From d3a095ba691778ab6485044a4f7ba451cf43ea8b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 25 Jun 2025 14:53:25 +0000 Subject: [PATCH] Integrate gotestsum using Go 1.24 tool dependency feature This commit introduces `gotestsum` to the project for enhanced test execution and reporting, utilizing the Go 1.24 feature for managing tool dependencies directly in `go.mod`. Key changes: - Added `gotest.tools/gotestsum` as a tool dependency to `go.mod` using `go get -d` and `go mod edit -tool`. - Updated Makefile: - The `test` target now uses `gotestsum` with `short-verbose` format. - Added `test-rerun-fails` target using `gotestsum --rerun-fails`. - Added `test-ci` target using `gotestsum --junitfile report.xml --format dots`. - Makefile test targets use `go run gotest.tools/gotestsum` for execution. - `clean` target updated to remove `report.xml` and `.gotestsum.json`. - Updated GitHub Actions workflow (`.github/workflows/go.yml`): - Added step to `go install gotest.tools/gotestsum@v1.12.3`. - Test execution changed to `make test-ci`. - Added step to upload `report.xml` artifact. This approach replaces the previous `tools.go` method for managing `gotestsum` and aligns with the newer Go tooling standards. --- .github/workflows/go.yml | 21 +- Makefile | 13 +- go.mod | 9 +- go.sum | 17 +- report.xml | 550 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 605 insertions(+), 5 deletions(-) create mode 100644 report.xml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index dc2d73c..e688dc0 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -34,13 +34,30 @@ jobs: - name: Build run: make build - - name: Test with Coverage + - name: Install gotestsum + run: go install gotest.tools/gotestsum@v1.12.3 # Using specific version + + - name: Test with gotestsum (generate JUnit report) + run: make test-ci + + - name: Upload test results (JUnit XML) + uses: actions/upload-artifact@v4 + if: always() # テストが失敗してもレポートをアップロードする + with: + name: test-results + path: report.xml + + - name: Generate coverage report run: | - go test -v -coverprofile=coverage.out ./... + # It's good practice to ensure tests pass before generating coverage, + # but make test-ci already ran tests. If needed, run simple tests again for coverage. + # For now, assuming `go test` for coverage is separate and intentional. + go test -coverprofile=coverage.out ./... go tool cover -html=coverage.out -o coverage.html - name: Upload coverage report uses: actions/upload-artifact@v4 + if: always() # カバレッジ生成が失敗してもアーティファクトをアップロードする with: name: coverage-report path: coverage.html diff --git a/Makefile b/Makefile index 9c670b1..f154645 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,10 @@ NASK=wine nask.exe KILL_DEAD_CODE = find . -type f -name "*.go" -exec sed -i -E '/^\s*\/\/.*(remove|delete|unnecessary|dead code|no longer needed)/Id' {} + .PHONY: all test gen +# Use go run to execute gotestsum, ensuring it uses the version from go.mod +GOTESTSUM = go run gotest.tools/gotestsum + +.PHONY: all test test-rerun-fails test-ci gen clean run dep all: build test @@ -13,10 +17,17 @@ build: gen $(GOBUILD) -v -o $(BIN) ./cmd/gosk test: dep - go tool gotest -v ./... + $(GOTESTSUM) --format short-verbose -- ./... + +test-rerun-fails: dep + $(GOTESTSUM) --rerun-fails --format short-verbose --packages="./..." + +test-ci: dep + $(GOTESTSUM) --junitfile report.xml --format dots -- ./... clean: go clean + rm -f report.xml .gotestsum.json run: build ./$(BIN) diff --git a/go.mod b/go.mod index 1b244c9..224babc 100644 --- a/go.mod +++ b/go.mod @@ -24,19 +24,23 @@ require ( github.com/Bin-Huang/newc v0.8.3 // indirect github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect github.com/awalterschulze/goderive v0.5.1 // indirect + github.com/bitfield/gotestdox v0.2.2 // indirect github.com/cilium/ebpf v0.11.0 // indirect github.com/cosiner/argv v0.1.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/derekparker/trie v0.0.0-20230829180723-39f4de51ef7d // indirect github.com/dmarkham/enumer v1.5.11 // indirect + github.com/dnephin/pflag v1.0.7 // indirect github.com/fatih/camelcase v1.0.0 // indirect - github.com/fatih/color v1.9.0 // indirect + github.com/fatih/color v1.18.0 // indirect github.com/fatih/gomodifytags v1.17.1-0.20250423142747-f3939df9aa3c // indirect github.com/fatih/structtag v1.2.0 // indirect + github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/go-delve/delve v1.25.0 // indirect github.com/go-delve/liner v1.2.3-0.20231231155935-4726ab1d7f62 // indirect github.com/google/go-dap v0.12.0 // indirect + github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/iancoleman/strcase v0.2.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -60,10 +64,12 @@ require ( golang.org/x/sync v0.15.0 // indirect golang.org/x/sys v0.33.0 // indirect golang.org/x/telemetry v0.0.0-20250417124945-06ef541f3fa3 // indirect + golang.org/x/term v0.32.0 // indirect golang.org/x/tools v0.34.1-0.20250610205101-c26dd3ba555e // indirect golang.org/x/tools/gopls v0.19.1 // indirect golang.org/x/vuln v1.1.4 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + gotest.tools/gotestsum v1.12.3 // indirect honnef.co/go/tools v0.7.0-0.dev.0.20250523013057-bbc2f4dd71ea // indirect mvdan.cc/gofumpt v0.7.0 // indirect mvdan.cc/xurls/v2 v2.6.0 // indirect @@ -77,4 +83,5 @@ tool ( github.com/mna/pigeon github.com/rakyll/gotest golang.org/x/tools/gopls + gotest.tools/gotestsum ) diff --git a/go.sum b/go.sum index 2fc764b..9237e87 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/akedrou/textdiff v0.1.0 h1:K7nbOVQju7/coCXnJRJ2fsltTwbSvC+M4hKBUJRBRG github.com/akedrou/textdiff v0.1.0/go.mod h1:a9CCC49AKtFTmVDNFHDlCg7V/M7C7QExDAhb2SkL6DQ= github.com/awalterschulze/goderive v0.5.1 h1:H2XNRDw0Ordwj/pgLAVqQgDC1LQWP7L99ofOs72bjqg= github.com/awalterschulze/goderive v0.5.1/go.mod h1:DLlff0SRVo846CBrp8nXuXJ4mdWA92ai5CYTr+LV/II= +github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE= +github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY= github.com/cilium/ebpf v0.11.0 h1:V8gS/bTCCjX9uUnkUFUpPsksM8n1lXBAvHcpiFk1X2Y= github.com/cilium/ebpf v0.11.0/go.mod h1:WE7CZAnqOL2RouJ4f1uyNhqr2P4CCvXFIqdRDUgWsVs= github.com/comail/colog v0.0.0-20160416085026-fba8e7b1f46c h1:bzYQ6WpR+t35/y19HUkolcg7SYeWZ15IclC9Z4naGHI= @@ -25,16 +27,21 @@ github.com/derekparker/trie v0.0.0-20230829180723-39f4de51ef7d h1:hUWoLdw5kvo2xC github.com/derekparker/trie v0.0.0-20230829180723-39f4de51ef7d/go.mod h1:C7Es+DLenIpPc9J6IYw4jrK0h7S9bKj4DNl8+KxGEXU= github.com/dmarkham/enumer v1.5.11 h1:quorLCaEfzjJ23Pf7PB9lyyaHseh91YfTM/sAD/4Mbo= github.com/dmarkham/enumer v1.5.11/go.mod h1:yixql+kDDQRYqcuBM2n9Vlt7NoT9ixgXhaXry8vmRg8= +github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= +github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= -github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fatih/gomodifytags v1.17.1-0.20250423142747-f3939df9aa3c h1:dDSgAjoOMp8da3egfz0t2S+t8RGOpEmEXZubcGuc0Bg= github.com/fatih/gomodifytags v1.17.1-0.20250423142747-f3939df9aa3c/go.mod h1:YVLagR57bBxMai8IAEc7V4E/MWUYi0oUutLrZcTcnI8= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA= github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= +github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/go-delve/delve v1.25.0 h1:JN2S3iVptvayUS2w+d0UEPmijgkodW1AFM4I8UViHGE= github.com/go-delve/delve v1.25.0/go.mod h1:kJk12wo6PqzWknTP6M+Pg3/CrNhFMZvNq1iHESKkhv8= github.com/go-delve/liner v1.2.3-0.20231231155935-4726ab1d7f62 h1:IGtvsNyIuRjl04XAOFGACozgUD7A82UffYxZt4DWbvA= @@ -48,6 +55,8 @@ github.com/google/go-dap v0.12.0 h1:rVcjv3SyMIrpaOoTAdFDyHs99CwVOItIJGKLQFQhNeM= github.com/google/go-dap v0.12.0/go.mod h1:tNjCASCm5cqePi/RVXXWEVqtnNLV1KTWtYOqu6rZNzc= github.com/google/safehtml v0.1.0 h1:EwLKo8qawTKfsi0orxcQAZzu07cICaBeFMegAU9eaT8= github.com/google/safehtml v0.1.0/go.mod h1:L4KWwDsUJdECRAEpZoBn3O64bQaywRscowZjJAzjHnU= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/harakeishi/gats v0.0.0-20230219034858-055bc915842a h1:w1k8jkMF813H+9hRjTZFbN+HqWmgnxSlrczNCQYUSPo= github.com/harakeishi/gats v0.0.0-20230219034858-055bc915842a/go.mod h1:YD5RD9SlvwtTugjiYpoC49fFsB9LoYFmLH+5N7lxmx8= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= @@ -184,6 +193,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= +golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -219,6 +230,10 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/gotestsum v1.12.3 h1:jFwenGJ0RnPkuKh2VzAYl1mDOJgbhobBDeL2W1iEycs= +gotest.tools/gotestsum v1.12.3/go.mod h1:Y1+e0Iig4xIRtdmYbEV7K7H6spnjc1fX4BOuUhWw2Wk= +gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= +gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= honnef.co/go/tools v0.7.0-0.dev.0.20250523013057-bbc2f4dd71ea h1:fj8r9irJSpolAGUdZBxJIRY3lLc4jH2Dt4lwnWyWwpw= honnef.co/go/tools v0.7.0-0.dev.0.20250523013057-bbc2f4dd71ea/go.mod h1:EPDDhEZqVHhWuPI5zPAsjU0U7v9xNIWjoOVyZ5ZcniQ= mvdan.cc/gofumpt v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= diff --git a/report.xml b/report.xml new file mode 100644 index 0000000..38cb43b --- /dev/null +++ b/report.xml @@ -0,0 +1,550 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file