Fix mutate-changes failing on pull_request CI events#466
Open
tomaszpatrzek wants to merge 2 commits into
Open
Conversation
On pull_request events the *-mutate workflows set GIT_BASE_SHA to ''. Make's `?=` does not override an env var that is already defined (even when empty), so `mutant run --since` was invoked with no base ref, and mutant's git-diff bootstrap blew up with Mutant::Repository::Diff::Error. - Workflows: use github.event.pull_request.base.sha on PRs instead of '' (full history is already available via fetch-depth: 0). - Makefiles: compute merge-base when GIT_BASE_SHA is set-but-empty via $(or ...), so a blank env can never reach mutant again. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
❌ Deploy Preview for ecommerce-events failed. Why did it fail? →
|
A push of a new branch sets github.event.before to the all-zero git SHA (0000…0), which is non-empty so it slipped past the $(or ...) guard and was passed to `mutant --since`, failing the same way an empty value did. Filter out the null SHA too, so both an empty and a null base fall back to `git merge-base HEAD origin/master` (diff the branch against master). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Fix mutate-changes failing on pull_request CI events
Problem
The pricing-mutate and rails_application-mutate workflows fail on every PR
during mutant bootstrap:
Running incremental mutation tests against ... ← GIT_BASE_SHA is empty
Mutant::Repository::Diff#touched_path: ...CommandStatus...
(Mutant::Repository::Diff::Error)
Root cause
Both workflows set the base SHA like this:
GIT_BASE_SHA: ${{ github.event_name == 'push' && github.event.before || '' }}
On a pull_request event the ternary resolves to ''. The Makefiles default it
with:
GIT_BASE_SHA ?= $(shell git merge-base HEAD origin/master)
but ?= only assigns when the variable is undefined — an env var exported as an
empty string still counts as defined, so the merge-base fallback never runs.
mutant run --since is then invoked with no base ref, and mutant's git-diff
bootstrap raises Mutant::Repository::Diff::Error. This hits every PR (the
workflows trigger on pull_request: [opened, reopened] with no path filter),
independent of what the PR changes.
Fix
github.event.pull_request.base.sha instead of ''. Full history is already
available via fetch-depth: 0, so the base commit is present for --since.
the merge-base when GIT_BASE_SHA is set-but-empty using $(or
never reach mutant again (defense in depth, also helps local runs).
Scope
CI-only change, 4 files, 4 lines. No application code touched.
🤖 Generated with Claude Code