[go_tests] Deduplicate runs per module#70
Merged
Conversation
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>
Nikolay1224
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
go_testsaction previously iterated over every*_test.gofile underimages/and rango testin 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.modfiles (one per Go module) and runsgo test ./... -tags <tag>once per module per build tag. The pattern matches what is already used in the sibling actions:go_lintergo_modules_checkgo_test_coverageAdditional small improvements:
cd "$basedir"instead of letting it drift),dirnameinstead of a fragilesedregex on the file name,[ "$failed" = 'true' ]for portability.The same fix has already been applied to the
v12branch.Test plan
go_testsaction in a downstream module repository.