Skip to content

CI: skip the master push run for already-tested PR merges - #73

Merged
vthorsteinsson merged 1 commit into
masterfrom
ci-skip-duplicate-runs
Oct 23, 2026
Merged

vthorsteinsson merged 1 commit into
masterfrom
ci-skip-duplicate-runs

Conversation

@vthorsteinsson

Copy link
Copy Markdown
Member

Every merged PR is tested twice: once by its pull_request run and again by the push run on master. That's 8 jobs (about 15 job-minutes) each time.

Changes (.github/workflows/python-package.yml)

  • gate job (Ubuntu, about 10 s). It skips the test matrix on a master push when all of these hold:

    • the pushed commit is a merge;
    • its first parent (master's previous head) is an ancestor of its second parent (the PR head), i.e. the branch was up to date with master;
    • the PR head has a successful pull_request run of this workflow.

    The merge commit then has exactly the tree the PR run tested. Direct pushes, squash merges and PRs that were behind master still get the full run. GitHub empties a workflow run's pull_requests list after merging, which is why the check uses commit ancestry rather than PR metadata.

  • Concurrency: a new push to a PR cancels its run in progress. Master runs are never cancelled (the group key is the commit SHA).

  • paths-ignore: **.md on both triggers, so Markdown-only changes don't run CI. There are no required status checks, so a docs-only PR is not left waiting.

Verified against past merges

I ran the gate logic locally against the real history:

Commit Branch state Gate
ca6464f (#72) up to date skip
3c7d88d (#71) up to date skip
6c53a71 (#63), dc777ba (#64) diverged (dependabot, 44 behind) full run
64b07a2 "Bump version to 3.9.0" direct push full run

This PR's own run exercises the pull_request path, where the gate always passes through. If this branch is still up to date with master when merged, the push run on master should show the matrix as skipped.

🤖 Generated with Claude Code

A merged PR was tested twice: once by its pull_request run and again
by the push run on master, 8 jobs each time. A new gate job skips the
test matrix on a master push when the pushed commit is a merge whose
first parent (master's previous head) is an ancestor of the second
parent (the PR head) and the PR head has a successful pull_request
run. The merge commit then has exactly the tree that the PR run
tested. Direct pushes, squash merges and PRs that were behind master
still get the full run.

Also cancel a superseded PR run when new commits are pushed (master
runs are never cancelled), and skip CI for Markdown-only changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vthorsteinsson
vthorsteinsson merged commit c25b839 into master Oct 23, 2026
9 checks passed
@vthorsteinsson
vthorsteinsson deleted the ci-skip-duplicate-runs branch October 23, 2026 13:41
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