惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
Google DeepMind News
Google DeepMind News
腾讯CDC
G
Google Developers Blog
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
Recent Announcements
Recent Announcements
爱范儿
爱范儿
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
有赞技术团队
有赞技术团队
Jina AI
Jina AI
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
M
MIT News - Artificial intelligence
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
美团技术团队
WordPress大学
WordPress大学
阮一峰的网络日志
阮一峰的网络日志

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(ci): preserve docker pull retry failures · openclaw/o...
vincentkoc · 2026-05-27 · via Recent Commits to openclaw:main

@@ -0,0 +1,167 @@

1+

import { execFileSync, spawnSync } from "node:child_process";

2+

import { chmodSync, existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";

3+

import { tmpdir } from "node:os";

4+

import path from "node:path";

5+

import { afterEach, describe, expect, it } from "vitest";

6+7+

const SCRIPT_PATH = path.resolve("scripts/ci-docker-pull-retry.sh");

8+

const tempDirs: string[] = [];

9+10+

function makeTempBin(prefix: string) {

11+

const dir = mkdtempSync(path.join(tmpdir(), prefix));

12+

tempDirs.push(dir);

13+

return dir;

14+

}

15+16+

function writeExecutable(filePath: string, contents: string) {

17+

writeFileSync(filePath, contents, "utf8");

18+

chmodSync(filePath, 0o755);

19+

}

20+21+

function runPullHelper(binDir: string) {

22+

return runPullHelperWithEnv(binDir, {});

23+

}

24+25+

function runPullHelperWithEnv(binDir: string, env: Record<string, string>) {

26+

return spawnSync("/bin/bash", [SCRIPT_PATH, "registry.example/openclaw:test"], {

27+

cwd: process.cwd(),

28+

encoding: "utf8",

29+

env: {

30+

...process.env,

31+

OPENCLAW_DOCKER_PULL_ATTEMPTS: "1",

32+

OPENCLAW_DOCKER_PULL_RETRY_DELAY_SECONDS: "0",

33+

OPENCLAW_DOCKER_PULL_TIMEOUT_SECONDS: "42",

34+

...env,

35+

PATH: binDir,

36+

},

37+

});

38+

}

39+40+

afterEach(() => {

41+

while (tempDirs.length > 0) {

42+

rmSync(tempDirs.pop()!, { force: true, recursive: true });

43+

}

44+

});

45+46+

describe("scripts/ci-docker-pull-retry.sh", () => {

47+

it("uses a kill-after grace period when timeout supports it", () => {

48+

const binDir = makeTempBin("openclaw-ci-docker-pull-gnu-");

49+

const timeoutArgsPath = path.join(binDir, "timeout-args.txt");

50+

const dockerArgsPath = path.join(binDir, "docker-args.txt");

51+52+

writeExecutable(

53+

path.join(binDir, "timeout"),

54+

[

55+

"#!/bin/bash",

56+

"set -euo pipefail",

57+

'if [ "${1:-}" = "--kill-after=1s" ]; then exit 0; fi',

58+

`printf "%s\\n" "$*" >${JSON.stringify(timeoutArgsPath)}`,

59+

'while [ "$#" -gt 0 ] && [ "$1" != "docker" ]; do shift; done',

60+

'exec "$@"',

61+

"",

62+

].join("\n"),

63+

);

64+

writeExecutable(

65+

path.join(binDir, "docker"),

66+

["#!/bin/sh", "set -eu", `printf "%s\\n" "$*" >${JSON.stringify(dockerArgsPath)}`, ""].join(

67+

"\n",

68+

),

69+

);

70+71+

const result = runPullHelper(binDir);

72+73+

expect(result.status).toBe(0);

74+

expect(execFileSync("cat", [timeoutArgsPath], { encoding: "utf8" }).trim()).toBe(

75+

"--kill-after=30s 42s docker pull registry.example/openclaw:test",

76+

);

77+

expect(execFileSync("cat", [dockerArgsPath], { encoding: "utf8" }).trim()).toBe(

78+

"pull registry.example/openclaw:test",

79+

);

80+

});

81+82+

it("falls back to plain timeout when kill-after is unavailable", () => {

83+

const binDir = makeTempBin("openclaw-ci-docker-pull-plain-");

84+

const timeoutArgsPath = path.join(binDir, "timeout-args.txt");

85+

const dockerArgsPath = path.join(binDir, "docker-args.txt");

86+87+

writeExecutable(

88+

path.join(binDir, "timeout"),

89+

[

90+

"#!/bin/bash",

91+

"set -euo pipefail",

92+

'if [ "${1:-}" = "--kill-after=1s" ]; then exit 1; fi',

93+

`printf "%s\\n" "$*" >${JSON.stringify(timeoutArgsPath)}`,

94+

'while [ "$#" -gt 0 ] && [ "$1" != "docker" ]; do shift; done',

95+

'exec "$@"',

96+

"",

97+

].join("\n"),

98+

);

99+

writeExecutable(

100+

path.join(binDir, "docker"),

101+

["#!/bin/sh", "set -eu", `printf "%s\\n" "$*" >${JSON.stringify(dockerArgsPath)}`, ""].join(

102+

"\n",

103+

),

104+

);

105+106+

const result = runPullHelper(binDir);

107+108+

expect(result.status).toBe(0);

109+

expect(execFileSync("cat", [timeoutArgsPath], { encoding: "utf8" }).trim()).toBe(

110+

"42s docker pull registry.example/openclaw:test",

111+

);

112+

expect(execFileSync("cat", [dockerArgsPath], { encoding: "utf8" }).trim()).toBe(

113+

"pull registry.example/openclaw:test",

114+

);

115+

});

116+117+

it("fails fast when timeout is unavailable", () => {

118+

const binDir = makeTempBin("openclaw-ci-docker-pull-no-timeout-");

119+

const dockerArgsPath = path.join(binDir, "docker-args.txt");

120+121+

writeExecutable(

122+

path.join(binDir, "docker"),

123+

["#!/bin/sh", "set -eu", `printf "%s\\n" "$*" >${JSON.stringify(dockerArgsPath)}`, ""].join(

124+

"\n",

125+

),

126+

);

127+128+

const result = runPullHelper(binDir);

129+130+

expect(result.status).toBe(127);

131+

expect(result.stderr).toContain("timeout command not found; cannot bound Docker pull after 42s");

132+

expect(existsSync(dockerArgsPath)).toBe(false);

133+

});

134+135+

it("returns the last pull failure status after retries are exhausted", () => {

136+

const binDir = makeTempBin("openclaw-ci-docker-pull-fail-");

137+

const dockerArgsPath = path.join(binDir, "docker-args.txt");

138+139+

writeExecutable(

140+

path.join(binDir, "timeout"),

141+

[

142+

"#!/bin/bash",

143+

"set -euo pipefail",

144+

'if [ "${1:-}" = "--kill-after=1s" ]; then exit 0; fi',

145+

'while [ "$#" -gt 0 ] && [ "$1" != "docker" ]; do shift; done',

146+

'exec "$@"',

147+

"",

148+

].join("\n"),

149+

);

150+

writeExecutable(

151+

path.join(binDir, "docker"),

152+

[

153+

"#!/bin/sh",

154+

"set -eu",

155+

`printf "%s\\n" "$*" >>${JSON.stringify(dockerArgsPath)}`,

156+

"exit 42",

157+

"",

158+

].join("\n"),

159+

);

160+161+

const result = runPullHelperWithEnv(binDir, { OPENCLAW_DOCKER_PULL_ATTEMPTS: "2" });

162+163+

expect(result.status).toBe(42);

164+

expect(result.stderr).toContain("Docker pull failed or timed out after 42s: status=42");

165+

expect(execFileSync("wc", ["-l", dockerArgsPath], { encoding: "utf8" }).trim()).toMatch(/^2\b/u);

166+

});

167+

});