diff --git a/tools/testmask/targets.go b/tools/testmask/targets.go index bb0dcbfe1bf..4c00c55780b 100644 --- a/tools/testmask/targets.go +++ b/tools/testmask/targets.go @@ -29,6 +29,11 @@ var commonTriggerPatterns = []string{ "tools/task/", } +// ignoredFiles lists files that never affect test results. +var ignoredFiles = []string{ + ".github/CODEOWNERS", +} + type targetMapping struct { prefixes []string target string @@ -107,6 +112,10 @@ func GetTargets(files []string, mappings []targetMapping) []string { unmatchedFiles := []string{} for _, file := range files { + if slices.Contains(ignoredFiles, file) { + continue + } + matched := false for _, mapping := range mappings { for _, prefix := range mapping.prefixes { @@ -127,7 +136,10 @@ func GetTargets(files []string, mappings []targetMapping) []string { } if len(targetSet) == 0 { - return []string{"test"} + if len(files) == 0 { + return []string{"test"} + } + return []string{} } return slices.Sorted(maps.Keys(targetSet)) diff --git a/tools/testmask/targets_test.go b/tools/testmask/targets_test.go index b2b058fc59d..fdb14212bd5 100644 --- a/tools/testmask/targets_test.go +++ b/tools/testmask/targets_test.go @@ -88,6 +88,21 @@ func TestGetTargets(t *testing.T) { files: []string{}, targets: []string{"test"}, }, + { + name: "codeowners_only", + files: []string{ + ".github/CODEOWNERS", + }, + targets: []string{}, + }, + { + name: "codeowners_with_other_files", + files: []string{ + ".github/CODEOWNERS", + "bundle/config.go", + }, + targets: []string{"test"}, + }, } for _, tt := range tests {