Skip to content

Commit 6145579

Browse files
committed
fix(ci): report full release decisions sooner
1 parent ae47b34 commit 6145579

3 files changed

Lines changed: 331 additions & 36 deletions

File tree

‎docs/reference/full-release-validation.md‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,18 @@ passes the Validation SHA as both the candidate ref and `expected_sha`, and
119119
deletes the temporary ref after successful validation and strict evidence
120120
verification. The helper reads Release Decision artifacts while the parent is
121121
active so blockers can surface while Diagnostic Drain collects failures. It
122-
waits 15 minutes between run-discovery attempts and between parent polling
123-
iterations. One parent iteration may perform status, decision-artifact, and
124-
progress-job reads together; the delay limits repeated polling cycles rather
125-
than spacing every GitHub call. Run discovery makes one immediate check and one
126-
delayed retry before failing. A not-yet-created artifact remains an unavailable
127-
polling result; terminal handling and temporary-ref cleanup wait for the parent
128-
to complete with a conclusion. Failed validations retain both refs for reruns
129-
and diagnosis. The
122+
checks parent status and exact-attempt decision metadata every two minutes,
123+
with full progress-job reads no more often than every 15 minutes. Each regular
124+
iteration makes at most two metadata requests; it downloads the decision only
125+
after its named artifact appears, retrying unavailable downloads on subsequent
126+
iterations. A validated passing decision is retained only for that attempt.
127+
Parent completion also triggers a decision download when none has been validated,
128+
so metadata lag cannot skip terminal handling. Discovery makes one immediate
129+
check and at most three retries, waiting 30, 60, then 120 seconds between checks.
130+
All reads use the normal cache-aware GitHub route; cache and request latency can
131+
add to these intervals. The helper retains its 12-hour wait deadline. Successful
132+
temporary-ref cleanup still requires parent completion and strict evidence
133+
verification. Failed validations retain both refs for reruns and diagnosis. The
130134
Validation SHA equals the Code SHA for product validation or the Release SHA
131135
for changelog-only validation; it is not a third release identity. The workflow
132136
rejects malformed or mismatched expected SHAs before child dispatch. Every

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

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ const RELEASE_EVIDENCE_VERIFIER_PATHS = [
3232
];
3333
const GH_READ_TIMEOUT_MS = 60_000;
3434
export const FULL_RELEASE_WAIT_TIMEOUT_MINUTES = 720;
35-
export const FULL_RELEASE_GITHUB_POLL_INTERVAL_MS = 15 * 60_000;
36-
const FULL_RELEASE_RUN_DISCOVERY_ATTEMPTS = 2;
35+
export const FULL_RELEASE_GITHUB_POLL_INTERVAL_MS = 2 * 60_000;
36+
const FULL_RELEASE_PROGRESS_INTERVAL_MS = 15 * 60_000;
37+
const FULL_RELEASE_RUN_DISCOVERY_DELAYS_MS = [30_000, 60_000, 120_000];
3738
const RELEASE_DECISION_FILE = "full-release-decision.json";
3839
const GH_READ_OPTIONS = {
3940
encoding: "utf8",
@@ -678,12 +679,41 @@ export function tryReadReleaseDecision(
678679
}
679680
}
680681

