File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ permissions:
55
66env :
77 FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : true
8+ # Re-run the test suite up to this many times before declaring failure.
9+ GEMC_TEST_MAX_ATTEMPTS : 3
810
911concurrency :
1012 group : sanitize-${{ github.workflow }}-${{ github.ref }}
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ permissions:
77
88env :
99 FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : true
10+ # Re-run the test suite up to this many times before declaring failure.
11+ GEMC_TEST_MAX_ATTEMPTS : 3
1012
1113concurrency :
1214 group : gemc-test-${{ github.ref }}
Original file line number Diff line number Diff line change @@ -89,25 +89,29 @@ function meson_setup_options {
8989 echo " ${args[@]} "
9090}
9191
92- # Run any command, retrying once on failure. Appends output to $test_log.
92+ # Run any command, retrying on failure. Appends output to $test_log.
93+ # The number of attempts is GEMC_TEST_MAX_ATTEMPTS (default 3), so a command is
94+ # re-run up to that many times until it succeeds.
9395function run_command_with_retry {
9496 local label=" $1 "
9597 shift
9698
97- for attempt in 1 2; do
98- echo " > Running ${label} (attempt ${attempt} /2):" " $@ " | tee -a " $test_log "
99+ local max_attempts=" ${GEMC_TEST_MAX_ATTEMPTS:- 3} "
100+
101+ for (( attempt = 1 ; attempt <= max_attempts; attempt++ )) ; do
102+ echo " > Running ${label} (attempt ${attempt} /${max_attempts} ):" " $@ " | tee -a " $test_log "
99103 " $@ " >> " $test_log "
100104 local exit_code=$?
101105
102106 if [ $exit_code -eq 0 ]; then
103107 return 0
104108 fi
105109
106- if [ $attempt -eq 2 ]; then
110+ if [ $attempt -eq $max_attempts ]; then
107111 return $exit_code
108112 fi
109113
110- echo " > ${label} failed; retrying once " | tee -a " $test_log "
114+ echo " > ${label} failed; retrying (attempt $(( attempt + 1 )) / ${max_attempts} ) " | tee -a " $test_log "
111115 done
112116}
113117
You can’t perform that action at this time.
0 commit comments