Skip to content

[go_tests] Deduplicate runs per module#70

Merged
Nikolay1224 merged 1 commit into
mainfrom
fix/go-tests-dedup
Apr 23, 2026
Merged

[go_tests] Deduplicate runs per module#70
Nikolay1224 merged 1 commit into
mainfrom
fix/go-tests-dedup

Conversation

@duckhawk
Copy link
Copy Markdown
Member

Summary

The go_tests action previously iterated over every *_test.go file under images/ and ran go test in the enclosing directory without specifying a package or file. For a package with N test files and M build tags, this produced N*M runs of the same package instead of M.

This PR switches the outer loop to iterate over go.mod files (one per Go module) and runs go test ./... -tags <tag> once per module per build tag. The pattern matches what is already used in the sibling actions:

  • go_linter
  • go_modules_check
  • go_test_coverage

Additional small improvements:

  • restore the working directory between modules (use cd "$basedir" instead of letting it drift),
  • use dirname instead of a fragile sed regex on the file name,
  • quote variables and use [ "$failed" = 'true' ] for portability.

The same fix has already been applied to the v12 branch.

Test plan

  • Trigger the go_tests action in a downstream module repository.
  • Confirm in the job log that each Go module is tested once per build tag (no more duplicate runs per test file).
  • Verify failing tests still cause the action to exit with non-zero status.

Previously the action iterated over every `*_test.go` file under
`images/` and ran `go test` in the enclosing directory without
specifying a package or file. For a package with N test files and M
build tags this produced N*M runs of the same package instead of M.

Switch the outer loop to iterate over `go.mod` files (one per Go
module) and run `go test ./... -tags <tag>` once per module per
build tag. This matches the iteration pattern already used in
`go_linter`, `go_modules_check`, and `go_test_coverage` actions.

Also restore the working directory between modules and use a safer
quoted equality check on `$failed`.

Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
@duckhawk duckhawk requested a review from Nikolay1224 as a code owner April 23, 2026 07:36
@Nikolay1224 Nikolay1224 merged commit 7278df2 into main Apr 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants