Skip to content

Commit 2bd11df

Browse files
authored
test: precompile the db cleaner on make test (coder#20000)
We're seeing some timeouts from starting the db cleaner, e.g. coder/internal#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.
1 parent fdb0267 commit 2bd11df

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,11 +1020,19 @@ endif
10201020

10211021
TEST_PACKAGES ?= ./...
10221022

1023-
test:
1023+
warm-go-cache-db-cleaner:
1024+
# ensure Go's build cache for the cleanercmd is fresh so that tests don't have to build from scratch. This
1025+
# could take some time and counts against the test's timeout, which can lead to flakes.
1026+
# c.f. https://github.com/coder/internal/issues/1026
1027+
mkdir -p build
1028+
$(GIT_FLAGS) go build -o ./build/cleaner github.com/coder/coder/v2/coderd/database/dbtestutil/cleanercmd
1029+
.PHONY: warm-go-cache-db-cleaner
1030+
1031+
test: warm-go-cache-db-cleaner
10241032
$(GIT_FLAGS) gotestsum --format standard-quiet $(GOTESTSUM_RETRY_FLAGS) --packages="$(TEST_PACKAGES)" -- $(GOTEST_FLAGS)
10251033
.PHONY: test
10261034

1027-
test-cli:
1035+
test-cli: warm-go-cache-db-cleaner
10281036
$(MAKE) test TEST_PACKAGES="./cli..."
10291037
.PHONY: test-cli
10301038

0 commit comments

Comments
 (0)