From c75c666ab101832f3d4436f37d4c976421b46835 Mon Sep 17 00:00:00 2001 From: Joseph Woodward Date: Sun, 7 Dec 2025 00:43:04 +0000 Subject: [PATCH 1/3] feat: add gotestfmt to CI to improve test reporting --- taskfiles/test.yml | 12 +++++++++--- taskfiles/tools.yml | 10 +++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/taskfiles/test.yml b/taskfiles/test.yml index 0f0681bcf8..27ffb2515c 100644 --- a/taskfiles/test.yml +++ b/taskfiles/test.yml @@ -5,29 +5,35 @@ tasks: desc: Run unit tests aliases: - ut + deps: + - :tools:install-gotestfmt vars: TIMEOUT: '{{if .CI}}5m{{else}}1m{{end}}' cmds: - - go test {{.GO_FLAGS}} -timeout {{.TIMEOUT}} -shuffle=on {{if .CI}}{{else}}-v{{end}} ./... + - go test {{.GO_FLAGS}} -json -timeout {{.TIMEOUT}} -shuffle=on {{if .CI}}{{else}}-v{{end}} ./... 2>&1 | tee /tmp/gotest.log | {{.TOOLS_BIN_DIR}}/gotestfmt unit-race: desc: Run unit tests with race detection aliases: - ut-race + deps: + - :tools:install-gotestfmt cmds: - - go test {{.GO_FLAGS}} -timeout 3m -shuffle=on -race {{if .CI}}{{else}}-v{{end}} ./... + - go test {{.GO_FLAGS}} -json -timeout 3m -shuffle=on -race {{if .CI}}{{else}}-v{{end}} ./... 2>&1 | tee /tmp/gotest.log | {{.TOOLS_BIN_DIR}}/gotestfmt integration-package: desc: Run integration tests for package PKG aliases: - it + deps: + - :tools:install-gotestfmt requires: vars: - PKG vars: TIMEOUT: '{{if .CI}}15m{{else}}5m{{end}}' cmds: - - go test {{.GO_FLAGS}} -run "^Test.*Integration" -timeout {{.TIMEOUT}} {{if .CI}}{{else}}-v{{end}} {{.PKG}} + - go test {{.GO_FLAGS}} -json -run "^Test.*Integration" -timeout {{.TIMEOUT}} {{if .CI}}{{else}}-v{{end}} {{.PKG}} 2>&1 | tee /tmp/gotest.log | {{.TOOLS_BIN_DIR}}/gotestfmt template: desc: Run template tests diff --git a/taskfiles/tools.yml b/taskfiles/tools.yml index 5b8c192693..ba43774201 100644 --- a/taskfiles/tools.yml +++ b/taskfiles/tools.yml @@ -9,6 +9,7 @@ tasks: deps: - install-golangci-lint - install-govulncheck + - install-gotestfmt install-golangci-lint: desc: Install golangci-lint @@ -27,4 +28,11 @@ tasks: run: always silent: true cmds: - - GOBIN={{.GOBIN}} go install golang.org/x/vuln/cmd/govulncheck@latest \ No newline at end of file + - GOBIN={{.GOBIN}} go install golang.org/x/vuln/cmd/govulncheck@latest + + install-gotestfmt: + desc: Install gotestfmt + run: always + silent: true + cmds: + - GOBIN={{.GOBIN}} go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@v2.5.0 From 80529e34c4dab7d76bc2edfc5961f1a03cde745e Mon Sep 17 00:00:00 2001 From: Joseph Woodward Date: Tue, 9 Dec 2025 16:52:48 +0000 Subject: [PATCH 2/3] refactor: remove dependency and let it fail if deps not installed --- taskfiles/test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/taskfiles/test.yml b/taskfiles/test.yml index 27ffb2515c..9b5e31a216 100644 --- a/taskfiles/test.yml +++ b/taskfiles/test.yml @@ -5,8 +5,6 @@ tasks: desc: Run unit tests aliases: - ut - deps: - - :tools:install-gotestfmt vars: TIMEOUT: '{{if .CI}}5m{{else}}1m{{end}}' cmds: @@ -16,8 +14,6 @@ tasks: desc: Run unit tests with race detection aliases: - ut-race - deps: - - :tools:install-gotestfmt cmds: - go test {{.GO_FLAGS}} -json -timeout 3m -shuffle=on -race {{if .CI}}{{else}}-v{{end}} ./... 2>&1 | tee /tmp/gotest.log | {{.TOOLS_BIN_DIR}}/gotestfmt @@ -25,8 +21,6 @@ tasks: desc: Run integration tests for package PKG aliases: - it - deps: - - :tools:install-gotestfmt requires: vars: - PKG From ffeb2ebdf0f3706b162ac049ba1870647ee80109 Mon Sep 17 00:00:00 2001 From: Joseph Woodward Date: Wed, 10 Dec 2025 12:13:29 +0000 Subject: [PATCH 3/3] feat: add pre-condition to require gotestfmt --- taskfiles/test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/taskfiles/test.yml b/taskfiles/test.yml index 9b5e31a216..07230137f5 100644 --- a/taskfiles/test.yml +++ b/taskfiles/test.yml @@ -7,6 +7,9 @@ tasks: - ut vars: TIMEOUT: '{{if .CI}}5m{{else}}1m{{end}}' + preconditions: + - sh: command -v {{.TOOLS_BIN_DIR}}/gotestfmt + msg: "gotestfmt is not installed. Run 'task tools:install-gotestfmt' first." cmds: - go test {{.GO_FLAGS}} -json -timeout {{.TIMEOUT}} -shuffle=on {{if .CI}}{{else}}-v{{end}} ./... 2>&1 | tee /tmp/gotest.log | {{.TOOLS_BIN_DIR}}/gotestfmt @@ -14,6 +17,9 @@ tasks: desc: Run unit tests with race detection aliases: - ut-race + preconditions: + - sh: command -v {{.TOOLS_BIN_DIR}}/gotestfmt + msg: "gotestfmt is not installed. Run 'task tools:install-gotestfmt' first." cmds: - go test {{.GO_FLAGS}} -json -timeout 3m -shuffle=on -race {{if .CI}}{{else}}-v{{end}} ./... 2>&1 | tee /tmp/gotest.log | {{.TOOLS_BIN_DIR}}/gotestfmt @@ -26,6 +32,9 @@ tasks: - PKG vars: TIMEOUT: '{{if .CI}}15m{{else}}5m{{end}}' + preconditions: + - sh: command -v {{.TOOLS_BIN_DIR}}/gotestfmt + msg: "gotestfmt is not installed. Run 'task tools:install-gotestfmt' first." cmds: - go test {{.GO_FLAGS}} -json -run "^Test.*Integration" -timeout {{.TIMEOUT}} {{if .CI}}{{else}}-v{{end}} {{.PKG}} 2>&1 | tee /tmp/gotest.log | {{.TOOLS_BIN_DIR}}/gotestfmt @@ -38,6 +47,9 @@ tasks: vars: TEMPLATE_FILES: sh: find internal/impl -type f -name "*tmpl.yaml" | tr '\n' ' ' + preconditions: + - sh: command -v {{.TOOLS_BIN_DIR}}/gotestfmt + msg: "gotestfmt is not installed. Run 'task tools:install-gotestfmt' first." cmds: - '{{.TARGET_DIR}}/redpanda-connect template lint {{.TEMPLATE_FILES}}' - '{{.TARGET_DIR}}/redpanda-connect test ./config/test/...'