Skip to content

Commit c98bd22

Browse files
authored
ci(release): retry child-run adoption through read-after-write lag (#120477)
1 parent 267268f commit c98bd22

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎.github/workflows/full-release-validation.yml‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -486,19 +486,23 @@ jobs:
486486
echo "::error::Refusing to adopt invalid ${workflow} run ID ${candidate_run_id}." >&2
487487
return 1
488488
fi
489-
# GitHub evaluates run-name asynchronously: a run adopted from the dispatch
490-
# response can briefly report its default display_title. Identity fields are
491-
# immediate-refuse; a lone title mismatch retries until the template lands.
489+
# GitHub materializes a dispatched run asynchronously: the API can 404 the
490+
# fresh run id (read-after-write lag) and can briefly report the default
491+
# display_title before run-name evaluates. Both are retryable; a REAL run
492+
# object with mismatched identity fields still refuses immediately.
492493
for attempt in $(seq 1 12); do
493-
candidate_run_json="$(
494+
if ! candidate_run_json="$(
494495
gh_with_retry api "repos/${GITHUB_REPOSITORY}/actions/runs/${candidate_run_id}"
495-
)"
496+
)" || ! jq -e --argjson id "$candidate_run_id" '.id == $id' \
497+
<<< "$candidate_run_json" >/dev/null 2>&1; then
498+
echo "Waiting for ${workflow} run ${candidate_run_id} to become readable (attempt ${attempt})." >&2
499+
sleep 5
500+
continue
501+
fi
496502
if ! jq -e \
497-
--argjson id "$candidate_run_id" \
498503
--argjson workflow_id "$expected_workflow_id" \
499504
--arg branch "$CHILD_WORKFLOW_REF" \
500-
'(.id == $id)
501-
and (.workflow_id == $workflow_id)
505+
'(.workflow_id == $workflow_id)
502506
and (.head_branch == $branch)
503507
and (.event == "workflow_dispatch")' \
504508
<<< "$candidate_run_json" >/dev/null; then
@@ -515,9 +519,9 @@ jobs:
515519
echo "Waiting for ${workflow} run ${candidate_run_id} display title (attempt ${attempt})." >&2
516520
sleep 5
517521
done
518-
echo "::error::Refusing to adopt ${workflow} run ${candidate_run_id}: display title never matched ${dispatch_run_name}." >&2
522+
echo "::error::Refusing to adopt ${workflow} run ${candidate_run_id}: run never became readable with display title ${dispatch_run_name}." >&2
519523
jq '{id, workflow_id, path, display_title, head_branch, head_sha, event, html_url}' \
520-
<<< "$candidate_run_json" >&2
524+
<<< "$candidate_run_json" >&2 || printf '%s\n' "$candidate_run_json" >&2
521525
return 1
522526
}
523527

‎test/scripts/package-acceptance-workflow.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ describe("package acceptance workflow", () => {
19781978
expect(result.status).toBe(1);
19791979
expect(result.stderr).toContain(
19801980
label === "title"
1981-
? "Refusing to adopt ci.yml run 101: display title never matched"
1981+
? "Refusing to adopt ci.yml run 101: run never became readable with display title"
19821982
: "Refusing to adopt unvalidated ci.yml run 101",
19831983
);
19841984
expect(

0 commit comments

Comments
 (0)