feat: enhance test commands to support GitHub Actions formatting (#4575)

With the number of tests growing, it is harder and harder to find errors in the test output. Gotestsum is a well-known runner for tests helping to format the output fot both local runs and GitHub Actions.

Signed-off-by: maksim.nabokikh <max.nabokih@gmail.com>
This commit is contained in:
Maksim Nabokikh
2026-02-23 15:34:51 +01:00
committed by GitHub
parent ec26e19e79
commit bcc2283694
+21 -5
View File
@@ -127,12 +127,28 @@ verify-go-mod: go-mod-tidy ## Check that go.mod and go.sum formatted according t
deps: bin/gotestsum bin/golangci-lint bin/protoc bin/protoc-gen-go bin/protoc-gen-go-grpc bin/kind ## Install dev dependencies.
.PHONY: test testrace testall
test: ## Test go code.
@go test -v ./...
# Detect if we're running in GitHub Actions
ifdef GITHUB_ACTIONS
GOTESTSUM_FORMAT = github-actions
else
GOTESTSUM_FORMAT = testname
GOTESTSUM_FORMAT_ICONS = hivis
endif
testrace: ## Test go code and check for possible race conditions.
@go test -v --race ./...
.PHONY: test testrace testall
test: bin/gotestsum ## Test go code.
ifdef GOTESTSUM_FORMAT_ICONS
@gotestsum --format $(GOTESTSUM_FORMAT) --format-icons $(GOTESTSUM_FORMAT_ICONS) -- -v ./...
else
@gotestsum --format $(GOTESTSUM_FORMAT) -- -v ./...
endif
testrace: bin/gotestsum ## Test go code and check for possible race conditions.
ifdef GOTESTSUM_FORMAT_ICONS
@gotestsum --format $(GOTESTSUM_FORMAT) --format-icons $(GOTESTSUM_FORMAT_ICONS) -- -v --race ./...
else
@gotestsum --format $(GOTESTSUM_FORMAT) -- -v --race ./...
endif
testall: testrace ## Run all tests for go code.