From 2bd11dfb159efe9b93dd5d6b8846e47e97f28550 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Tue, 30 Sep 2025 10:42:06 +0400 Subject: [PATCH] test: precompile the db cleaner on make test (#20000) We're seeing some timeouts from starting the db cleaner, e.g. https://github.com/coder/internal/issues/1026 My suspicion is that in CI the go build cache might not be warm, and so it can take a while to compile and run the dbcleaner subprocess. This fix builds the cleaner once prior to starting a test run via `make test` to ensure we have a warm cache. --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8b17b88e20..8f7bc9d17e 100644 --- a/Makefile +++ b/Makefile @@ -1020,11 +1020,19 @@ endif TEST_PACKAGES ?= ./... -test: +warm-go-cache-db-cleaner: + # ensure Go's build cache for the cleanercmd is fresh so that tests don't have to build from scratch. This + # could take some time and counts against the test's timeout, which can lead to flakes. + # c.f. https://github.com/coder/internal/issues/1026 + mkdir -p build + $(GIT_FLAGS) go build -o ./build/cleaner github.com/coder/coder/v2/coderd/database/dbtestutil/cleanercmd +.PHONY: warm-go-cache-db-cleaner + +test: warm-go-cache-db-cleaner $(GIT_FLAGS) gotestsum --format standard-quiet $(GOTESTSUM_RETRY_FLAGS) --packages="$(TEST_PACKAGES)" -- $(GOTEST_FLAGS) .PHONY: test -test-cli: +test-cli: warm-go-cache-db-cleaner $(MAKE) test TEST_PACKAGES="./cli..." .PHONY: test-cli