Skip to content

Commit

Permalink
Merge pull request #29 from keboola/ondra-test-kbc-tests
Browse files Browse the repository at this point in the history
Run KBC test jobs on new Queue
  • Loading branch information
ondrajodas authored Nov 4, 2021
2 parents ce4703f + bf3f905 commit ee3960b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ env:
# Test KBC project
KBC_STORAGE_TOKEN: ${{ secrets.KBC_STORAGE_TOKEN }}
KBC_TEST_PROJECT_URL: "https://connection.keboola.com/admin/projects/8296"
#KBC_TEST_PROJECT_CONFIGS: "638537315 636916992" # space separated list
KBC_TEST_PROJECT_CONFIGS: "" # space separated list
KBC_TEST_PROJECT_CONFIGS: "638537315 636916992" # space separated list
jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -104,16 +103,16 @@ jobs:
tests-in-kbc:
needs: build
runs-on: ubuntu-latest
env:
TAG: ${{ needs.build.outputs.app_image_tag }}
steps:
-
name: Check out the repo
uses: actions/checkout@v2
-
name: Run KBC test jobs
if: env.KBC_STORAGE_TOKEN && env.KBC_TEST_PROJECT_CONFIGS
uses: keboola/action-run-configs-parallel@master
with:
token: ${{ env.KBC_STORAGE_TOKEN }}
componentId: ${{ env.KBC_DEVELOPERPORTAL_APP }}
tag: ${{ needs.build.outputs.app_image_tag }}
configs: ${{ env.KBC_TEST_PROJECT_CONFIGS }}
run: ./kbctests.sh

deploy:
needs:
Expand Down
29 changes: 29 additions & 0 deletions kbctests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
set -e

for config in ${KBC_TEST_PROJECT_CONFIGS}
do
export CONFIG="{\"component\": \"${KBC_DEVELOPERPORTAL_APP}\",\"mode\": \"run\",\"config\": \"${config}\",\"tag\": \"${TAG}\"}"

jobid=$(curl -s -X POST -H "X-StorageApi-Token: ${KBC_STORAGE_TOKEN}" -H "Content-Type: application/json" -d "${CONFIG}" https://queue.keboola.com/jobs | jq -r '.id')
echo "Job '$jobid' started"
jobfinished=false
while ! $jobfinished; do
sleep 5
curl -s -X GET -H "X-StorageApi-Token: ${KBC_STORAGE_TOKEN}" -H "Content-Type: application/json" https://queue.keboola.com/jobs/$jobid > jobResult.json
jobfinished=$(jq -r '.isFinished' jobResult.json)
status=$(jq -r '.status' jobResult.json)

if [[ "$jobfinished" == "true" && "$status" != "success" ]]
then
echo "Job '$jobid' ended with status '$status'"
exit 1
fi
if [ "$jobfinished" == "true" ]
then
echo "Job '$jobid' has been successful"
fi
done
done

echo "OK"

0 comments on commit ee3960b

Please sign in to comment.