Repository navigation
fix(ci): run CI on a pull request whose base is not main (#512) - #526
Merged
Merged
Conversation
ci.yml and security.yml both filtered their pull_request trigger on `branches: [main]`, so a pull request stacked on a feature branch started none of their jobs — not test, not lint, not coverage, not Security Scan, not one of the twelve build-tags/cross-build cells. Nothing failed, and that is what made it invisible for as long as it lasted. The checks never existed, so `gh pr checks` returned one row, `dependabot skipping`, and the pull request read as green because nothing was red rather than because anything had passed. #511 was reviewed in that state. The window also closes at exactly the moment it stops being useful. GitHub retargets a stacked pull request to main when its parent merges, so CI first runs after review has already happened against zero signal — the gap is invisible while it matters and gone by the time anyone would look. security.yml is not named in #512 but carried the same filter, and it matters more there: Security Scan is a required status check on main, so the filtered-out trigger was a check that is supposed to be able to block a merge and could not report at all. The push trigger keeps its `branches: [main]` in both files. That one is a different question with a correct answer — it stops a feature-branch push from duplicating the pull request's own run — so it is left alone rather than removed for symmetry. TestNoPullRequestTriggerFiltersItsBaseBranch walks .github/workflows/ and fails on a branches or branches-ignore filter under pull_request or pull_request_target. Walked rather than enumerated on purpose: naming the two files that had the bug checks the two files that had the bug, and the next workflow to arrive with `branches: [main]` copied out of a README is the case a hard-coded list cannot see. It carries a floor on the file count and a non-vacuity guard on the trigger count, the latter because yaml.v2 parses the key `on` as the boolean true — a map[string]any lookup finds nothing and passes every file.
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.
Closes #512.
The defect
ci.ymlandsecurity.ymlboth filtered theirpull_requesttrigger onbranches: [main]. A pullrequest stacked on a feature branch therefore started none of their jobs — not
test, notlint, notcoverage, notSecurity Scan, not one of the twelvebuild-tags/cross-buildcells.Nothing failed, and that is what made it invisible. The checks never existed, so
gh pr checksreturned a single row —
dependabot skipping, the one workflow with no base filter — and the pullrequest read as green because nothing was red rather than because anything passed. #511 was reviewed
in exactly that state.
The window also closes at precisely the moment it stops being useful: GitHub retargets a stacked pull
request to
mainwhen its parent merges, so CI first runs after review has already happened againstzero signal. The gap is invisible while it matters and gone by the time anyone would look for it.
Beyond the issue's scope
#512 names
ci.ymlonly.security.ymlcarried the same filter, and it matters more there:Security Scanis a required status check onmain, so the trigger being filtered out meant acheck that is supposed to be able to block a merge could not report at all on a stacked PR.
The
pushtrigger keeps itsbranches: [main]in both files. That is a different question with acorrect answer — it stops a feature-branch push from duplicating the pull request's own run — so it is
left alone rather than removed for symmetry.
The test
TestNoPullRequestTriggerFiltersItsBaseBranchwalks.github/workflows/and fails on abranches:or
branches-ignore:filter underpull_requestorpull_request_target.Walked rather than enumerated on purpose: naming
ci.ymlandsecurity.ymlchecks the two files thatalready had the bug, while the next workflow to arrive with
branches: [main]copied out of a READMEis the case a hard-coded list cannot see. It carries a floor on the file count (
< 4fails) and anon-vacuity guard on the trigger count — the latter because yaml.v2 parses the key
onas theboolean
true, not the string"on", so amap[string]anylookup finds nothing and passes everyfile without inspecting one.
Verification
The test passes (
checked 3 pull-request triggers across 5 workflow files), and five mutations wererun against it, each of which it caught:
branches: [main]onci.yml'spull_requestci.ymlsecurity.ymlsecurity.ymlbranches-ignore: [docs/**]instead ofbranches:pull_request_target(dependabot-automerge.yml)truekey from theon:lookupM5 is the one worth having: without the guard it is the mutation that would have made this test
useless and green.
go test -race ./...passes for every package that builds on this machine. Six packages —cmd/objectfs,internal/adapter,internal/metrics,sdks/c,sdks/go/objectfs,tests— fail to build locallywith
runtime/cgo: You have not agreed to the Xcode license agreements, which is a local toolchainstate unrelated to this change and does not affect the Linux runners.
CGO_ENABLED=0 go build ./...isclean,
golangci-lintreports 0 issues oninternal/config, and every pre-commit hook passes exceptthe two that are blocked by the same cgo failure.