Skip to content

Commit 1dac6ac

Browse files
committed
ci: retry transient live provider flakes
1 parent 6b4873d commit 1dac6ac

3 files changed

Lines changed: 69 additions & 2 deletions

File tree

‎.github/workflows/openclaw-live-and-e2e-checks-reusable.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,9 @@ jobs:
19231923
19241924
- name: Run ${{ matrix.label }}
19251925
if: contains(matrix.profiles, inputs.release_test_profile)
1926-
run: ${{ matrix.command }}
1926+
env:
1927+
OPENCLAW_LIVE_COMMAND: ${{ matrix.command }}
1928+
run: bash .release-harness/scripts/ci-live-command-retry.sh
19271929

19281930
validate_live_docker_provider_suites:
19291931
name: Docker live suites (${{ matrix.label }})
@@ -2082,7 +2084,9 @@ jobs:
20822084
20832085
- name: Run ${{ matrix.label }}
20842086
if: contains(matrix.profiles, inputs.release_test_profile)
2085-
run: ${{ matrix.command }}
2087+
env:
2088+
OPENCLAW_LIVE_COMMAND: ${{ matrix.command }}
2089+
run: bash .release-harness/scripts/ci-live-command-retry.sh
20862090

20872091
validate_live_media_provider_suites:
20882092
name: Live media suites (${{ matrix.label }})

‎scripts/ci-live-command-retry.sh‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
command="${OPENCLAW_LIVE_COMMAND:-}"
5+
if [[ -z "$command" && "$#" -gt 0 ]]; then
6+
command="$*"
7+
fi
8+
9+
if [[ -z "$command" ]]; then
10+
echo "Usage: OPENCLAW_LIVE_COMMAND='<command>' $0" >&2
11+
exit 64
12+
fi
13+
14+
attempts="${OPENCLAW_LIVE_COMMAND_ATTEMPTS:-2}"
15+
delay_seconds="${OPENCLAW_LIVE_COMMAND_RETRY_DELAY_SECONDS:-10}"
16+
retry_pattern="${OPENCLAW_LIVE_COMMAND_RETRY_PATTERN:-ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|fetch failed|TLS connection|socket hang up|UND_ERR|\\b429\\b|\\b529\\b}"
17+
18+
if ! [[ "$attempts" =~ ^[1-9][0-9]*$ ]]; then
19+
echo "OPENCLAW_LIVE_COMMAND_ATTEMPTS must be a positive integer, got: $attempts" >&2
20+
exit 64
21+
fi
22+
23+
if ! [[ "$delay_seconds" =~ ^[0-9]+$ ]]; then
24+
echo "OPENCLAW_LIVE_COMMAND_RETRY_DELAY_SECONDS must be a non-negative integer, got: $delay_seconds" >&2
25+
exit 64
26+
fi
27+
28+
log_file="$(mktemp)"
29+
cleanup() {
30+
rm -f "$log_file"
31+
}
32+
trap cleanup EXIT
33+
34+
for attempt in $(seq 1 "$attempts"); do
35+
: >"$log_file"
36+
set +e
37+
bash -o pipefail -c "$command" 2>&1 | tee "$log_file"
38+
status="${PIPESTATUS[0]}"
39+
set -e
40+
41+
if [[ "$status" -eq 0 ]]; then
42+
exit 0
43+
fi
44+
45+
if [[ "$attempt" -ge "$attempts" ]]; then
46+
exit "$status"
47+
fi
48+
49+
if ! grep -Eiq "$retry_pattern" "$log_file"; then
50+
exit "$status"
51+
fi
52+
53+
echo "Live command failed with a retryable provider/network error; retrying ($attempt/$attempts)..." >&2
54+
if [[ "$delay_seconds" -gt 0 ]]; then
55+
sleep "$delay_seconds"
56+
fi
57+
done

‎test/scripts/package-acceptance-workflow.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ describe("package artifact reuse", () => {
119119

120120
it("shards broad native live tests instead of one serial live-all job", () => {
121121
const workflow = readFileSync(LIVE_E2E_WORKFLOW, "utf8");
122+
const retryHelper = readFileSync("scripts/ci-live-command-retry.sh", "utf8");
122123

123124
expect(workflow).not.toContain("suite_id: live-all");
124125
expect(workflow).not.toContain("command: pnpm test:live\n");
@@ -127,6 +128,8 @@ describe("package artifact reuse", () => {
127128
expect(workflow).toContain(
128129
"command: node .release-harness/scripts/test-live-shard.mjs native-live-src-agents",
129130
);
131+
expect(workflow).toContain("OPENCLAW_LIVE_COMMAND: ${{ matrix.command }}");
132+
expect(workflow).toContain("bash .release-harness/scripts/ci-live-command-retry.sh");
130133
expect(workflow).toContain("suite_id: native-live-src-gateway-core");
131134
expect(workflow).toContain("suite_id: native-live-src-gateway-backends");
132135
expect(workflow).toContain("suite_id: native-live-src-gateway-profiles-deepseek");
@@ -150,6 +153,9 @@ describe("package artifact reuse", () => {
150153
expect(workflow).toContain("suite_id: native-live-extensions-media-music-minimax");
151154
expect(workflow).toContain("suite_id: native-live-extensions-media-video");
152155
expect(workflow).not.toContain("needs_ffmpeg: true");
156+
expect(retryHelper).toContain("OPENCLAW_LIVE_COMMAND_ATTEMPTS:-2");
157+
expect(retryHelper).toContain("ECONNRESET");
158+
expect(retryHelper).toContain("fetch failed");
153159
});
154160

155161
it("runs Docker live harnesses from trusted helper scripts", () => {

0 commit comments

Comments
 (0)