Skip to content

Commit f418f61

Browse files
committed
fix(release): ignore unselected historical validation children
1 parent b9e0fcb commit f418f61

2 files changed

Lines changed: 94 additions & 3 deletions

File tree

‎scripts/validate-authorized-beta-focused-evidence.mts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,18 @@ function requireHistoricalExecutionPlan(policy: AuthorizedBetaFocusedPolicy) {
350350
fail("historical execution plan children must be an array");
351351
}
352352
const childRuns = new Map(
353-
plan.children.map((entry: unknown) => {
353+
plan.children.flatMap((entry: unknown) => {
354354
if (!isRecord(entry)) {
355355
fail("historical execution plan child must be an object");
356356
}
357+
if (entry.selected !== true) {
358+
return [];
359+
}
357360
return [
358-
exactString(entry.key, "historical execution plan child key"),
359-
exactJsonId(entry.runId, "historical execution plan child run id"),
361+
[
362+
exactString(entry.key, "historical execution plan child key"),
363+
exactJsonId(entry.runId, "historical execution plan child run id"),
364+
],
360365
];
361366
}),
362367
);

‎test/scripts/authorized-beta-focused-evidence.test.ts‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,92 @@ describe("authorized beta focused evidence", () => {
434434
});
435435
});
436436

437+
it("accepts skipped historical release-plan children without run identities", () => {
438+
const { policy, root } = fixturePolicy();
439+
const trustedRoot = tempDirs.make("authorized-beta-focused-historical-plan-");
440+
const validatorPath = stageValidatorClosure(trustedRoot, false);
441+
writeFileSync(join(trustedRoot, "authorized-beta-focused-policy.json"), JSON.stringify(policy));
442+
443+
const producerSha = "a".repeat(40);
444+
const producerRef = "release-publish/aaaaaaaaaaaa-1";
445+
const historical = policy.historicalFrv;
446+
const plan = {
447+
parentRunId: historical.runId,
448+
parentRunAttempt: historical.runAttempt,
449+
workflowRef: historical.workflowRef,
450+
workflowSha: policy.historicalToolingSha,
451+
targetSha: historical.targetSha,
452+
releaseProfile: "beta",
453+
rerunGroup: "all",
454+
children: [
455+
{ key: "normalCi", selected: true, runId: historical.ciRunId },
456+
{ key: "pluginPrerelease", selected: true, runId: historical.pluginRunId },
457+
{ key: "releaseChecks", selected: true, runId: historical.releaseChecksRunId },
458+
{ key: "npmTelegram", selected: false, runId: "" },
459+
{ key: "productPerformance", selected: true, runId: historical.performanceRunId },
460+
],
461+
};
462+
const producerRun = {
463+
id: 123,
464+
run_attempt: 1,
465+
name: "Authorized Beta Focused Validation",
466+
path: ".github/workflows/authorized-beta-focused-validation.yml",
467+
event: "workflow_dispatch",
468+
status: "completed",
469+
conclusion: "success",
470+
head_branch: producerRef,
471+
head_sha: producerSha,
472+
};
473+
writeFileSync(
474+
join(trustedRoot, "gh"),
475+
[
476+
"#!/usr/bin/env node",
477+
'import { writeFileSync } from "node:fs";',
478+
'import { join } from "node:path";',
479+
"const [command, route, ...args] = process.argv.slice(2);",
480+
'if (command === "api" && route.endsWith("/actions/runs/123")) {',
481+
` process.stdout.write(JSON.stringify(${JSON.stringify(producerRun)}));`,
482+
'} else if (command === "api" && route.includes("/git/ref/tags/")) {',
483+
` process.stdout.write(JSON.stringify({ object: { type: "commit", sha: ${JSON.stringify(producerSha)} } }));`,
484+
'} else if (command === "run" && route === "download") {',
485+
' const directory = args[args.indexOf("--dir") + 1];',
486+
` writeFileSync(join(directory, "full-release-execution-plan.json"), JSON.stringify(${JSON.stringify(plan)}));`,
487+
"} else {",
488+
' console.error("historical execution plan child identities accepted");',
489+
" process.exitCode = 1;",
490+
"}",
491+
].join("\n"),
492+
{ mode: 0o755 },
493+
);
494+
495+
const result = spawnSync(
496+
process.execPath,
497+
[
498+
validatorPath,
499+
"verify",
500+
"--candidate-root",
501+
root,
502+
"--artifact",
503+
join(trustedRoot, "unused-evidence.json"),
504+
"--producer-run-id",
505+
"123",
506+
"--producer-run-attempt",
507+
"1",
508+
"--producer-workflow-full-ref",
509+
`refs/tags/${producerRef}`,
510+
"--producer-workflow-sha",
511+
producerSha,
512+
],
513+
{
514+
encoding: "utf8",
515+
env: { ...process.env, PATH: `${trustedRoot}:${process.env.PATH ?? ""}` },
516+
},
517+
);
518+
expect(result.status).toBe(1);
519+
expect(result.stderr).toContain("historical execution plan child identities accepted");
520+
expect(result.stderr).not.toContain("historical execution plan child run id");
521+
});
522+
437523
it("binds the direct-child tree, exact diff, and unchanged published projection", () => {
438524
const { policy, root } = fixturePolicy();
439525
const changedPath = policy.changedPaths[0];

0 commit comments

Comments
 (0)