From 1aecc140dc3be6b09348e524a1f55ed824d989fc Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Tue, 1 Sep 2026 11:33:08 +0800 Subject: [PATCH] =?UTF-8?q?ci=F0=9F=94=A7:=20run=20the=20test=20suite=20on?= =?UTF-8?q?=20every=20push=20and=20pull=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The repository has 19 test files and nothing was running any of them. Both workflows build with go build, which does not compile _test.go, the Makefile's test target was commented out, and there is no pre-commit hook. Every test in the tree, including the schema guards that exist precisely to catch a silent breakage, only ran when someone remembered to type go test. Enables the commented-out target and calls it from go.yml, the one workflow that fires on every push and pull request. build.yml is left alone: it skips documentation-only changes and deploys on master, so it is the wrong place for a gate that should never be skipped. Runs with -race. common/actions reuses model instances across concurrent requests, so a Generate() that returns in place rather than a copy leaks data between them, which a single-threaded run cannot see. Verified locally: the suite passes under CGO_ENABLED=0 and under -race, and make test exits non-zero when a test fails, so the step actually gates. Claude-Session: https://claude.ai/code/session_01DJhM6LvhkNPej35wy9F7Aq --- .github/workflows/go.yml | 7 +++++++ Makefile | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1bdb57e1..497e0eaf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -28,6 +28,13 @@ jobs: - name: Get dependencies run: go mod tidy + + # go build does not compile _test.go, so building alone never ran a single + # test. This is the only workflow that fires on every push and pull request, + # which makes it the one place a test gate belongs. + - name: Test + run: make test + - name: Build run: make build diff --git a/Makefile b/Makefile index 73972725..65b32832 100644 --- a/Makefile +++ b/Makefile @@ -37,9 +37,13 @@ stop: #@echo "go-admin stop success" -#.PHONY: test -#test: -# go test -v ./... -cover +# -race is worth the extra minute here: common/actions reuses model instances +# across concurrent requests, so a Generate() that returns in place instead of +# a copy leaks data between them - and that is invisible to a single-threaded +# test run. +.PHONY: test +test: + go test -race -cover ./... #.PHONY: docker #docker: