From 54e57f2b055a73f8beba18715913af806e0c4977 Mon Sep 17 00:00:00 2001 From: Tomasz Patrzek Date: Mon, 22 Jun 2026 14:13:18 +0200 Subject: [PATCH 1/2] Fix mutate-changes failing on pull_request CI events 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 --- .github/workflows/pricing-mutate.yml | 2 +- .github/workflows/rails_application-mutate.yml | 2 +- apps/rails_application/Makefile | 2 +- domains/pricing/Makefile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pricing-mutate.yml b/.github/workflows/pricing-mutate.yml index 953a70c2..4b1afae1 100644 --- a/.github/workflows/pricing-mutate.yml +++ b/.github/workflows/pricing-mutate.yml @@ -32,4 +32,4 @@ jobs: - name: Run incremental mutation testing run: make -C domains/pricing mutate-changes env: - GIT_BASE_SHA: ${{ github.event_name == 'push' && github.event.before || '' }} + GIT_BASE_SHA: ${{ github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha }} diff --git a/.github/workflows/rails_application-mutate.yml b/.github/workflows/rails_application-mutate.yml index aef0679f..6f91679b 100644 --- a/.github/workflows/rails_application-mutate.yml +++ b/.github/workflows/rails_application-mutate.yml @@ -56,4 +56,4 @@ jobs: DATABASE_URL: "postgres://postgres:secret@localhost:5432/cqrs-es-sample-with-res_test" RAILS_ENV: test MUTANT_OPTS: --jobs 4 - GIT_BASE_SHA: ${{ github.event_name == 'push' && github.event.before || '' }} + GIT_BASE_SHA: ${{ github.event_name == 'push' && github.event.before || github.event.pull_request.base.sha }} diff --git a/apps/rails_application/Makefile b/apps/rails_application/Makefile index 20685538..e57f6b04 100644 --- a/apps/rails_application/Makefile +++ b/apps/rails_application/Makefile @@ -26,7 +26,7 @@ else @bundle exec mutant run $(MUTANT_OPTS) endif -GIT_BASE_SHA ?= $(shell git merge-base HEAD origin/master) +GIT_BASE_SHA := $(or $(GIT_BASE_SHA),$(shell git merge-base HEAD origin/master)) mutate-changes: ## Run incremental mutation tests on changes @echo "Running incremental mutation tests against $(GIT_BASE_SHA)..." diff --git a/domains/pricing/Makefile b/domains/pricing/Makefile index 7382e574..0449b3f0 100644 --- a/domains/pricing/Makefile +++ b/domains/pricing/Makefile @@ -1,4 +1,4 @@ -GIT_BASE_SHA ?= $(shell git merge-base HEAD origin/master) +GIT_BASE_SHA := $(or $(GIT_BASE_SHA),$(shell git merge-base HEAD origin/master)) install: @bundle install From 3bf71cc15ae9b275ba7272c93ba0ca24321567a5 Mon Sep 17 00:00:00 2001 From: Tomasz Patrzek Date: Mon, 22 Jun 2026 14:23:02 +0200 Subject: [PATCH 2/2] Treat git null SHA as missing base in mutate-changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/rails_application/Makefile | 4 +++- domains/pricing/Makefile | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/rails_application/Makefile b/apps/rails_application/Makefile index e57f6b04..61591a74 100644 --- a/apps/rails_application/Makefile +++ b/apps/rails_application/Makefile @@ -26,7 +26,9 @@ else @bundle exec mutant run $(MUTANT_OPTS) endif -GIT_BASE_SHA := $(or $(GIT_BASE_SHA),$(shell git merge-base HEAD origin/master)) +# Fall back to merge-base when GIT_BASE_SHA is empty or the git null SHA +# (push of a new branch sets github.event.before to 0000…0). +GIT_BASE_SHA := $(or $(filter-out 0000000000000000000000000000000000000000,$(GIT_BASE_SHA)),$(shell git merge-base HEAD origin/master)) mutate-changes: ## Run incremental mutation tests on changes @echo "Running incremental mutation tests against $(GIT_BASE_SHA)..." diff --git a/domains/pricing/Makefile b/domains/pricing/Makefile index 0449b3f0..91de9de2 100644 --- a/domains/pricing/Makefile +++ b/domains/pricing/Makefile @@ -1,4 +1,6 @@ -GIT_BASE_SHA := $(or $(GIT_BASE_SHA),$(shell git merge-base HEAD origin/master)) +# Fall back to merge-base when GIT_BASE_SHA is empty or the git null SHA +# (push of a new branch sets github.event.before to 0000…0). +GIT_BASE_SHA := $(or $(filter-out 0000000000000000000000000000000000000000,$(GIT_BASE_SHA)),$(shell git merge-base HEAD origin/master)) install: @bundle install