@@ -13,7 +13,7 @@ get_latest_run_id() {
13
13
echo " $latest_run_id "
14
14
}
15
15
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
17
17
get_run_status () {
18
18
run_id=" $1 "
19
19
run_status=$( curl -s -H " Authorization: Bearer $GITHUB_TOKEN " \
@@ -24,6 +24,17 @@ get_run_status() {
24
24
echo " $run_status "
25
25
}
26
26
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
+
27
38
# Function to trigger a workflow dispatch event to run the e2e test
28
39
trigger_workflow () {
29
40
curl -s -H " Authorization: Bearer $GITHUB_TOKEN " \
@@ -40,24 +51,25 @@ main() {
40
51
# Get the latest run ID and initial status
41
52
latest_run_id=$( get_latest_run_id)
42
53
echo " Latest run ID: $latest_run_id "
43
- latest_status =$( get_run_status " $latest_run_id " )
54
+ run_status =$( get_run_status " $latest_run_id " )
44
55
timeout=$(( SECONDS + 600 )) # 600 seconds = 10 minutes
45
56
46
57
# Continuously check for status until completion
47
- while [[ " $latest_status " != " completed" && " $SECONDS " -lt " $timeout " ]]; do
58
+ while [[ " $run_status " != " completed" && " $SECONDS " -lt " $timeout " ]]; do
48
59
echo " Test run status: $latest_status "
49
60
sleep 10 # Wait before checking again
50
- latest_status =$( get_run_status " $latest_run_id " )
61
+ run_status =$( get_run_status " $latest_run_id " )
51
62
done
52
63
53
64
# Check if the run completed within the specified duration
54
- if [[ " $latest_status " != " completed" ]]; then
65
+ if [[ " $run_status " != " completed" ]]; then
55
66
echo " The test run did not complete within the specified duration."
56
67
exit 1
57
68
fi
58
69
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
61
73
echo " The test run failed."
62
74
exit 1
63
75
else
0 commit comments