Skip redundant push builds for branches with an open PR - #3941
Merged
Conversation
A branch with an open PR was built twice per push, once by the push trigger and once by the pull_request trigger, doubling the Actions cost of every PR iteration. The pull_request run is the canonical one (it tests the merge with the base branch), so a small gate job now asks the API whether the pushed branch has an open PR whose base would fire the pull_request trigger and skips the push build if so. Pushes to master and release/* are exempt because their runs publish packages; PRs targeting other branches are ignored because they never trigger a pull_request build that could replace the push one. Filtering fork PRs in the on: section instead was considered and rejected: trigger-level filters cannot see whether an open PR exists, and skipping the pull_request runs would have lost merge testing. Assisted-by: Claude:claude-fable-5:Claude Code
The gate job was copy-pasted into build-ilspy.yml and build-frontends.yml and the two copies had already started drifting (job casing, comment wording). A workflow_call workflow keeps a single definition; the callers shrink to a uses: job and route its "run" output to their build jobs unchanged. Each caller must still grant pull-requests: read explicitly, because the called workflow's token is the intersection of what the caller grants and what the callee requests, and both callers default to contents: read only. Assisted-by: Claude:claude-fable-5:Claude Code
christophwille
approved these changes
Jul 31, 2026
The decompiler suite is cross-platform code already exercised by the Windows and Linux jobs; running it a third time on macOS only made the slowest job of the matrix (~54 min vs ~41 min on Linux) slower without adding coverage. Assisted-by: Claude:claude-fable-5:Claude Code
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.
Every push to a branch with an open PR currently builds twice: once via the
pushtrigger and once via thepull_requesttrigger, doubling the Actions cost of every PR iteration (including the 10x-billed macOS leg).This adds a small
Gatejob tobuild-ilspy.ymlandbuild-frontends.ymlthat skips thepush-triggered build when the pushed branch has an open PR that already builds it via thepull_requesttrigger. Thepull_requestrun is kept as the canonical one because it tests the merge with the base branch. Details:masterandrelease/*always build (their runs publish packages, and no PR of theirs may suppress that).master/release/*suppress a push build; a PR targeting any other branch never fires thepull_requesttrigger, so its head branch keeps building viapush.on:section: trigger filters cannot see whether an open PR exists, so a job queriesGET /repos/.../pulls?head=...(needspull-requests: read).Known benign race: pushing a branch and then opening its PR lets the already-started push run finish, so that one iteration still builds twice.
Verified with actionlint; the PR query and
jqbase filter were tested against the live repo, and the event/branch routing (master/release/*/feature pushes,pull_requestmerge refs) was exercised in a shell self-check.🤖 Generated with Claude Code