Skip to content

Commit

Permalink
Merge pull request snyk#1015 from snyk/fix/windows-test-check-on-build
Browse files Browse the repository at this point in the history
fix: on merge PR use correct commit SHA
  • Loading branch information
dkontorovskyy authored Feb 21, 2020
2 parents c8d5a73 + 752a032 commit 22fa0ab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/check_circleci_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ workflow_name="test_and_release"
declare -i max_retry=120
declare -i i=0
STATUS_ARR=("")
COMMIT_TO_RUN=$([[ -z ${TRAVIS_PULL_REQUEST_SHA} ]] && echo ${TRAVIS_COMMIT} || echo ${TRAVIS_PULL_REQUEST_SHA})

echo 'TRAVIS_COMMIT='${TRAVIS_COMMIT}
echo 'TRAVIS_PULL_REQUEST_SHA='${TRAVIS_PULL_REQUEST_SHA}

while [[ "${STATUS_ARR[0]}" != "completed" && "${i}" -lt "${max_retry}" ]]
do
((i++)) # increment attempts so if won't go forever
curl_result=$(curl -s \
-H 'Accept: application/vnd.github.antiope-preview+json' \
-H 'Authorization: token '${GH_TOKEN} \
'https://api.github.com/repos/'${TRAVIS_REPO_SLUG}'/commits/'${TRAVIS_PULL_REQUEST_SHA}'/check-runs') # query github for CircleCI job status
'https://api.github.com/repos/'${TRAVIS_REPO_SLUG}'/commits/'${COMMIT_TO_RUN}'/check-runs') # query github for CircleCI job status
result=$(echo ${curl_result} | jq -r '.check_runs[] | select(.name == "'${workflow_name}'") | "\(.status) \(.conclusion)"') # extract status and conclusion
IFS=' ' read -ra STATUS_ARR <<< "$result"
echo $(date '+%F %T') 'Not completed yet. Finished '${i}' attempt out of '${max_retry}'. Current status: '${result}
echo $(date '+%F %T') 'Not completed for '${COMMIT_TO_RUN}'. Finished '${i}' attempt out of '${max_retry}'. Current status: '${result}

sleep 15
done
Expand Down

0 comments on commit 22fa0ab

Please sign in to comment.