Repository navigation
[CI] check_signal: wait for a located run instead of giving up on it - #8339
Conversation
One retry budget covered two different situations: not having found the Checks run yet, and having found it while it is still going. Five attempts thirty seconds apart is a reasonable budget for the first and no budget at all for the second -- on a busy day the queue alone holds a run past 2.5 minutes, and the script then reports "Failed to read pre-checks status" and exits 1, taking the gate red on a pre-check that goes on to pass. Seen on #8291: run 44609631130 was located on attempt 2 and was still in_progress through attempt 5; its conclusion was success. Every workflow that gates on this script -- eight of them -- fails the same way whenever the queue is deep. So the two are budgeted apart. MAX_RETRIES still bounds locating the run, because a missing run usually means the event never started one. Once located, the script polls until the run completes, bounded by MAX_WAIT_SECONDS (45 minutes) so a genuinely stuck run still ends the job rather than holding a runner forever. Exercised against a stubbed `gh` on all four paths: slow-then-success (exit 0, where the current script exits 1), pre-checks failed (78), never located (1), and still running at the deadline (1). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
check-signalgoes red on a pre-check that passes, whenever the queue is deep. It gates eight workflows, andAiter Test Gateis one of them.What happens
.github/scripts/check_signal.shspends one budget --MAX_RETRIES=5, thirty seconds apart -- on two different situations:queued/in_progress.Five attempts is a reasonable budget for the first. For the second it is not a budget at all: it says the pre-check has 2.5 minutes to finish, and when it does not, the script prints
Failed to read pre-checks status after 5 attemptsand exits 1.Observed on #8291 (run
44609631181), with ~190 runs queued on the repo at the time:Run
44609631130finishedcompleted / success. The run it was waiting for was fine; only the waiting was too short. Re-running the job alone turned it green.The change
Budget the two apart.
MAX_RETRIESkeeps bounding the lookup: a run that cannot be found usually means the event never started one, and that should not take long to conclude.MAX_WAIT_SECONDS(default 2700). A genuinely stuck run still ends the job rather than holding a runner forever, and the message says which case it was.Exit codes are unchanged: 0 on success, 78 on a pre-check that did not pass, 1 when the run cannot be located or is still running at the deadline.
Verified
Against a stubbed
gh, all four paths:🤖 Generated with Claude Code
PR Self-Review
Reviewed revision
0097c0ba67Behavior and intent
.github/scripts/check_signal.shspends a single retry budget -- five attempts, thirty seconds apart -- on two situations that are not alike: the Checks run has not been found yet, and the run has been found and is stillqueued/in_progress. For the first that is a reasonable budget. For the second it is not a budget at all: it gives the pre-check 2.5 minutes to finish, and when it does not, the script exits 1 and takes the gate red on a pre-check that goes on to pass.The existing behaviour is insufficient because the failure is a function of queue depth, not of anything the PR did. Observed on #8291 (run
44609631181) with ~190 runs queued on the repo: run44609631130was located on attempt 2, wasin_progressthrough attempt 5, and the script gave up -- that run finishedcompleted / success. Re-running the job alone turned it green. Eight workflows gate on this script andAiter Test Gateis one of them, so every PR is exposed whenever the repo is busy.This budgets the two apart.
MAX_RETRIESstill bounds locating the run, because a run that cannot be found usually means the event never started one. Once located, the script polls until the run completes, bounded byMAX_WAIT_SECONDS(default 2700) so a genuinely stuck run still ends the job rather than holding a runner indefinitely. Exit codes are unchanged: 0 on success, 78 on a pre-check that did not pass, 1 on "cannot locate" or "still running at the deadline".Validation and unverified scope
Exercised against a stubbed
ghon this machine, withMAX_RETRIES=3 RETRY_INTERVAL_SECONDS=0, running both the currentorigin/mainscript and this one over the same stub:origin/maincompleted/successfailureMAX_WAIT_SECONDSelapsesbash -nclean.Unverified: the real-CI path. The stub replaces
gh run listandgh api .../actions/runs/<id>, so what is proven is the script's control flow and exit codes, not the shape of the live API responses. Those two call sites are unchanged from the current script, which is the argument for the stub being representative rather than merely convenient. What would close it is one real run while the repo is busy -- which is the condition that cannot be arranged on demand.PR-specific question
What permissions and untrusted-input boundary does this CI change have, and can fork PR code or text reach a privileged execution path?
No new permissions and no new boundary. The script keeps running in the same job, with the same
GITHUB_TOKENthe step already passed it, and makes the same two read-only API calls as before (gh run listfor the workflow,gh api repos/.../actions/runs/<id>for status). It writes nothing and still executes nothing from the repository under test.Nothing from a fork PR gains a path here. The values the script interpolates are workflow-provided --
GITHUB_REPOSITORY,GITHUB_SHA,GITHUB_HEAD_REF, and the event payload's head SHA -- and are used exactly as before, asgharguments and in a--jqstring comparison; no new interpolation site is added. The two new quantities,MAX_WAIT_SECONDSand the loop counter, are numeric and come from the workflow environment, not from PR content. The only behavioural difference a fork PR can produce is that the job waits longer before concluding.Changed op tests
None.