Skip to content

Commit bcc2283

Browse files
authored
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>
1 parent ec26e19 commit bcc2283

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

Makefile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,28 @@ verify-go-mod: go-mod-tidy ## Check that go.mod and go.sum formatted according t
127127

128128
deps: bin/gotestsum bin/golangci-lint bin/protoc bin/protoc-gen-go bin/protoc-gen-go-grpc bin/kind ## Install dev dependencies.
129129

130+
# Detect if we're running in GitHub Actions
131+
ifdef GITHUB_ACTIONS
132+
GOTESTSUM_FORMAT = github-actions
133+
else
134+
GOTESTSUM_FORMAT = testname
135+
GOTESTSUM_FORMAT_ICONS = hivis
136+
endif
137+
130138
.PHONY: test testrace testall
131-
test: ## Test go code.
132-
@go test -v ./...
139+
test: bin/gotestsum ## Test go code.
140+
ifdef GOTESTSUM_FORMAT_ICONS
141+
@gotestsum --format $(GOTESTSUM_FORMAT) --format-icons $(GOTESTSUM_FORMAT_ICONS) -- -v ./...
142+
else
143+
@gotestsum --format $(GOTESTSUM_FORMAT) -- -v ./...
144+
endif
133145

134-
testrace: ## Test go code and check for possible race conditions.
135-
@go test -v --race ./...
146+
testrace: bin/gotestsum ## Test go code and check for possible race conditions.
147+
ifdef GOTESTSUM_FORMAT_ICONS
148+
@gotestsum --format $(GOTESTSUM_FORMAT) --format-icons $(GOTESTSUM_FORMAT_ICONS) -- -v --race ./...
149+
else
150+
@gotestsum --format $(GOTESTSUM_FORMAT) -- -v --race ./...
151+
endif
136152

137153
testall: testrace ## Run all tests for go code.
138154

0 commit comments

Comments
 (0)