682+
function releaseDecisionAvailable(parentRunId: string, parentRunAttempt: number) {
683+
const artifactName = `full-release-decision-${parentRunId}-${parentRunAttempt}`;
684+
try {
685+
const response: unknown = JSON.parse(
686+
execGhRead(
687+
[
688+
"api",
689+
`repos/openclaw/openclaw/actions/runs/${parentRunId}/artifacts?per_page=100&name=${artifactName}`,
690+
],
691+
{ ...GH_READ_OPTIONS, stdio: ["ignore", "pipe", "pipe"] },
692+
),
693+
);
694+
if (!isJsonRecord(response) || !Array.isArray(response.artifacts)) {
695+
throw new Error(`Full Release Validation run ${parentRunId} returned invalid artifacts`);
696+
}
697+
return response.artifacts.some(
698+
(artifact) =>
699+
isJsonRecord(artifact) && artifact.name === artifactName && artifact.expired === false,
700+
);
701+
} catch (error) {
702+
if (classifyReleaseGhTransportError(error) !== "transient") {
703+
throw error;
704+
}
705+
console.warn(`Release Decision metadata unavailable this poll; retrying: ${String(error)}`);
706+
return false;
707+
}
708+
}
709+
681710
function waitForWorkflowRun(parentRunId: string, workflowSha: string) {
682711
let lastSummary = "";
683712
let consecutiveErrors = 0;
684713
const startedAt = Date.now();
685714
const deadline = startedAt + FULL_RELEASE_WAIT_TIMEOUT_MINUTES * 60_000;
686-
let nextProgressAt = startedAt + FULL_RELEASE_GITHUB_POLL_INTERVAL_MS;
715+
let nextProgressAt = startedAt + FULL_RELEASE_PROGRESS_INTERVAL_MS;
716+
let decision: { attempt: number; state: "unavailable" | "ready" | "passed" } | undefined;
687717
while (Date.now() < deadline) {
688718
let suite: Record<string, unknown> | undefined;
689719
try {
@@ -706,15 +736,30 @@ function waitForWorkflowRun(parentRunId: string, workflowSha: string) {
706736
lastSummary = summary;
707737
}
708738
if (suite) {
709-
const releaseDecision = tryReadReleaseDecision(
710-
parentRunId,
711-
requiredPositiveInteger(suite.run_attempt, "parent run attempt"),
712-
workflowSha,
713-
);
714-
if (releaseDecision && releaseDecisionStopsForeground(releaseDecision.state)) {
715-
throw new Error(
716-
`${formatReleaseStateOutcome(releaseDecision)}\nhttps://github.com/openclaw/openclaw/actions/runs/${parentRunId}`,
717-
);
739+
const attempt = requiredPositiveInteger(suite.run_attempt, "parent run attempt");
740+
if (decision?.attempt !== attempt) {
741+
decision = { attempt, state: "unavailable" };
742+
}
743+
// Metadata is only a readiness hint. Once advertised, keep trying the
744+
// authoritative download across status regressions until this attempt validates.
745+
if (
746+
decision.state === "unavailable" &&
747+
(suite.status === "completed" || releaseDecisionAvailable(parentRunId, attempt))
748+
) {
749+
decision.state = "ready";
750+
}
751+
if (decision.state === "ready") {
752+
const releaseDecision = tryReadReleaseDecision(parentRunId, attempt, workflowSha);
753+
if (releaseDecision && releaseDecisionStopsForeground(releaseDecision.state)) {
754+
throw new Error(
755+
`${formatReleaseStateOutcome(releaseDecision)}\nhttps://github.com/openclaw/openclaw/actions/runs/${parentRunId}`,
756+
);
757+
}
758+
// The workflow uploads one immutable decision per attempt; final success
759+
// still requires the parent's terminal conclusion and strict evidence verifier.
760+
if (releaseDecision?.state === "passed") {
761+
decision.state = "passed";
762+
}
718763
}
719764
}
720765
if (suite?.status === "completed" && stringValue(suite.conclusion)) {
@@ -741,7 +786,7 @@ function waitForWorkflowRun(parentRunId: string, workflowSha: string) {
741786
`Parent run progress query failed: ${error instanceof Error ? error.message : String(error)}`,
742787
);
743788
}
744-
nextProgressAt += FULL_RELEASE_GITHUB_POLL_INTERVAL_MS;
789+
nextProgressAt = now + FULL_RELEASE_PROGRESS_INTERVAL_MS;
745790
}
746791
const remainingMs = deadline - Date.now();
747792
if (remainingMs <= 0) {
@@ -980,17 +1025,17 @@ function main() {
9801025
}
9811026
parentRunId = collectRunId(dispatchOutput);
9821027
if (!parentRunId && !args.dryRun) {
983-
for (let attempt = 0; attempt < FULL_RELEASE_RUN_DISCOVERY_ATTEMPTS; attempt += 1) {
1028+
for (let attempt = 0; attempt <= FULL_RELEASE_RUN_DISCOVERY_DELAYS_MS.length; attempt += 1) {
9841029
parentRunId = findLatestRunId(branch, workflowSha);
9851030
if (parentRunId) {
9861031
break;
9871032
}
988-
if (attempt + 1 < FULL_RELEASE_RUN_DISCOVERY_ATTEMPTS) {
1033+
if (attempt < FULL_RELEASE_RUN_DISCOVERY_DELAYS_MS.length) {
9891034
Atomics.wait(
9901035
new Int32Array(new SharedArrayBuffer(4)),
9911036
0,
9921037
0,
993-
FULL_RELEASE_GITHUB_POLL_INTERVAL_MS,
1038+
FULL_RELEASE_RUN_DISCOVERY_DELAYS_MS[attempt],
9941039
);
9951040
}
9961041
}

0 commit comments

Comments
 (0)