Skip to content

Commit 34adb06

Browse files
committed
test retry configurable
1 parent b3f2a76 commit 34adb06

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

.github/workflows/sanitize.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ permissions:
55

66
env:
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

911
concurrency:
1012
group: sanitize-${{ github.workflow }}-${{ github.ref }}

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ permissions:
77

88
env:
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

1113
concurrency:
1214
group: gemc-test-${{ github.ref }}

ci/env.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff 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.
9395
function 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

0 commit comments

Comments
 (0)