Skip to content

Commit 8785601

Browse files
committed
fix(release): retain workflow ref after failed validation
1 parent 6a11e44 commit 8785601

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

‎scripts/full-release-validation-at-sha.d.mts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export function releaseProfileForTarget(
1818
readPackageJson?: (sha: string) => string,
1919
): "beta" | "stable";
2020
export function releaseEvidenceVerificationArgs(parentRunId: unknown): string[];
21+
export function shouldDeleteTemporaryWorkflowRef(params: {
22+
keepBranch: boolean;
23+
dryRun: boolean;
24+
parentConclusion: string;
25+
}): boolean;
2126
export function releaseEvidenceVerifierPath(worktreeRoot: unknown): string;
2227
export function resolveRemoteTargetRefSha(
2328
targetRef: string,

‎scripts/full-release-validation-at-sha.mjs‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ export function releaseEvidenceVerificationArgs(parentRunId) {
319319
return ["--validate-run", String(parentRunId), "--trusted-workflow-ref", "main", "--json"];
320320
}
321321

322+
export function shouldDeleteTemporaryWorkflowRef(params) {
323+
return !params.keepBranch && (params.dryRun || params.parentConclusion === "success");
324+
}
325+
322326
export function releaseEvidenceVerifierPath(worktreeRoot) {
323327
const candidates = [
324328
join(worktreeRoot, "scripts", "release-ci-summary.mjs"),
@@ -388,6 +392,7 @@ function main() {
388392
});
389393

390394
let parentRunId;
395+
let parentConclusion = "";
391396
try {
392397
const dispatchArgs = ["workflow", "run", WORKFLOW, "--ref", branch];
393398
for (const [key, value] of Object.entries(dispatchInputs)) {
@@ -416,16 +421,32 @@ function main() {
416421
}
417422

418423
console.log(`Parent run: https://github.com/openclaw/openclaw/actions/runs/${parentRunId}`);
419-
waitForWorkflowRun(parentRunId, workflowSha);
424+
const completedRun = waitForWorkflowRun(parentRunId, workflowSha);
425+
parentConclusion = String(completedRun.conclusion ?? "");
426+
if (parentConclusion !== "success") {
427+
throw new Error(
428+
`Full Release Validation concluded ${parentConclusion.toLowerCase() || "without a conclusion"}: https://github.com/openclaw/openclaw/actions/runs/${parentRunId}`,
429+
);
430+
}
420431
verifyReleaseEvidence(parentRunId, workflowSha);
421432
} finally {
422-
if (!args.keepBranch) {
433+
if (
434+
shouldDeleteTemporaryWorkflowRef({
435+
keepBranch: args.keepBranch,
436+
dryRun: args.dryRun,
437+
parentConclusion,
438+
})
439+
) {
423440
run("git", ["push", "origin", `:${remoteBranchRef}`], {
424441
dryRun: args.dryRun,
425442
stdio: "inherit",
426443
});
427444
} else {
428-
console.log(`Kept ${remoteBranchRef}`);
445+
console.warn(
446+
args.keepBranch
447+
? `Kept ${remoteBranchRef}`
448+
: `Kept ${remoteBranchRef}: parent concluded ${parentConclusion || "without a conclusion"}. Keep it through any GitHub reruns; delete it after a successful parent attempt.`,
449+
);
429450
}
430451
}
431452
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
releaseEvidenceVerificationArgs,
99
releaseEvidenceVerifierPath,
1010
resolveRemoteTargetRefSha,
11+
shouldDeleteTemporaryWorkflowRef,
1112
} from "../../scripts/full-release-validation-at-sha.mjs";
1213

1314
describe("full-release-validation-at-sha", () => {
@@ -155,6 +156,30 @@ describe("full-release-validation-at-sha", () => {
155156
expect(source).not.toContain('["run", "watch"');
156157
});
157158

159+
it("retains a failed parent workflow ref for GitHub reruns", () => {
160+
expect(
161+
shouldDeleteTemporaryWorkflowRef({
162+
dryRun: false,
163+
keepBranch: false,
164+
parentConclusion: "failure",
165+
}),
166+
).toBe(false);
167+
expect(
168+
shouldDeleteTemporaryWorkflowRef({
169+
dryRun: false,
170+
keepBranch: false,
171+
parentConclusion: "success",
172+
}),
173+
).toBe(true);
174+
expect(
175+
shouldDeleteTemporaryWorkflowRef({
176+
dryRun: true,
177+
keepBranch: false,
178+
parentConclusion: "",
179+
}),
180+
).toBe(true);
181+
});
182+
158183
it("supports current and legacy verifier locations in trusted workflow checkouts", () => {
159184
const root = mkdtempSync(join(tmpdir(), "openclaw-release-verifier-path-"));
160185
try {

0 commit comments

Comments
 (0)