ci(build_fork.yml): supersede fork CI runs by PR head sha instead of arrival order - #43955
Open
bryangingechen wants to merge 2 commits into
Open
bryangingechen wants to merge 2 commits into
bryangingechen wants to merge 2 commits into
Conversation
`build_fork.yml`'s `guard` skips the build for a superseded commit, and a run whose only executed job succeeded still concludes `success` — which `decls-diff.yml` read as evidence that an `import-graph` artifact existed to diff. Check for the artifact instead, in a cheap job ahead of the full-history checkout. Also on the guard itself: build rather than skip CI when `guard` fails, so the job boundary fails open the way the step already does; cap `guard` at five minutes; and stop passing `concurrency_group`, which would otherwise log a group that no longer exists. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
PR summary 669cd1679aImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
bryangingechen
marked this pull request as ready for review
September 19, 2026 02:31
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.
This PR addresses a race condition reported at #mathlib4 > [pre-commit.ci lite] cancelling CI. We replace
build_fork.yml'sconcurrencyblock with aguardjob that picks the surviving fork run by comparing against the PR's live head sha, rather than by the order GitHub created the runs in.Details of the race
When two pushes to a PR occur in quick succession, sometimes the CI for the HEAD commit is triggered before CI for the previous commit starts, causing `cancel-in-progress` to cancel CI for the HEAD commit, causing the CI to get stuck until a manual re-trigger or another push. Example: on #43646, the run for commit `d046ac32` (committed 22:42:59) was created at 22:43:03 and [cancelled](https://github.com/leanprover-community/mathlib4/actions/runs/34538806707) one second later by the run for `a201b6db` (committed 22:41:49), which then [reported the PR's status](https://github.com/leanprover-community/mathlib4/actions/runs/34538807811) for a 70-second-stale commit.The new guard job skips the build when its sha is no longer the PR head, and otherwise cancels the branch's other in-flight runs. The guard fails open: an API error or a failure of
guarditself builds anyway so a mistake costs a duplicate build rather than a PR with no CI. Never dispatching stale builds saves roughly what superseded runs now cost by living ~30s longer, so this should be roughly neutral with respect to runner usage.Two companion changes:
success, anddecls-diff.ymlreadsuccessas "there is animport-graphartifact to diff", so it now checks for the artifact instead.build_fork.ymlstops passingconcurrency_grouptobuild_template.yml, which would otherwise log a group that no longer exists; the input inbuild_template.ymlalso becomes optional.🤖 Generated with Claude Code