ci: cancel unfinished PR runs when the PR closes#1755
Open
guapisolo wants to merge 1 commit into
Open
Conversation
Merging or closing a PR does not stop its in-flight CI: GitHub only cancels a run when a new run enters the same concurrency group, and closed is not a pr-test.yml trigger. A run started just before merge (e.g. #1584's run 29863936642) keeps occupying self-hosted GPU runners to completion, delaying every queued PR behind it. Port sgl-project/sglang's cancel-pr-workflows-on-close.yml: on pull_request_target closed (merged or not), list every unfinished run on the PR's head branch repo-wide, filter by head repo id, and cancel each one, with a force-cancel fallback and a second pass for runs still materializing. Document the cancellation model in docs/ci/03-cancellation.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Summary
Cancel every unfinished CI run on a PR's head branch the moment the PR closes, merged or not.
Motivation
Merging or closing a PR does not stop its in-flight CI: GitHub cancels a run only when a new run enters the same concurrency group, and
closedis not apr-test.ymltrigger. A run started just before merge keeps occupying self-hosted GPU runners to completion — run 29863936642 kept running the full GPU fleet for PR #1584 after it was already merged, delaying every queued PR behind it.Design
Port
cancel-pr-workflows-on-close.ymlfrom sgl-project/sglang, which solved the same problem on the same runner-scarcity grounds:pull_request_target: closedso the job holdsactions: writeeven for fork PRs; the job never checks out PR code.queued,in_progress,waiting,pending,requested,action_required), retry listing up to 3 times, force-cancel runs stuck behind approval rules, and run a second pass 20 s later for runs still materializing.docs/ci/03-cancellation.md(bound via the workflow'sdoc-devsentinel) documents the full cancellation model: per-PR supersede inpr-test.ymlplus this on-close sweep.Verification
pre-commit run(check-yaml) passes on both files.main): push a trivial PR, wait forPR Testto start its GPU stages, merge, then confirm within ~1 min that the leftover run flips tocancelledand a greenCancel PR Workflows on Closerun appears for the PR.Review Focus
pull_request_targettrigger and theactions: write-only permission block.🤖 Generated with Claude Code