Last active
September 5, 2021 08:56
-
-
Save Weiyuan-Lane/2da1d653e68ddb40386383a51e5671cb to your computer and use it in GitHub Desktop.
For running autify test plan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run regression tests on Autify | |
response=$(\ | |
curl -XPOST -s -H "Authorization: Bearer ${AUTIFY_PERSONAL_ACCESS_TOKEN}" \ | |
"https://app.autify.com/api/v1/schedules/${AUTIFY_TEST_PLAN_ID}" \ | |
) | |
# Get test plan result URL | |
test_plan_result_id=$(echo ${response} | jq -r .data.id) | |
test_plan_result_url="https://app.autify.com/projects/${AUTIFY_PROJECT_ID}/results/${test_plan_result_id}" | |
test_plan_result_api_url="https://app.autify.com/api/v1/projects/${AUTIFY_PROJECT_ID}/results/${test_plan_result_id}" | |
# Check for the status every 10 seconds | |
echo "You can check if the results directly at $test_plan_result_url while the CI is running" | |
while : | |
do | |
# Every iteration, check for the results | |
test_response=$(\ | |
curl -X GET -s -H "Authorization: Bearer ${AUTIFY_PERSONAL_ACCESS_TOKEN}" \ | |
"${test_plan_result_api_url}" \ | |
) | |
status=$(echo ${test_response} | jq -r .status) | |
# Based on the status, wait, exit, or throw an error status | |
case "$status" in | |
"queuing"|"waiting"|"running") | |
echo "Test status is \"$status\" ... checking again in 10 seconds" | |
sleep 10 | |
;; | |
"passed") | |
echo "Test status is \"$status\" ... exiting" | |
exit 0 | |
;; | |
"failed"|"skipped") | |
echo "Test status is \"$status\" ... exiting" | |
exit 1 | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment