Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
208 lines
6.7 KiB
TypeScript
208 lines
6.7 KiB
TypeScript
// Ci Docker Pull Retry tests cover ci docker pull retry script behavior.
|
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
import { chmodSync, existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
|
|
const SCRIPT_PATH = path.resolve("scripts/ci-docker-pull-retry.sh");
|
|
const tempDirs: string[] = [];
|
|
|
|
function makeTempBin(prefix: string) {
|
|
const dir = mkdtempSync(path.join(tmpdir(), prefix));
|
|
tempDirs.push(dir);
|
|
return dir;
|
|
}
|
|
|
|
function writeExecutable(filePath: string, contents: string) {
|
|
writeFileSync(filePath, contents, "utf8");
|
|
chmodSync(filePath, 0o755);
|
|
}
|
|
|
|
function runPullHelper(binDir: string) {
|
|
return runPullHelperWithEnv(binDir, {});
|
|
}
|
|
|
|
function runPullHelperWithEnv(binDir: string, env: Record<string, string>) {
|
|
return spawnSync("/bin/bash", [SCRIPT_PATH, "registry.example/openclaw:test"], {
|
|
cwd: process.cwd(),
|
|
encoding: "utf8",
|
|
env: {
|
|
...process.env,
|
|
OPENCLAW_DOCKER_PULL_ATTEMPTS: "1",
|
|
OPENCLAW_DOCKER_PULL_RETRY_DELAY_SECONDS: "0",
|
|
OPENCLAW_DOCKER_PULL_TIMEOUT_SECONDS: "42",
|
|
...env,
|
|
PATH: binDir,
|
|
},
|
|
});
|
|
}
|
|
|
|
afterEach(() => {
|
|
while (tempDirs.length > 0) {
|
|
rmSync(tempDirs.pop()!, { force: true, recursive: true });
|
|
}
|
|
});
|
|
|
|
describe("scripts/ci-docker-pull-retry.sh", () => {
|
|
it("uses a kill-after grace period when timeout supports it", () => {
|
|
const binDir = makeTempBin("openclaw-ci-docker-pull-gnu-");
|
|
const timeoutArgsPath = path.join(binDir, "timeout-args.txt");
|
|
const dockerArgsPath = path.join(binDir, "docker-args.txt");
|
|
|
|
writeExecutable(
|
|
path.join(binDir, "timeout"),
|
|
[
|
|
"#!/bin/bash",
|
|
"set -euo pipefail",
|
|
'if [ "${1:-}" = "--kill-after=1s" ]; then exit 0; fi',
|
|
`printf "%s\\n" "$*" >${JSON.stringify(timeoutArgsPath)}`,
|
|
'while [ "$#" -gt 0 ] && [ "$1" != "docker" ]; do shift; done',
|
|
'exec "$@"',
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
writeExecutable(
|
|
path.join(binDir, "docker"),
|
|
["#!/bin/sh", "set -eu", `printf "%s\\n" "$*" >${JSON.stringify(dockerArgsPath)}`, ""].join(
|
|
"\n",
|
|
),
|
|
);
|
|
|
|
const result = runPullHelper(binDir);
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(execFileSync("cat", [timeoutArgsPath], { encoding: "utf8" }).trim()).toBe(
|
|
"--kill-after=30s 42s docker pull registry.example/openclaw:test",
|
|
);
|
|
expect(execFileSync("cat", [dockerArgsPath], { encoding: "utf8" }).trim()).toBe(
|
|
"pull registry.example/openclaw:test",
|
|
);
|
|
});
|
|
|
|
it("falls back to plain timeout when kill-after is unavailable", () => {
|
|
const binDir = makeTempBin("openclaw-ci-docker-pull-plain-");
|
|
const timeoutArgsPath = path.join(binDir, "timeout-args.txt");
|
|
const dockerArgsPath = path.join(binDir, "docker-args.txt");
|
|
|
|
writeExecutable(
|
|
path.join(binDir, "timeout"),
|
|
[
|
|
"#!/bin/bash",
|
|
"set -euo pipefail",
|
|
'if [ "${1:-}" = "--kill-after=1s" ]; then exit 1; fi',
|
|
`printf "%s\\n" "$*" >${JSON.stringify(timeoutArgsPath)}`,
|
|
'while [ "$#" -gt 0 ] && [ "$1" != "docker" ]; do shift; done',
|
|
'exec "$@"',
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
writeExecutable(
|
|
path.join(binDir, "docker"),
|
|
["#!/bin/sh", "set -eu", `printf "%s\\n" "$*" >${JSON.stringify(dockerArgsPath)}`, ""].join(
|
|
"\n",
|
|
),
|
|
);
|
|
|
|
const result = runPullHelper(binDir);
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(execFileSync("cat", [timeoutArgsPath], { encoding: "utf8" }).trim()).toBe(
|
|
"42s docker pull registry.example/openclaw:test",
|
|
);
|
|
expect(execFileSync("cat", [dockerArgsPath], { encoding: "utf8" }).trim()).toBe(
|
|
"pull registry.example/openclaw:test",
|
|
);
|
|
});
|
|
|
|
it("uses gtimeout when timeout is unavailable", () => {
|
|
const binDir = makeTempBin("openclaw-ci-docker-pull-gtimeout-");
|
|
const timeoutArgsPath = path.join(binDir, "gtimeout-args.txt");
|
|
const dockerArgsPath = path.join(binDir, "docker-args.txt");
|
|
|
|
writeExecutable(
|
|
path.join(binDir, "gtimeout"),
|
|
[
|
|
"#!/bin/bash",
|
|
"set -euo pipefail",
|
|
'if [ "${1:-}" = "--kill-after=1s" ]; then exit 0; fi',
|
|
`printf "%s\\n" "gtimeout:$*" >${JSON.stringify(timeoutArgsPath)}`,
|
|
'while [ "$#" -gt 0 ] && [ "$1" != "docker" ]; do shift; done',
|
|
'exec "$@"',
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
writeExecutable(
|
|
path.join(binDir, "docker"),
|
|
["#!/bin/sh", "set -eu", `printf "%s\\n" "$*" >${JSON.stringify(dockerArgsPath)}`, ""].join(
|
|
"\n",
|
|
),
|
|
);
|
|
|
|
const result = runPullHelper(binDir);
|
|
|
|
expect(result.status).toBe(0);
|
|
expect(execFileSync("cat", [timeoutArgsPath], { encoding: "utf8" }).trim()).toBe(
|
|
"gtimeout:--kill-after=30s 42s docker pull registry.example/openclaw:test",
|
|
);
|
|
expect(execFileSync("cat", [dockerArgsPath], { encoding: "utf8" }).trim()).toBe(
|
|
"pull registry.example/openclaw:test",
|
|
);
|
|
});
|
|
|
|
it("fails fast when timeout and gtimeout are unavailable", () => {
|
|
const binDir = makeTempBin("openclaw-ci-docker-pull-no-timeout-");
|
|
const dockerArgsPath = path.join(binDir, "docker-args.txt");
|
|
|
|
writeExecutable(
|
|
path.join(binDir, "docker"),
|
|
["#!/bin/sh", "set -eu", `printf "%s\\n" "$*" >${JSON.stringify(dockerArgsPath)}`, ""].join(
|
|
"\n",
|
|
),
|
|
);
|
|
|
|
const result = runPullHelper(binDir);
|
|
|
|
expect(result.status).toBe(127);
|
|
expect(result.stderr).toContain(
|
|
"timeout or gtimeout command not found; cannot bound Docker pull after 42s",
|
|
);
|
|
expect(existsSync(dockerArgsPath)).toBe(false);
|
|
});
|
|
|
|
it("returns the last pull failure status after retries are exhausted", () => {
|
|
const binDir = makeTempBin("openclaw-ci-docker-pull-fail-");
|
|
const dockerArgsPath = path.join(binDir, "docker-args.txt");
|
|
|
|
writeExecutable(
|
|
path.join(binDir, "timeout"),
|
|
[
|
|
"#!/bin/bash",
|
|
"set -euo pipefail",
|
|
'if [ "${1:-}" = "--kill-after=1s" ]; then exit 0; fi',
|
|
'while [ "$#" -gt 0 ] && [ "$1" != "docker" ]; do shift; done',
|
|
'exec "$@"',
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
writeExecutable(
|
|
path.join(binDir, "docker"),
|
|
[
|
|
"#!/bin/sh",
|
|
"set -eu",
|
|
`printf "%s\\n" "$*" >>${JSON.stringify(dockerArgsPath)}`,
|
|
"exit 42",
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
|
|
const result = runPullHelperWithEnv(binDir, { OPENCLAW_DOCKER_PULL_ATTEMPTS: "2" });
|
|
|
|
expect(result.status).toBe(42);
|
|
expect(result.stderr).toContain("Docker pull failed or timed out after 42s: status=42");
|
|
expect(execFileSync("wc", ["-l", dockerArgsPath], { encoding: "utf8" }).trim()).toMatch(
|
|
/^2\b/u,
|
|
);
|
|
});
|
|
});
|