Skip to content

ci: build every branch again, still without duplicate runs - #13

Merged
s-celles merged 1 commit into
mainfrom
ci/branch-ci-without-duplicates
Aug 1, 2026
Merged

s-celles merged 1 commit into
mainfrom
ci/branch-ci-without-duplicates

Conversation

@s-celles

@s-celles s-celles commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

#9 removed the push: ['**'] wildcard to stop the matrix running twice on the same commit. It worked — #8 went from six checks to three — but it also removed CI from branches with no open PR. I flagged that trade-off in #9 without knowing whether it mattered to you. It does. This gets both.

How

The wildcard is back on push. The duplication is now prevented at the job rather than at the trigger:

if: >-
  github.event_name != 'pull_request'
  || github.event.pull_request.head.repo.full_name != github.repository

When both events fire for a branch in this repository, the push run covers the commit and the pull_request run is skipped.

Fork PRs are exempted from the skip. A fork's branch produces no push event here, so without that exemption a fork PR would get no CI at all — worse than the doubling this fixes.

Situation Before #9 After #9 This PR
Branch, no PR ✅ built ❌ nothing ✅ built
Branch, same-repo PR ⚠️ built twice ✅ once ✅ once
Fork PR ✅ built ✅ built ✅ built
main, tags ✅ built ✅ built ✅ built

The trade-off, stated

A same-repository PR is now tested at its branch head, not at the merge with main. That is what push gives you; pull_request builds refs/pull/N/merge instead.

Fork PRs keep merge-result testing. For a repository whose branches are mostly its maintainer's, branch-head testing is the ordinary arrangement — but if main moves under a long-lived PR, update the branch to get a true signal. Worth knowing rather than discovering.

If you would rather keep merge-result testing for your own PRs and accept the doubling, say so and I will revert to the original triggers — that is a legitimate choice, and the cost is only CI minutes.

Concurrency

Now cancels superseded runs on any ref that is not main and not a tag. Feature branches are built through push again, so repeated pushes should supersede rather than race. main and tags still record every commit.

Testing

Workflow-only. YAML validated locally: the wildcard, the tag trigger, the job if and the concurrency expression all parse and resolve as intended.

This PR is its own partial test: it is a same-repository PR, so it should report three checks from the push event, with the pull_request run skipped. What it cannot test from here is the fork path — that only shows the first time someone opens a PR from a fork.

#9 removed the `push: ['**']` wildcard to stop the matrix running twice
per commit. That worked, but it also removed CI from branches with no
open PR — a trade-off I flagged in that PR without knowing it mattered
here. It does. This restores branch builds and keeps the deduplication.

The wildcard is back on `push`. The duplication is now prevented at the
job instead: when both events fire for a branch in this repository, the
`push` run covers it and the `pull_request` run is skipped.

    if: >-
      github.event_name != 'pull_request'
      || github.event.pull_request.head.repo.full_name != github.repository

Fork PRs are exempted from the skip. A fork's branch produces no `push`
event here, so without that exemption a fork PR would get no CI at all —
which would be worse than the doubling this is fixing.

Trade-off, taken deliberately and worth stating: a same-repository PR is
now tested at its branch head rather than at the merge with `main`. Fork
PRs keep the merge-result testing `pull_request` provides. For a
repository whose branches are mostly its own maintainer's, branch-head
testing is the ordinary arrangement; if `main` moves under a long-lived
PR, update the branch to get a true signal.

The concurrency group now cancels superseded runs on any ref that is not
`main` and not a tag, since feature branches are built through `push`
again and repeated pushes should not race each other.
@s-celles
s-celles merged commit 74dd142 into main Aug 1, 2026
4 checks passed
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