From d7fb7e2d4ae47f749f1a52c8c6d7b996f0e1b233 Mon Sep 17 00:00:00 2001 From: David Cavazos Date: Mon, 23 Dec 2024 17:45:26 -0800 Subject: [PATCH] fix: testing-isolation do not force run all if no packages were found (#3939) * fix: testing-isolation do not force run all if no packages were found * add test case --------- Co-authored-by: Jennifer Davis --- .github/cloud-samples-tools/pkg/config/config.go | 4 ---- .github/cloud-samples-tools/pkg/config/config_test.go | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/cloud-samples-tools/pkg/config/config.go b/.github/cloud-samples-tools/pkg/config/config.go index 879a1c2217..c8e7a22936 100644 --- a/.github/cloud-samples-tools/pkg/config/config.go +++ b/.github/cloud-samples-tools/pkg/config/config.go @@ -177,10 +177,6 @@ func (c *Config) Changed(log io.Writer, diffs []string) []string { changedUnique[pkg] = true } - if len(changedUnique) == 0 { - return []string{"."} - } - changed := make([]string, 0, len(changedUnique)) for pkg := range changedUnique { if slices.Contains(c.ExcludePackages, pkg) { diff --git a/.github/cloud-samples-tools/pkg/config/config_test.go b/.github/cloud-samples-tools/pkg/config/config_test.go index dbe7105be5..a95c5c7e8e 100644 --- a/.github/cloud-samples-tools/pkg/config/config_test.go +++ b/.github/cloud-samples-tools/pkg/config/config_test.go @@ -169,6 +169,7 @@ func TestChanged(t *testing.T) { config := c.Config{ PackageFile: []string{"package.json"}, Match: []string{"*"}, + Ignore: []string{"ignored.txt"}, ExcludePackages: []string{filepath.Join("testdata", "excluded")}, } @@ -180,6 +181,10 @@ func TestChanged(t *testing.T) { diffs: []string{filepath.Join("testdata", "file.txt")}, expected: []string{"."}, }, + { // Ignored files should not trigger tests. + diffs: []string{filepath.Join("testdata", "ignored.txt")}, + expected: []string{}, + }, { // Single affected package. diffs: []string{filepath.Join("testdata", "my-package", "file.txt")}, expected: []string{filepath.Join("testdata", "my-package")},