diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51e840fc6..84ded107b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,9 @@ jobs: with: go-version: ${{ matrix.go-version }} + - name: Install gotestsum + run: go install gotest.tools/gotestsum@latest + - name: Create junit-xml directory run: mkdir junit-xml diff --git a/internal/cmd/build/main.go b/internal/cmd/build/main.go index 2df49c57d..7628edd9a 100644 --- a/internal/cmd/build/main.go +++ b/internal/cmd/build/main.go @@ -122,10 +122,6 @@ func (b *builder) integrationTest() error { return fmt.Errorf("failed parsing flags: %w", err) } - gotestsum, err := b.getInstalledTool("gotest.tools/gotestsum") - if err != nil { - return fmt.Errorf("failed getting gotestsum: %w", err) - } // Also accept coverage file as env var if env := strings.TrimSpace(os.Getenv("TEMPORAL_COVERAGE_FILE")); *coverageFileFlag == "" && env != "" { *coverageFileFlag = env @@ -176,7 +172,7 @@ func (b *builder) integrationTest() error { } // Run integration test - args := []string{gotestsum, "-tags", "protolegacy", "-count", "1", "-race", "-v", "-timeout", "10m"} + args := []string{"gotestsum", "-tags", "protolegacy", "-count", "1", "-race", "-v", "-timeout", "10m"} if *junitFileFlag != "" { args = append(args, "--junitfile", *junitFileFlag+"-integration-test.xml") } @@ -247,14 +243,10 @@ func (b *builder) unitTest() error { return fmt.Errorf("failed parsing flags: %w", err) } - gotestsum, err := b.getInstalledTool("gotest.tools/gotestsum") - if err != nil { - return fmt.Errorf("failed getting gotestsum: %w", err) - } // Find every non ./test-prefixed package that has a test file testDirMap := map[string]struct{}{} var testDirs []string - err = fs.WalkDir(os.DirFS(b.rootDir), ".", func(p string, d fs.DirEntry, err error) error { + err := fs.WalkDir(os.DirFS(b.rootDir), ".", func(p string, d fs.DirEntry, err error) error { if !strings.HasPrefix(p, "test") && strings.HasSuffix(p, "_test.go") { dir := path.Dir(p) if _, ok := testDirMap[dir]; !ok { @@ -280,7 +272,7 @@ func (b *builder) unitTest() error { log.Printf("Running unit tests in dirs: %v", testDirs) for _, testDir := range testDirs { // Run unit test - args := []string{gotestsum, "-tags", "protolegacy", "-count", "1", "-race", "-v", "-timeout", "15m"} + args := []string{"gotestsum", "-tags", "protolegacy", "-count", "1", "-race", "-v", "-timeout", "15m"} if *junitFileFlag != "" { args = append(args, "--junitfile", *junitFileFlag+strings.ReplaceAll(testDir, "/", "-")+"unit-test.xml") }