Repository navigation
[CI] Stop expensive checks when an unmerged PR closes - #25829
Merged
Merged
Conversation
nwparker
marked this pull request as ready for review
October 6, 2026 08:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Closing a PR without merging should stop its expensive checks. Today, checks can keep using runners after the work has been abandoned.
What Changed
Extend the existing trusted closed-PR cleanup workflow to request cancellation of active PR Checks, headless Node, Windows SSH, hostile-host SSH, mobile and computer E2E runs. Identify runs through GitHub's exact PR concurrency groups, then verify the workflow, event and creation time before cancelling. Recheck that the same unmerged closure is still current before every cancellation.
Cache cleanup still runs after a cancellation error. There is no PR checkout in this privileged workflow. Merged, reopened, unrelated, manual and release runs are retained. Test assignments, worker counts and platform coverage stay as they are.
Why
In the October 5–6 demand sample, unmerged PR #25726 closed at 00:36:40 UTC, but its headless run consumed another 2,203 runner-seconds (36.7 minutes) after closure. An additional historical Windows serve run used 170 seconds, but that removed workflow is outside this patch's scope. This is an observed waste example, not a daily savings estimate.
GitHub clears the closed PR association from some run/check-suite responses. Exact concurrency groups provide positive PR identity without guessing from branch names or commit IDs. Reusing the current no-checkout cleanup workflow avoids adding a runner job to every CI workflow. Only six high-cost workflows are queried, with inactive groups treated as normal.
Linked Issue
Maintainer CI efficiency follow-up; no new issue needed.
Visual Proof
N/A — GitHub Actions cleanup only; no application UI changes.
Testing
37431125293at 07:44:27 UTC; GitHub reports completed/cancelled at 07:44:28. The qualification job occupied eight runner-seconds. This proves queued-run cancellation with the actual token, group API and PR identity; it does not measure active-run cancellation latency or daily savings.src/shared/protocol-version.tsmax-lines violation (301 code lines), before unit fan-out. GitHub reports no required branch checks; merging uses normal repository policy, without an administrator override. The temporary qualification workflow is absent from this review diff.Review
Review the exact group/workflow allowlist and the current-closure check before mutation. The existing Actions write permission is retained; Pull requests read is added for that check. Cancellation uses the normal API, preserving runner cleanup. API failures remain visible and cache cleanup still proceeds.
Agent skill upstream boundary
Notes
All six skill areas were audited against current workflow code, documented validation commitments and the October 5–6 demand report (415 sampled runs out of 6,810):
The report estimates 696.5 daily runner-hours for PR Checks, 92.8 for Windows SSH and 87.2 for headless Node. These are sampled full-run durations, not billing totals. Closing obsolete work frees capacity; it does not establish lower whole-PR percentiles.
Checklist