Skip to content

Fix mutate-changes failing on pull_request CI events#466

Open
tomaszpatrzek wants to merge 2 commits into
masterfrom
fix-mutate-changes-ci
Open

Fix mutate-changes failing on pull_request CI events#466
tomaszpatrzek wants to merge 2 commits into
masterfrom
fix-mutate-changes-ci

Conversation

@tomaszpatrzek

Copy link
Copy Markdown
Collaborator

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

  • Workflows (pricing-mutate.yml, rails_application-mutate.yml): on PRs use
    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.
  • Makefiles (domains/pricing/Makefile, apps/rails_application/Makefile): compute
    the merge-base when GIT_BASE_SHA is set-but-empty using $(or
    $(GIT_BASE_SHA),$(shell git merge-base HEAD origin/master)), so a blank env can
    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

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>
@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploy Preview for ecommerce-events failed. Why did it fail? →

Name Link
🔨 Latest commit 3bf71cc
🔍 Latest deploy log https://app.netlify.com/projects/ecommerce-events/deploys/6a392974b5bbdf0008318212

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>
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