Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: testing-isolation do not force run all if no packages were found #3939

Merged
merged 3 commits into from
Dec 24, 2024

Conversation

davidcavazos
Copy link
Contributor

Description

Currently, if all diff files are in the ignore list, it's considered as a global change. This is not necessary since a non-ignored file will return the "." package, which will correctly trigger all tests. If no packages were found that's because files should be ignored and no tests should be run. Added a test case to cover this.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi team,

I'm currently reviewing this pull request and will have a full review ready in a few minutes. In the meantime, here's a quick summary to get everyone up to speed:

This pull request addresses an issue where the testing isolation mechanism incorrectly forced the execution of all tests even when no packages were found. The core change is to prevent this behavior. The intent is to improve the efficiency of the testing process by avoiding unnecessary test runs when no relevant changes are detected.

Here's a breakdown of the changes:

  • File Changed: .github/cloud-samples-tools/pkg/config/config.go
  • Change Summary: Removed the logic that returned "." (all packages) when no changed packages were found. This prevents unnecessary test runs when all changes are ignored. Lines 180-182 were removed.

The updated logic ensures that if no packages are identified as changed, no tests are run, leading to a more efficient and targeted testing process.


And now, a little haiku to lighten the mood:

Tests run swift and true,
No need for all, just the changed,
Efficiency reigns.

Thanks,
Gemini

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Dec 21, 2024
@davidcavazos davidcavazos marked this pull request as ready for review December 21, 2024 15:31
@davidcavazos davidcavazos requested review from a team as code owners December 21, 2024 15:31
Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request fixes an issue where a global change was triggered even when all diff files were ignored. The fix correctly identifies that if no packages are found, it's because the files should be ignored, and therefore no tests should run. This change improves the accuracy of the test runner and prevents unnecessary test executions. The added test case is a good addition and covers the new behavior. I've summarized the style guide elements I referenced below.

Referenced Style Guide Elements:

  • General: Encouraged adding comments to explain the logic behind returning an empty slice. While the code is relatively straightforward, a brief comment can enhance understanding, especially for new contributors.
  • Go Style Guide: Comments should be clear and concise, explaining the why behind the code, not just the what.

@davidcavazos davidcavazos merged commit d7fb7e2 into main Dec 24, 2024
13 checks passed
@davidcavazos davidcavazos deleted the testing-isolation-ignorefiles branch December 24, 2024 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants