Skip to content

Commit d5f41f7

Browse files
authored
fix(ci): trust QA tooling for frozen targets (#124509)
* fix(ci): trust QA tooling for frozen targets * fix(ci): validate frozen QA tooling context * fix(ci): verify frozen context without checkout * fix(ci): pin QA tooling to workflow revision
1 parent 77902b1 commit d5f41f7

2 files changed

Lines changed: 294 additions & 0 deletions

File tree

‎.github/workflows/openclaw-release-checks.yml‎

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ jobs:
153153
run_maturity_scorecard: ${{ steps.inputs.outputs.run_maturity_scorecard }}
154154
allow_unreleased_changelog: ${{ steps.inputs.outputs.allow_unreleased_changelog }}
155155
skip_package_telegram_e2e: ${{ steps.inputs.outputs.skip_package_telegram_e2e }}
156+
trusted_qa_tooling_eligible: ${{ steps.trusted_qa_tooling.outputs.eligible }}
156157
rerun_group: ${{ steps.inputs.outputs.rerun_group }}
157158
live_suite_filter: ${{ steps.inputs.outputs.live_suite_filter }}
158159
repo_live_suite_filter: ${{ steps.inputs.outputs.repo_live_suite_filter }}
@@ -202,6 +203,79 @@ jobs:
202203
exit 1
203204
fi
204205
206+
- name: Validate trusted QA tooling context
207+
id: trusted_qa_context
208+
if: inputs.target_context_ref != ''
209+
env:
210+
TARGET_CONTEXT_REF: ${{ inputs.target_context_ref }}
211+
TARGET_REF: ${{ inputs.ref }}
212+
run: |
213+
set -euo pipefail
214+
normalized_context_ref="$TARGET_CONTEXT_REF"
215+
case "$normalized_context_ref" in
216+
refs/heads/*) normalized_context_ref="${normalized_context_ref#refs/heads/}" ;;
217+
refs/tags/*) normalized_context_ref="${normalized_context_ref#refs/tags/}" ;;
218+
esac
219+
if [[ "$normalized_context_ref" =~ ^(release/[0-9]{4}\.([1-9]|1[0-2])\.[1-9][0-9]*|extended-stable/[0-9]{4}\.([1-9]|1[0-2])\.33)$ ]]; then
220+
context_kind=branch
221+
fetch_ref="refs/heads/${normalized_context_ref}"
222+
elif [[ "$normalized_context_ref" =~ ^v[0-9]{4}\.([1-9]|1[0-2])\.[1-9][0-9]*(-(alpha|beta)\.[1-9][0-9]*)?$ ]]; then
223+
context_kind=tag
224+
fetch_ref="refs/tags/${normalized_context_ref}"
225+
else
226+
echo "target_context_ref must be a canonical OpenClaw release branch or tag." >&2
227+
exit 1
228+
fi
229+
if [[ ! "$TARGET_REF" =~ ^[0-9a-fA-F]{40}$ ]]; then
230+
echo "target_context_ref requires ref to be a full 40-character commit SHA." >&2
231+
exit 1
232+
fi
233+
echo "normalized_ref=${normalized_context_ref}" >> "$GITHUB_OUTPUT"
234+
echo "context_kind=${context_kind}" >> "$GITHUB_OUTPUT"
235+
echo "fetch_ref=${fetch_ref}" >> "$GITHUB_OUTPUT"
236+
237+
- name: Validate trusted QA tooling eligibility
238+
id: trusted_qa_tooling
239+
if: steps.trusted_qa_context.outputs.fetch_ref != ''
240+
env:
241+
CONTEXT_FETCH_REF: ${{ steps.trusted_qa_context.outputs.fetch_ref }}
242+
CONTEXT_KIND: ${{ steps.trusted_qa_context.outputs.context_kind }}
243+
CONTEXT_REF: ${{ steps.trusted_qa_context.outputs.normalized_ref }}
244+
TARGET_REF: ${{ inputs.ref }}
245+
TRUSTED_REPOSITORY_URL: https://github.com/${{ github.repository }}.git
246+
run: |
247+
set -euo pipefail
248+
context_repo="$(mktemp -d)"
249+
trap 'rm -rf -- "$context_repo"' EXIT
250+
git init --bare --quiet "$context_repo"
251+
if ! GIT_TERMINAL_PROMPT=0 git -C "$context_repo" fetch --quiet --no-tags --filter=blob:none \
252+
"$TRUSTED_REPOSITORY_URL" "$CONTEXT_FETCH_REF"; then
253+
echo "Failed to fetch trusted QA tooling context ${CONTEXT_REF}." >&2
254+
exit 1
255+
fi
256+
context_sha="$(git -C "$context_repo" rev-parse --verify 'FETCH_HEAD^{commit}')"
257+
normalized_context_sha="$(printf '%s' "$context_sha" | tr '[:upper:]' '[:lower:]')"
258+
normalized_target_sha="$(printf '%s' "$TARGET_REF" | tr '[:upper:]' '[:lower:]')"
259+
case "$CONTEXT_KIND" in
260+
tag)
261+
if [[ "$normalized_context_sha" != "$normalized_target_sha" ]]; then
262+
echo "Trusted QA tooling tag ${CONTEXT_REF} resolves to ${context_sha} and does not match target ${TARGET_REF}." >&2
263+
exit 1
264+
fi
265+
;;
266+
branch)
267+
if ! git -C "$context_repo" merge-base --is-ancestor "$normalized_target_sha" "$normalized_context_sha" 2>/dev/null; then
268+
echo "Target ${TARGET_REF} is not reachable from branch ${CONTEXT_REF} at ${context_sha}." >&2
269+
exit 1
270+
fi
271+
;;
272+
*)
273+
echo "Trusted QA tooling context kind is invalid: ${CONTEXT_KIND}." >&2
274+
exit 1
275+
;;
276+
esac
277+
echo "eligible=true" >> "$GITHUB_OUTPUT"
278+
205279
- name: Checkout trusted workflow helper
206280
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
207281
with:
@@ -1261,6 +1335,32 @@ jobs:
12611335
ref: ${{ needs.resolve_target.outputs.revision }}
12621336
fetch-depth: 1
12631337

1338+
- name: Checkout trusted QA Anthropic mock tooling
1339+
if: needs.resolve_target.outputs.trusted_qa_tooling_eligible == 'true'
1340+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
1341+
with:
1342+
ref: ${{ github.workflow_sha }}
1343+
path: .release-qa-tooling-trusted
1344+
fetch-depth: 1
1345+
fetch-tags: false
1346+
persist-credentials: false
1347+
sparse-checkout: extensions/qa-lab/src/providers/mock-openai/mock-anthropic-wire.ts
1348+
sparse-checkout-cone-mode: false
1349+
submodules: false
1350+
1351+
- name: Install trusted QA Anthropic mock tooling
1352+
if: needs.resolve_target.outputs.trusted_qa_tooling_eligible == 'true'
1353+
shell: bash
1354+
run: |
1355+
set -euo pipefail
1356+
trusted_checkout=.release-qa-tooling-trusted
1357+
trap 'rm -rf -- "$trusted_checkout"' EXIT
1358+
install -m 0644 \
1359+
"$trusted_checkout/extensions/qa-lab/src/providers/mock-openai/mock-anthropic-wire.ts" \
1360+
extensions/qa-lab/src/providers/mock-openai/mock-anthropic-wire.ts
1361+
rm -rf -- "$trusted_checkout"
1362+
trap - EXIT
1363+
12641364
- name: Setup Node environment
12651365
uses: ./.github/actions/setup-node-env
12661366
with:

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

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
writeFileSync,
1010
} from "node:fs";
1111
import { resolve } from "node:path";
12+
import { pathToFileURL } from "node:url";
1213
import { afterEach, describe, expect, it } from "vitest";
1314
import { parse } from "yaml";
1415
import { FULL_RELEASE_WAIT_TIMEOUT_MINUTES } from "../../scripts/full-release-validation-at-sha.mts";
@@ -324,6 +325,48 @@ function runReleaseChecksInputValidation(
324325
return { outputPath, result };
325326
}
326327

328+
function runReleaseChecksShellStep(
329+
stepName: string,
330+
env: Record<string, string>,
331+
workdir = tempDirs.make("release-checks-shell-step-"),
332+
) {
333+
const step = workflowStep(workflowJob(RELEASE_CHECKS_WORKFLOW, "resolve_target"), stepName);
334+
const outputPath = resolve(workdir, "github-output");
335+
writeFileSync(outputPath, "", "utf8");
336+
const result = spawnSync("bash", ["-c", step.run ?? ""], {
337+
cwd: workdir,
338+
encoding: "utf8",
339+
env: {
340+
...env,
341+
GITHUB_OUTPUT: outputPath,
342+
PATH: process.env.PATH,
343+
},
344+
});
345+
return { output: readFileSync(outputPath, "utf8"), result };
346+
}
347+
348+
function createReleaseChecksContextFixture() {
349+
const root = tempDirs.make("release-checks-context-repo-");
350+
const repo = resolve(root, "context-source");
351+
mkdirSync(repo);
352+
const git = (...args: string[]) =>
353+
execFileSync("git", args, { cwd: repo, encoding: "utf8" }).trim();
354+
git("init", "-q", "--initial-branch=release/2026.8.1");
355+
git("config", "user.name", "OpenClaw Test");
356+
git("config", "user.email", "[email protected]");
357+
writeFileSync(resolve(repo, "package.json"), '{"version":1}\n', "utf8");
358+
git("add", "package.json");
359+
git("commit", "-qm", "candidate");
360+
const candidateSha = git("rev-parse", "HEAD");
361+
writeFileSync(resolve(repo, "package.json"), '{"version":2}\n', "utf8");
362+
git("commit", "-qam", "branch advance");
363+
const branchHeadSha = git("rev-parse", "HEAD");
364+
git("tag", "-a", "v2026.8.1", "-m", "release", branchHeadSha);
365+
const tree = git("rev-parse", "HEAD^{tree}");
366+
const unrelatedSha = git("commit-tree", tree, "-m", "unrelated root");
367+
return { branchHeadSha, candidateSha, repoUrl: pathToFileURL(repo).href, unrelatedSha };
368+
}
369+
327370
function runFullReleaseTargetSummary(rerunGroup: string, skipTelegram: string) {
328371
const step = workflowStep(
329372
workflowJob(FULL_RELEASE_VALIDATION_WORKFLOW, "resolve_target"),
@@ -4159,6 +4202,157 @@ describe("package artifact reuse", () => {
41594202
expect(reportStep.if).toBe("steps.run_lane.outcome == 'success'");
41604203
});
41614204

4205+
it("overlays only trusted Anthropic mock tooling for frozen-target QA parity", () => {
4206+
const resolveTarget = workflowJob(RELEASE_CHECKS_WORKFLOW, "resolve_target");
4207+
const contextValidation = workflowStep(resolveTarget, "Validate trusted QA tooling context");
4208+
const eligibility = workflowStep(resolveTarget, "Validate trusted QA tooling eligibility");
4209+
const resolveStepNames = resolveTarget.steps?.map((step) => step.name) ?? [];
4210+
const job = workflowJob(RELEASE_CHECKS_WORKFLOW, "qa_lab_parity_lane_release_checks");
4211+
const trustedCheckout = workflowStep(job, "Checkout trusted QA Anthropic mock tooling");
4212+
const installTooling = workflowStep(job, "Install trusted QA Anthropic mock tooling");
4213+
const stepNames = job.steps?.map((step) => step.name) ?? [];
4214+
const targetSha = "a".repeat(40);
4215+
const eligibilityCondition =
4216+
"needs.resolve_target.outputs.trusted_qa_tooling_eligible == 'true'";
4217+
4218+
expect(resolveTarget.outputs?.trusted_qa_tooling_eligible).toBe(
4219+
"${{ steps.trusted_qa_tooling.outputs.eligible }}",
4220+
);
4221+
expect(contextValidation.if).toBe("inputs.target_context_ref != ''");
4222+
expect(
4223+
resolveTarget.steps?.find((step) => step.name === "Checkout trusted QA tooling context"),
4224+
).toBeUndefined();
4225+
expect(eligibility.if).toBe("steps.trusted_qa_context.outputs.fetch_ref != ''");
4226+
expect(resolveStepNames.indexOf("Validate trusted QA tooling context")).toBeLessThan(
4227+
resolveStepNames.indexOf("Validate trusted QA tooling eligibility"),
4228+
);
4229+
expect(eligibility.env?.TRUSTED_REPOSITORY_URL).toBe(
4230+
"https://github.com/${{ github.repository }}.git",
4231+
);
4232+
expect(eligibility.run).toContain('context_repo="$(mktemp -d)"');
4233+
expect(eligibility.run).toContain("git init --bare --quiet");
4234+
expect(eligibility.run).toContain("--filter=blob:none");
4235+
expect(eligibility.run).toContain("FETCH_HEAD^{commit}");
4236+
expect(eligibility.run).not.toContain("git checkout");
4237+
expect(eligibility.run).not.toContain("git worktree");
4238+
4239+
for (const contextRef of [
4240+
"release/2026.8.1",
4241+
"refs/heads/extended-stable/2026.8.33",
4242+
"v2026.8.1",
4243+
"refs/tags/v2026.8.1-alpha.2",
4244+
"v2026.8.1-beta.3",
4245+
]) {
4246+
const { output, result } = runReleaseChecksShellStep("Validate trusted QA tooling context", {
4247+
TARGET_CONTEXT_REF: contextRef,
4248+
TARGET_REF: targetSha,
4249+
});
4250+
expect(result.status, `${contextRef}: ${result.stderr}`).toBe(0);
4251+
expect(output, contextRef).toContain(
4252+
`normalized_ref=${contextRef.replace(/^refs\/(heads|tags)\//u, "")}\n`,
4253+
);
4254+
}
4255+
4256+
for (const contextRef of [
4257+
"main",
4258+
"release-ci/2026.8.1-frozen",
4259+
"release/2026.8",
4260+
"v2026.8.1-rc.1",
4261+
"refs/heads/refs/tags/v2026.8.1",
4262+
]) {
4263+
const { result } = runReleaseChecksShellStep("Validate trusted QA tooling context", {
4264+
TARGET_CONTEXT_REF: contextRef,
4265+
TARGET_REF: targetSha,
4266+
});
4267+
expect(result.status, contextRef).toBe(1);
4268+
expect(result.stderr).toContain(
4269+
"target_context_ref must be a canonical OpenClaw release branch or tag.",
4270+
);
4271+
}
4272+
4273+
for (const targetRef of ["release/2026.8.1", "a".repeat(39)]) {
4274+
const { result } = runReleaseChecksShellStep("Validate trusted QA tooling context", {
4275+
TARGET_CONTEXT_REF: "release/2026.8.1",
4276+
TARGET_REF: targetRef,
4277+
});
4278+
expect(result.status, targetRef).toBe(1);
4279+
expect(result.stderr).toContain(
4280+
"target_context_ref requires ref to be a full 40-character commit SHA.",
4281+
);
4282+
}
4283+
4284+
const fixture = createReleaseChecksContextFixture();
4285+
const relationshipCases = [
4286+
["tag", "refs/tags/v2026.8.1", fixture.branchHeadSha, 0, ""],
4287+
["tag", "refs/tags/v2026.8.1", fixture.candidateSha, 1, "does not match target"],
4288+
["branch", "refs/heads/release/2026.8.1", fixture.branchHeadSha, 0, ""],
4289+
["branch", "refs/heads/release/2026.8.1", fixture.candidateSha, 0, ""],
4290+
[
4291+
"branch",
4292+
"refs/heads/release/2026.8.1",
4293+
fixture.unrelatedSha,
4294+
1,
4295+
"is not reachable from branch",
4296+
],
4297+
[
4298+
"tag",
4299+
"refs/tags/v2026.8.1-beta.99",
4300+
fixture.branchHeadSha,
4301+
1,
4302+
"Failed to fetch trusted QA tooling context",
4303+
],
4304+
] as const;
4305+
for (const [contextKind, fetchRef, targetRef, expectedStatus, error] of relationshipCases) {
4306+
const { output, result } = runReleaseChecksShellStep(
4307+
"Validate trusted QA tooling eligibility",
4308+
{
4309+
CONTEXT_KIND: contextKind,
4310+
CONTEXT_FETCH_REF: fetchRef,
4311+
CONTEXT_REF: fetchRef.replace(/^refs\/(heads|tags)\//u, ""),
4312+
TARGET_REF: targetRef,
4313+
TRUSTED_REPOSITORY_URL: fixture.repoUrl,
4314+
},
4315+
);
4316+
expect(result.status, `${contextKind} ${targetRef}: ${result.stderr}`).toBe(expectedStatus);
4317+
expect(output).toBe(expectedStatus === 0 ? "eligible=true\n" : "");
4318+
if (error) {
4319+
expect(result.stderr).toContain(error);
4320+
}
4321+
}
4322+
4323+
expect(trustedCheckout).toMatchObject({
4324+
if: eligibilityCondition,
4325+
uses: "actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10",
4326+
with: {
4327+
"persist-credentials": false,
4328+
ref: "${{ github.workflow_sha }}",
4329+
path: ".release-qa-tooling-trusted",
4330+
"sparse-checkout": "extensions/qa-lab/src/providers/mock-openai/mock-anthropic-wire.ts",
4331+
"sparse-checkout-cone-mode": false,
4332+
},
4333+
});
4334+
expect(installTooling.if).toBe(eligibilityCondition);
4335+
expect(installTooling.run).toContain("trap 'rm -rf -- \"$trusted_checkout\"' EXIT");
4336+
const installLines = (installTooling.run ?? "").split("\n").map((line) => line.trim());
4337+
const sourceArgument =
4338+
'"$trusted_checkout/extensions/qa-lab/src/providers/mock-openai/mock-anthropic-wire.ts" \\';
4339+
const sourceArgumentIndex = installLines.indexOf(sourceArgument);
4340+
expect(sourceArgumentIndex).toBeGreaterThanOrEqual(0);
4341+
expect(installLines[sourceArgumentIndex + 1]).toBe(
4342+
"extensions/qa-lab/src/providers/mock-openai/mock-anthropic-wire.ts",
4343+
);
4344+
expect(installTooling.run).toContain('rm -rf -- "$trusted_checkout"');
4345+
expect(stepNames.indexOf("Checkout selected ref")).toBeLessThan(
4346+
stepNames.indexOf("Checkout trusted QA Anthropic mock tooling"),
4347+
);
4348+
expect(stepNames.indexOf("Install trusted QA Anthropic mock tooling")).toBeLessThan(
4349+
stepNames.indexOf("Setup Node environment"),
4350+
);
4351+
expect(stepNames.indexOf("Install trusted QA Anthropic mock tooling")).toBeLessThan(
4352+
stepNames.indexOf("Build private QA runtime"),
4353+
);
4354+
});
4355+
41624356
it("runs the core gateway restart pair on its pinned live model", () => {
41634357
const job = workflowJob(QA_LIVE_TRANSPORTS_WORKFLOW, "run_live_runtime_token_efficiency");
41644358
const credentialStep = workflowStep(job, "Validate required QA credential env");

0 commit comments

Comments
 (0)