From 5376618a13a73978c073929c32091eafdf5d6d2c Mon Sep 17 00:00:00 2001 From: "ilya.kuznetsov" Date: Wed, 11 Nov 2026 13:05:48 +0000 Subject: [PATCH] Skip tests in testmask for CODEOWNERS-only changes Co-authored-by: Isaac --- tools/testmask/targets.go | 14 +++++++++++++- tools/testmask/targets_test.go | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) 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 {