Browse Source

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>
pull/4576/head v2.45.0
Maksim Nabokikh 3 weeks ago committed by GitHub
parent
commit
bcc2283694
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 24
      Makefile

24
Makefile

@ -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.
# Detect if we're running in GitHub Actions
ifdef GITHUB_ACTIONS
GOTESTSUM_FORMAT = github-actions
else
GOTESTSUM_FORMAT = testname
GOTESTSUM_FORMAT_ICONS = hivis
endif
.PHONY: test testrace testall
test: ## Test go code.
@go test -v ./...
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: ## Test go code and check for possible race conditions.
@go test -v --race ./...
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.

Loading…
Cancel
Save