@@ -13,7 +13,7 @@ get_latest_run_id() {
1313 echo " $latest_run_id "
1414}
1515
16- # Function to get the status of a workflow run
16+ # Function to get the status of a workflow run - can be queued or in_progress or completed
1717get_run_status () {
1818 run_id=" $1 "
1919 run_status=$( curl -s -H " Authorization: Bearer $GITHUB_TOKEN " \
@@ -24,6 +24,17 @@ get_run_status() {
2424 echo " $run_status "
2525}
2626
27+ # Function to get the status of a test run - can be success or failure
28+ get_test_status () {
29+ run_id=" $1 "
30+ test_status=$( curl -s -H " Authorization: Bearer $GITHUB_TOKEN " \
31+ -H " Accept: application/vnd.github+json" \
32+ -H " X-GitHub-Api-Version: 2022-11-28" \
33+ " https://api.github.com/repos/$REPO_OWNER /$REPO_NAME /actions/runs/$run_id " | \
34+ jq -r ' .conclusion' )
35+ echo " $test_status "
36+ }
37+
2738# Function to trigger a workflow dispatch event to run the e2e test
2839trigger_workflow () {
2940 curl -s -H " Authorization: Bearer $GITHUB_TOKEN " \
@@ -40,24 +51,25 @@ main() {
4051 # Get the latest run ID and initial status
4152 latest_run_id=$( get_latest_run_id)
4253 echo " Latest run ID: $latest_run_id "
43- latest_status =$( get_run_status " $latest_run_id " )
44- timeout=$(( SECONDS + 600 )) # 600 seconds = 10 minutes
54+ run_status =$( get_run_status " $latest_run_id " )
55+ timeout=$(( SECONDS + 1200 )) # 1200 seconds = 20 minutes
4556
4657 # Continuously check for status until completion
47- while [[ " $latest_status " != " completed" && " $SECONDS " -lt " $timeout " ]]; do
48- echo " Test run status: $latest_status "
58+ while [[ " $run_status " != " completed" && " $SECONDS " -lt " $timeout " ]]; do
59+ echo " Test run status: $run_status "
4960 sleep 10 # Wait before checking again
50- latest_status =$( get_run_status " $latest_run_id " )
61+ run_status =$( get_run_status " $latest_run_id " )
5162 done
5263
5364 # Check if the run completed within the specified duration
54- if [[ " $latest_status " != " completed" ]]; then
65+ if [[ " $run_status " != " completed" ]]; then
5566 echo " The test run did not complete within the specified duration."
5667 exit 1
5768 fi
5869
59- # Check if the run failed and throw an error if it did
60- if [[ " $latest_status " == " failure" ]]; then
70+ test_status=$( get_test_status " $latest_run_id " )
71+ # Check if the test failed and throw an error if it did
72+ if [[ " $test_status " != " success" ]]; then
6173 echo " The test run failed."
6274 exit 1
6375 else
0 commit comments