Skip to content

Stop push/pull_request CI runs from racing to cancel each other - #1246

Merged
mkarlesky merged 2 commits into
next_versionfrom
ci-dedupe-push-vs-pr
Aug 27, 2026
Merged

Stop push/pull_request CI runs from racing to cancel each other#1246
mkarlesky merged 2 commits into
next_versionfrom
ci-dedupe-push-vs-pr

Conversation

@mkarlesky

Copy link
Copy Markdown
Member

Summary

A push to a branch with an open PR fires both a push event and a pull_request:synchronize event for the same commit. Both previously shared one concurrency group (keyed only on branch name), so whichever run happened to start second cancelled the other — sometimes the pull_request-attached run, whose checks are what a reviewer actually sees on the PR.

  • Keys the concurrency group on event name too, so push and pull_request runs for the same branch can never cancel each other; each event type still dedupes/cancels its own superseded runs as before.
  • Adds a check-duplicate-push job that queries the GitHub API for an open PR on the pushed branch and, if one exists, skips every other job in the push-triggered run entirely — restoring single-run-per-commit behavior without relying on a cancellation race to get there.
  • Every job's if: explicitly ANDs in success() alongside the new skip check, since a custom if: replaces GitHub's default implicit success-of-needs check rather than being combined with it.

Test plan

  • YAML syntax validated (ruby -ryaml -e 'YAML.load_file(...)')
  • Manually traced every job's needs:/if: wiring to confirm the original "only run if dependencies succeeded" behavior is preserved alongside the new skip guard
  • Live validation in progress on this PR itself: after opening this PR, an additional commit will be pushed to this same branch to fire both a push and a pull_request:synchronize event for the same commit — the exact scenario this fix targets. Expected: the pull_request-triggered run (this PR's checks) runs to completion, unaffected; the redundant push-triggered run's check-duplicate-push job detects this open PR and skips its remaining jobs. Results will be added to this PR's checks/comments once observed.

🤖 Generated with Claude Code

mkarlesky and others added 2 commits August 27, 2026 16:22
A push to a branch with an open PR fires both a push and a
pull_request:synchronize event for the same commit. Both previously
shared one concurrency group (keyed only on branch name), so whichever
run happened to start second cancelled the other -- sometimes the
pull_request-attached run, whose checks are what a reviewer actually
sees on the PR.

Keys the concurrency group on event name too, so push and pull_request
runs for the same branch can never cancel each other; each event type
still dedupes/cancels its own superseded runs as before. Adds a
check-duplicate-push job that queries the GitHub API for an open PR on
the pushed branch and, if one exists, skips every other job in the
push-triggered run entirely -- restoring single-run-per-commit behavior
without relying on a cancellation race to get there. Every job's `if:`
explicitly ANDs in success() alongside the new skip check, since a
custom `if:` replaces GitHub's default implicit success-of-needs check
rather than being combined with it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Also a live trigger for validating this PR's own fix: pushing this to a
branch that already has an open PR should skip the resulting push-triggered
run's downstream jobs while this PR's own pull_request-triggered run
proceeds unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mkarlesky
mkarlesky merged commit 7b99c7b into next_version Aug 27, 2026
28 checks passed
@mkarlesky
mkarlesky deleted the ci-dedupe-push-vs-pr branch August 27, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant