|
9 | 9 | writeFileSync, |
10 | 10 | } from "node:fs"; |
11 | 11 | import { resolve } from "node:path"; |
| 12 | +import { pathToFileURL } from "node:url"; |
12 | 13 | import { afterEach, describe, expect, it } from "vitest"; |
13 | 14 | import { parse } from "yaml"; |
14 | 15 | import { FULL_RELEASE_WAIT_TIMEOUT_MINUTES } from "../../scripts/full-release-validation-at-sha.mts"; |
@@ -324,6 +325,48 @@ function runReleaseChecksInputValidation( |
324 | 325 | return { outputPath, result }; |
325 | 326 | } |
326 | 327 |
|
| 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 | + |
327 | 370 | function runFullReleaseTargetSummary(rerunGroup: string, skipTelegram: string) { |
328 | 371 | const step = workflowStep( |
329 | 372 | workflowJob(FULL_RELEASE_VALIDATION_WORKFLOW, "resolve_target"), |
@@ -4159,6 +4202,157 @@ describe("package artifact reuse", () => { |
4159 | 4202 | expect(reportStep.if).toBe("steps.run_lane.outcome == 'success'"); |
4160 | 4203 | }); |
4161 | 4204 |
|
| 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 | + |
4162 | 4356 | it("runs the core gateway restart pair on its pinned live model", () => { |
4163 | 4357 | const job = workflowJob(QA_LIVE_TRANSPORTS_WORKFLOW, "run_live_runtime_token_efficiency"); |
4164 | 4358 | const credentialStep = workflowStep(job, "Validate required QA credential env"); |
|
0 commit comments