From ae0337d31b9c461b828b93bab116feb5dbd67ba4 Mon Sep 17 00:00:00 2001 From: Julian Sommer <115516918+juliansommer@users.noreply.github.com> Date: Mon, 17 Aug 2026 11:28:59 +1000 Subject: [PATCH] test: run the unit and race tiers clean in CI Go stores test results in the build cache alongside compiled objects, so now that the cache persists across runs an unchanged package replays its previous result instead of executing. That is what makes a local run fast and exactly what a merge gate should not do: a green check would no longer mean the suite ran against that commit. Add a GOTESTFLAGS hook, empty by default so local runs keep reusing results, and pass -count=1 from the two CI steps that gate a PR. Compilation is still cached either way, so this costs no build time. --- .github/workflows/spinifex.yml | 4 ++-- Makefile | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/spinifex.yml b/.github/workflows/spinifex.yml index fc928bafa..36e80be44 100644 --- a/.github/workflows/spinifex.yml +++ b/.github/workflows/spinifex.yml @@ -123,7 +123,7 @@ jobs: env: SPINIFEX_REQUIRE_CONFORMANCE_TOOLS: "1" VIPERBLOCK_NBDKIT_PLUGIN: ${{ github.workspace }}/viperblock/lib/nbdkit-viperblock-plugin.so - run: make -C spinifex test-cover + run: make -C spinifex test-cover GOTESTFLAGS=-count=1 - name: Run Action Tests run: make -C spinifex test-actions @@ -295,7 +295,7 @@ jobs: run: go work init ./spinifex ./viperblock ./predastore ./northstar ./bluebottle - name: Run Tests with Race Detector - run: make -C spinifex test-race + run: make -C spinifex test-race GOTESTFLAGS=-count=1 lint_and_security: name: Lint and Security diff --git a/Makefile b/Makefile index af392b77a..edfc1f79a 100644 --- a/Makefile +++ b/Makefile @@ -222,17 +222,22 @@ test: @echo -e "\n....Running tests for $(GO_PROJECT_NAME)...." LOG_IGNORE=1 go test -timeout 180s ./spinifex/... ./cmd/... ./internal/... +# Empty locally, where reusing a cached result between runs is the point. +# CI passes -count=1 so a green run means the suite executed against that commit +# rather than replaying results the persisted build cache carried over. +GOTESTFLAGS ?= + # Run unit tests with coverage profile COVERPROFILE ?= coverage.out test-cover: @echo -e "\n....Running tests with coverage for $(GO_PROJECT_NAME)...." - $(_Q)LOG_IGNORE=1 go test -timeout 180s -coverprofile=$(COVERPROFILE) -covermode=atomic ./spinifex/... ./cmd/... ./internal/... $(_COVQ) + $(_Q)LOG_IGNORE=1 go test $(GOTESTFLAGS) -timeout 180s -coverprofile=$(COVERPROFILE) -covermode=atomic ./spinifex/... ./cmd/... ./internal/... $(_COVQ) @scripts/check-coverage.sh $(COVERPROFILE) $(QUIET) # Run unit tests with race detector test-race: @echo -e "\n....Running tests with race detector for $(GO_PROJECT_NAME)...." - $(_Q)LOG_IGNORE=1 go test -race -timeout 300s ./spinifex/... ./cmd/... ./internal/... $(_RACEQ) + $(_Q)LOG_IGNORE=1 go test $(GOTESTFLAGS) -race -timeout 300s ./spinifex/... ./cmd/... ./internal/... $(_RACEQ) # Unit tests for in-repo GitHub Actions (e.g. .github/actions/e2e-analyze). # Kept out of `test-cover` so coverage % isn't diluted by CI-only tooling.