Skip to content

Commit ef0c883

Browse files
authored
perf(ci): avoid duplicate local release package validation (#134505)
* perf(ci): avoid duplicate local release package validation * test(ci): align source package proof with single validation
1 parent 8da38d8 commit ef0c883

3 files changed

Lines changed: 144 additions & 10 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,15 +2628,15 @@ jobs:
26282628
fi
26292629
cp "${tgzs[0]}" "$target"
26302630
fi
2631-
echo "Validating Docker E2E package tarball: $target"
2632-
validator=(node scripts/check-openclaw-package-tarball.mjs)
2631+
# Local pack validates final bytes; imports need the trusted harness before identity checks.
26332632
if [[ -n "${EXPECTED_PACKAGE_FILE_NAME// }" ]]; then
2633+
echo "Validating Docker E2E package tarball: $target"
26342634
validator=(bash -c 'cd .release-harness && pnpm exec node scripts/check-openclaw-package-tarball.mjs "$1"' --)
2635+
started_at="$(date +%s)"
2636+
timeout --foreground 5m "${validator[@]}" "$GITHUB_WORKSPACE/$target"
2637+
finished_at="$(date +%s)"
2638+
echo "Docker E2E package tarball validation finished in $((finished_at - started_at))s."
26352639
fi
2636-
started_at="$(date +%s)"
2637-
timeout --foreground 5m "${validator[@]}" "$GITHUB_WORKSPACE/$target"
2638-
finished_at="$(date +%s)"
2639-
echo "Docker E2E package tarball validation finished in $((finished_at - started_at))s."
26402640
digest="$(sha256sum "$target" | awk '{print $1}')"
26412641
version="$(tar -xOf "$target" package/package.json | jq -r '.version')"
26422642
name="$(tar -xOf "$target" package/package.json | jq -r '.name')"

‎test/scripts/package-source-preflight.test.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,6 @@ if [[ "$1" == "scripts/package-openclaw-for-docker.mjs" ]]; then
196196
rm -rf "$fixture"
197197
exit 0
198198
fi
199-
if [[ "$1" == "scripts/check-openclaw-package-tarball.mjs" ]]; then
200-
exit 0
201-
fi
202199
exit 64
203200
`,
204201
{ mode: 0o755 },
@@ -653,7 +650,6 @@ describe("package source preflight", () => {
653650
expect(result.validationResult.status, result.validationResult.stderr).toBe(0);
654651
expect(result.calls).toEqual([
655652
expect.stringContaining("scripts/package-openclaw-for-docker.mjs"),
656-
expect.stringContaining("scripts/check-openclaw-package-tarball.mjs"),
657653
]);
658654
expect(result.output).toMatchObject({
659655
file_name: "openclaw-current.tgz",

‎test/scripts/release-no-push-workflow.test.ts‎

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { spawnSync } from "node:child_process";
2+
import { createHash } from "node:crypto";
23
import {
34
chmodSync,
45
existsSync,
@@ -307,6 +308,143 @@ function executeParentFilterValidation(
307308
}
308309

309310
describe("release validation no-push transport", () => {
311+
it.each([
312+
{ name: "local validated package", imported: false, status: 0, calls: 0 },
313+
{ name: "imported package", imported: true, status: 0, calls: 1 },
314+
{ name: "imported validator failure", imported: true, checkExit: 7, status: 7, calls: 1 },
315+
{
316+
name: "local source mismatch",
317+
imported: false,
318+
wrongSource: true,
319+
status: 1,
320+
calls: 0,
321+
error: "Exact-target package build commit differs from the selected SHA.",
322+
},
323+
{
324+
name: "imported digest mismatch",
325+
imported: true,
326+
wrongDigest: true,
327+
status: 1,
328+
calls: 0,
329+
error: "Declared package tarball SHA-256 differs from package_sha256.",
330+
},
331+
{
332+
name: "imported version mismatch",
333+
imported: true,
334+
wrongVersion: true,
335+
status: 1,
336+
calls: 1,
337+
error: "Resolved package identity differs from the declared immutable tuple.",
338+
},
339+
{
340+
name: "local metadata mismatch",
341+
imported: false,
342+
wrongMetadata: true,
343+
status: 1,
344+
calls: 0,
345+
error: "Exact-target package metadata does not bind the selected SHA and tarball.",
346+
},
347+
])("validates package identity without repeating local pack checks: $name", (fixture) => {
348+
const validate = step(
349+
job(readWorkflow(LIVE_E2E), "prepare_docker_e2e_image"),
350+
"Validate OpenClaw Docker E2E package",
351+
);
352+
const root = tempDirs.make("release package identity-");
353+
const artifacts = join(root, ".artifacts/docker-e2e-package");
354+
const bin = join(root, "bin");
355+
const calls = join(root, "validator-calls");
356+
const output = join(root, "github-output");
357+
const source = "a".repeat(40);
358+
const version = "2026.8.1";
359+
for (const directory of [
360+
artifacts,
361+
bin,
362+
"package/dist",
363+
"scripts",
364+
".release-harness/scripts",
365+
]) {
366+
mkdirSync(resolve(root, directory), { recursive: true });
367+
}
368+
writeFileSync(
369+
join(root, "package/package.json"),
370+
JSON.stringify({ name: "openclaw", version }),
371+
);
372+
writeFileSync(
373+
join(root, "package/dist/build-info.json"),
374+
JSON.stringify({ commit: fixture.wrongSource ? "b".repeat(40) : source }),
375+
);
376+
const fileName = fixture.imported ? "provided package.tgz" : "openclaw-current.tgz";
377+
const tarball = join(artifacts, fileName);
378+
const pack = spawnSync("tar", ["-czf", tarball, "-C", root, "package"], { encoding: "utf8" });
379+
expect(pack.status, pack.stderr).toBe(0);
380+
const digest = createHash("sha256").update(readFileSync(tarball)).digest("hex");
381+
if (fixture.wrongMetadata) {
382+
writeFileSync(
383+
join(artifacts, "package-candidate.json"),
384+
JSON.stringify({
385+
name: "openclaw",
386+
packageSourceSha: source,
387+
sha256: "b".repeat(64),
388+
version,
389+
}),
390+
);
391+
}
392+
writeFileSync(output, "");
393+
writeFileSync(calls, "");
394+
// Instrument only the validator/package-manager boundary; identity checks use real tar, jq and hashes.
395+
writeFileSync(
396+
join(root, "scripts/check-openclaw-package-tarball.mjs"),
397+
'throw new Error("local pack already validated this package");\n',
398+
);
399+
writeFileSync(
400+
join(root, ".release-harness/scripts/check-openclaw-package-tarball.mjs"),
401+
'import fs from "node:fs"; fs.appendFileSync(process.env.VALIDATOR_CALLS, JSON.stringify(process.argv.slice(2)) + "\\n"); process.exit(Number(process.env.CHECK_EXIT));\n',
402+
);
403+
writeFileSync(
404+
join(bin, "pnpm"),
405+
'#!/usr/bin/env bash\n[[ "$1" == exec ]] || exit 98\nshift\nexec "$@"\n',
406+
);
407+
chmodSync(join(bin, "pnpm"), 0o755);
408+
const result = spawnSync("bash", ["-euo", "pipefail", "-c", validate.run ?? ""], {
409+
cwd: root,
410+
encoding: "utf8",
411+
env: {
412+
PATH: `${bin}:${process.env.PATH ?? ""}`,
413+
CHECK_EXIT: String(fixture.checkExit ?? 0),
414+
EXPECTED_PACKAGE_FILE_NAME: fixture.imported ? fileName : "",
415+
EXPECTED_PACKAGE_SHA256: fixture.imported
416+
? fixture.wrongDigest
417+
? "b".repeat(64)
418+
: digest
419+
: "",
420+
EXPECTED_PACKAGE_SOURCE_SHA: fixture.imported ? source : "",
421+
EXPECTED_PACKAGE_VERSION: fixture.imported
422+
? fixture.wrongVersion
423+
? "2026.7.1"
424+
: version
425+
: "",
426+
GITHUB_OUTPUT: output,
427+
GITHUB_STEP_SUMMARY: join(root, "summary"),
428+
GITHUB_WORKSPACE: root,
429+
SELECTED_SHA: source,
430+
SHARED_IMAGE_POLICY: "no-push-artifact",
431+
VALIDATOR_CALLS: calls,
432+
},
433+
});
434+
expect(result.status, result.stderr).toBe(fixture.status);
435+
if (fixture.error) {
436+
expect(result.stderr).toContain(fixture.error);
437+
}
438+
expect(readFileSync(calls, "utf8")).toBe(
439+
fixture.calls ? `${JSON.stringify([join(artifacts, "openclaw-current.tgz")])}\n` : "",
440+
);
441+
expect(readFileSync(output, "utf8")).toBe(
442+
fixture.status === 0
443+
? `sha256=${digest}\nversion=${version}\nfile_name=openclaw-current.tgz\nsource_sha=${source}\ntag=pkg-${digest.slice(0, 32)}\n`
444+
: "",
445+
);
446+
});
447+
310448
it("routes release retries through explicit concrete groups and resource gates", () => {
311449
const full = readWorkflow(FULL_RELEASE);
312450
const release = readWorkflow(RELEASE_CHECKS);

0 commit comments

Comments
 (0)