Skip to content

Commit 858bcca

Browse files
authored
Format unit test output with gotestfmt and upload raw log (#1639)
ci: format unit tests with gotestfmt and upload raw log - Add gotestfmt-install task - Format unit tests via gotestfmt, hide successful tests/packages and empty packages - Upload /tmp/gotest.log artifact in unit test workflow No coverage added; only unit tests are formatted.
1 parent 6c4efe3 commit 858bcca

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ jobs:
2727

2828
- name: Run tests
2929
run: task test
30+
31+
- name: Upload test log
32+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
33+
if: always()
34+
with:
35+
name: test-log
36+
path: /tmp/gotest.log
37+
if-no-files-found: error

Taskfile.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ tasks:
2424
cmds:
2525
- go install go.uber.org/mock/mockgen@latest
2626

27+
gotestfmt-install:
28+
desc: Install gotestfmt for pretty test output
29+
cmds:
30+
- go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
31+
2732
gen:
2833
desc: Generate mock files using go generate
2934
deps: [mock-install]
@@ -42,11 +47,12 @@ tasks:
4247
- golangci-lint run --fix ./...
4348

4449
test-unixlike:
45-
desc: Run unit tests (excluding e2e tests) on Linux and macOS with race detection
50+
desc: Run unit tests (excluding e2e tests) on Linux and macOS with race detection (formatted)
4651
platforms: [linux, darwin]
4752
internal: true
53+
deps: [gotestfmt-install]
4854
cmds:
49-
- go test -v -race $(go list ./... | grep -v '/test/e2e')
55+
- bash -o pipefail -c 'set -euo pipefail; go test -json -v -race $(go list ./... | grep -v "/test/e2e") 2>&1 | tee /tmp/gotest.log | gotestfmt -hide successful-tests,successful-packages,empty-packages'
5056

5157
test-windows:
5258
desc: Run unit tests (excluding e2e tests) on Windows with race detection

0 commit comments

Comments
 (0)