Skip to content

Commit 3708908

Browse files
committed
feat(test): introduce gotestsum to make output readable
Adds a new test target test-pretty which is now the default which makes failures more identifiable and test output just in general more read-able.
1 parent f44598b commit 3708908

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656

5757
- name: Run unit tests for kube-router
5858
run: |
59-
make test
59+
make test-pretty
6060
env:
6161
DOCKER_BUILD_IMAGE: ${{ env.BUILDTIME_BASE }}
6262

Makefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ FILE_ARCH=x86-64
6666
DOCKER_ARCH=
6767
endif
6868
$(info Building for GOARCH=$(GOARCH))
69-
all: lint test kube-router container ## Default target. Lints code, runs tests, builds binaries and images.
69+
all: lint test-pretty kube-router container ## Default target. Lints code, runs tests, builds binaries and images.
7070

7171
kube-router:
7272
@echo Starting kube-router binary build.
@@ -98,6 +98,21 @@ else
9898
go test -v -timeout 30s github.com/cloudnativelabs/kube-router/v2/cmd/kube-router/ github.com/cloudnativelabs/kube-router/v2/pkg/...
9999
endif
100100

101+
test-pretty: gofmt ## Runs code quality pipelines (gofmt, tests, coverage, etc)
102+
ifeq "$(BUILD_IN_DOCKER)" "true"
103+
$(DOCKER) run -v $(PWD):/go/src/github.com/cloudnativelabs/kube-router \
104+
-v $(GO_CACHE):/root/.cache/go-build \
105+
-v $(GO_MOD_CACHE):/go/pkg/mod \
106+
-w /go/src/github.com/cloudnativelabs/kube-router $(DOCKER_BUILD_IMAGE) \
107+
sh -c \
108+
'go install gotest.tools/gotestsum@latest && CGO_ENABLED=0 gotestsum --format gotestdox -- -timeout 30s github.com/cloudnativelabs/kube-router/v2/cmd/kube-router/ github.com/cloudnativelabs/kube-router/v2/pkg/...'
109+
else
110+
ifeq ($(shell command -v gotestsum 2>/dev/null),)
111+
go install gotest.tools/gotestsum@latest
112+
endif
113+
gotestsum --format gotestdox -- -timeout 30s github.com/cloudnativelabs/kube-router/v2/cmd/kube-router/ github.com/cloudnativelabs/kube-router/v2/pkg/...
114+
endif
115+
101116
lint: gofmt markdownlint
102117
ifeq "$(BUILD_IN_DOCKER)" "true"
103118
$(DOCKER) run -v $(PWD):/go/src/github.com/cloudnativelabs/kube-router \
@@ -250,7 +265,7 @@ help:
250265
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-22s\033[0m %s\n", $$1, $$2}'
251266

252267
.PHONY: clean container run release goreleaser push gofmt gofmt-fix gomoqs
253-
.PHONY: test lint docker-login push-manifest push-manifest-release
268+
.PHONY: test test-pretty lint docker-login push-manifest push-manifest-release
254269
.PHONY: push-release github-release help multiarch-binverify markdownlint
255270

256271
.DEFAULT: all

0 commit comments

Comments
 (0)