Skip to content

Commit e28d822

Browse files
authored
fix(ci): let push-checks wait out a lagging validation run listing (#10651)
push-checks looks up the commit's validation run through GitHub's filtered run listing and gave up after two minutes. That listing can lag a push by minutes, and it can briefly return a page that disagrees with its own total_count; the gate treated the second case as a hard error. On 2026-11-25 that failed one staging push whose validation was fine, and during the 2026-12-02 Actions incident every staging push failed this way. An inconsistent listing now counts as "not listed yet" and is polled again, and the gate waits up to ten minutes for the run to appear, polling every ten seconds (at most 60 requests against the shared GITHUB_TOKEN budget). What it admits is unchanged: the same provenance check on the listing and on the terminal run, a complete listing required, and two matching runs still refused at once.
1 parent 8f8fef5 commit e28d822

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

‎.github/scripts/wait-for-push-checks.sh‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ query() {
2626
--arg sha "$GITHUB_SHA" --argjson repo_id "$GITHUB_REPOSITORY_ID" "$@"
2727
}
2828

29+
# GitHub's filtered run listing can lag a push by minutes, and can briefly return a page that
30+
# disagrees with its own count: both mean "not listed yet", so poll again rather than fail.
2931
run_id=''
30-
deadline=$((SECONDS + 120))
32+
deadline=$((SECONDS + 600))
3133
while [ "$SECONDS" -lt "$deadline" ]; do
3234
response=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs" --method GET \
3335
-f event=push -f branch="$GITHUB_REF_NAME" -f head_sha="$GITHUB_SHA" -F per_page=100)
3436
selection=$(query "$provenance
3537
if (.workflow_runs | type) != \"array\" or .total_count != (.workflow_runs | length)
36-
then error(\"Incomplete validation run listing\") else .workflow_runs end
38+
then empty else .workflow_runs end
3739
| map(select(trusted))
3840
| if length > 1 then error(\"Ambiguous matching push validations\")
3941
elif length == 1 then .[0] | [.id, .workflow_id] | @tsv
@@ -42,7 +44,7 @@ while [ "$SECONDS" -lt "$deadline" ]; do
4244
IFS=$'\t' read -r run_id workflow_id <<< "$selection"
4345
break
4446
fi
45-
sleep 2
47+
sleep 10
4648
done
4749

4850
if [ -z "$run_id" ]; then

‎scripts/wait-for-push-checks.test.ts‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ function runGate(options: GateOptions = {}) {
4949
repos/example/project/actions/runs)
5050
if [ "$LIST_STATUS" -ne 0 ]; then return "$LIST_STATUS"; fi
5151
if [ "$poll" -eq 0 ]; then printf '%s\\n' "$FIRST_LIST";
52-
else printf '%s\\n' "$NEXT_LIST"; fi
52+
elif [ "$poll" -eq 1 ]; then printf '%s\\n' "$NEXT_LIST";
53+
else printf '%s\\n' "$LATER_LIST"; fi
5354
;;
5455
repos/example/project/actions/runs/101)
5556
if [ "$TERMINAL_STATUS" -ne 0 ]; then return "$TERMINAL_STATUS"; fi
@@ -76,6 +77,7 @@ function runGate(options: GateOptions = {}) {
7677
GITHUB_SHA: sha,
7778
FIRST_LIST: fixtures[0],
7879
NEXT_LIST: fixtures[1] ?? fixtures[0],
80+
LATER_LIST: fixtures[2] ?? fixtures[1] ?? fixtures[0],
7981
TERMINAL_RESPONSE: JSON.stringify(options.terminal ?? validation()),
8082
LIST_STATUS: String(options.listStatus ?? 0),
8183
TERMINAL_STATUS: String(options.terminalStatus ?? 0),
@@ -126,6 +128,27 @@ describe('independent push-validation admission', () => {
126128
expect(result.stdout).toContain('WATCH 101')
127129
})
128130

131+
it('keeps waiting past two minutes for a run GitHub lists late', () => {
132+
const none = { total_count: 0, workflow_runs: [] }
133+
const result = runGate({
134+
listings: [none, none, { total_count: 1, workflow_runs: [validation()] }],
135+
})
136+
expect(result.status, result.stderr).toBe(0)
137+
expect(result.stdout).toContain('WATCH 101')
138+
})
139+
140+
it.each([
141+
['a truncated listing', { total_count: 2, workflow_runs: [validation()] }],
142+
['a missing count', { workflow_runs: [validation()] }],
143+
['malformed runs', { total_count: 1, workflow_runs: null }],
144+
])('polls again past %s and admits from the next complete one', (_name, listing) => {
145+
const result = runGate({
146+
listings: [listing, { total_count: 1, workflow_runs: [validation()] }],
147+
})
148+
expect(result.status, result.stderr).toBe(0)
149+
expect(result.stdout).toContain('WATCH 101')
150+
})
151+
129152
it('selects the validation among unrelated runs for the same commit', () => {
130153
const result = runGate({
131154
listings: [

0 commit comments

Comments
 (0)