Skip to content

Commit ab5b8b9

Browse files
authored
refactor(test): prove release validation through its harness (#124245)
* refactor(test): move release validation proof to harness * test(release): assert dispatch input pairs
1 parent 8668aeb commit ab5b8b9

1 file changed

Lines changed: 29 additions & 30 deletions

File tree

‎test/scripts/full-release-validation-at-sha.test.ts‎

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,6 @@ describe("full-release-validation-at-sha", () => {
199199
expect(releaseProfileForTarget("a".repeat(40), readVersion("2026.7.1-1"))).toBe("stable");
200200
});
201201

202-
it("keeps release context separate from the exact target SHA", () => {
203-
const source = readFileSync("scripts/full-release-validation-at-sha.mts", "utf8");
204-
expect(source).toContain("ref: targetBranch");
205-
expect(source).toContain("target_context_ref: targetContextRef");
206-
expect(source).toContain(
207-
'args.inputs.allow_unreleased_changelog ??= args.targetRef ? "false" : "true"',
208-
);
209-
});
210-
211202
it("rejects missing option values", () => {
212203
expect(() => parseArgs(["--sha", "--dry-run"])).toThrow("--sha requires a value");
213204
expect(() => parseArgs(["--sha", "-h"])).toThrow("--sha requires a value");
@@ -293,11 +284,10 @@ describe("full-release-validation-at-sha", () => {
293284
expect(() => releaseEvidenceVerificationArgs("")).toThrow("positive decimal");
294285
});
295286

296-
it("polls the exact workflow run without GraphQL quota use", () => {
287+
it("bounds polling for the exact workflow run", () => {
297288
const source = readFileSync("scripts/full-release-validation-at-sha.mts", "utf8");
298289
expect(FULL_RELEASE_WAIT_TIMEOUT_MINUTES).toBe(720);
299290
expect(FULL_RELEASE_WAIT_POLL_INTERVAL_MS).toBe(45_000);
300-
expect(source).toContain("actions/runs/${parentRunId}");
301291
expect(source).toContain("workflowRun.head_sha !== workflowSha");
302292
expect(source).toContain("return suite;");
303293
expect(source).toContain("Date.now() + FULL_RELEASE_WAIT_TIMEOUT_MINUTES * 60_000");
@@ -307,8 +297,6 @@ describe("full-release-validation-at-sha", () => {
307297
"Timed out after ${FULL_RELEASE_WAIT_TIMEOUT_MINUTES} minutes waiting for Full Release Validation",
308298
);
309299
expect(source).not.toContain("attempt < 480");
310-
expect(source).not.toContain('"graphql"');
311-
expect(source).not.toContain('["run", "watch"');
312300
});
313301

314302
it("bounds GitHub reads without applying a timeout to workflow dispatch", () => {
@@ -348,11 +336,6 @@ describe("full-release-validation-at-sha", () => {
348336
() => "on:\n workflow_dispatch:\n inputs: {}\n",
349337
),
350338
).toThrow(`Tooling SHA ${"b".repeat(40)} is missing workflow_dispatch input expected_sha`);
351-
352-
const source = readFileSync("scripts/full-release-validation-at-sha.mts", "utf8");
353-
expect(source.indexOf("assertTrustedWorkflowHarness(workflowSha);")).toBeLessThan(
354-
source.indexOf('run("git", ["push", "origin", `${workflowSha}:${remoteBranchRef}`]'),
355-
);
356339
});
357340

358341
it("retains a failed parent workflow ref for GitHub reruns", () => {
@@ -418,18 +401,34 @@ describe("full-release-validation-at-sha", () => {
418401
),
419402
);
420403
const dispatch = ghCalls.find((args) => args[0] === "workflow" && args[1] === "run");
421-
expect(dispatch).toEqual(
422-
expect.arrayContaining([
423-
"--ref",
424-
workflowBranch,
425-
"-f",
426-
`ref=${targetBranch}`,
427-
"-f",
428-
`expected_sha=${fixture.targetSha}`,
429-
"-f",
430-
`target_context_ref=${fixture.releaseRef}`,
431-
]),
432-
);
404+
expect(dispatch?.slice(0, 5)).toEqual([
405+
"workflow",
406+
"run",
407+
"full-release-validation.yml",
408+
"--ref",
409+
workflowBranch,
410+
]);
411+
const inputArgs = dispatch?.slice(5) ?? [];
412+
expect(inputArgs.length % 2).toBe(0);
413+
const dispatchInputs: Record<string, string> = {};
414+
for (let index = 0; index < inputArgs.length; index += 2) {
415+
expect(inputArgs[index]).toBe("-f");
416+
const assignment = inputArgs[index + 1];
417+
const separatorIndex = assignment?.indexOf("=") ?? -1;
418+
if (!assignment || separatorIndex <= 0) {
419+
throw new Error(`invalid workflow input assignment: ${String(assignment)}`);
420+
}
421+
dispatchInputs[assignment.slice(0, separatorIndex)] = assignment.slice(separatorIndex + 1);
422+
}
423+
expect(dispatchInputs).toMatchObject({
424+
ref: targetBranch,
425+
expected_sha: fixture.targetSha,
426+
target_context_ref: fixture.releaseRef,
427+
allow_unreleased_changelog: "false",
428+
});
429+
expect(ghCalls).toContainEqual(["api", "repos/openclaw/openclaw/actions/runs/123"]);
430+
expect(ghCalls.some((args) => args[0] === "graphql")).toBe(false);
431+
expect(ghCalls.some((args) => args[0] === "run" && args[1] === "watch")).toBe(false);
433432
expect(result.stdout).toContain(`Validation SHA: ${fixture.targetSha}`);
434433
expect(result.stdout).toContain(`Tooling SHA: ${fixture.workflowSha}`);
435434
expect(result.stdout).toContain(

0 commit comments

Comments
 (0)