Skip to content

fix: testing-isolation excluded packages #3935

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

Merged
merged 1 commit into from
Dec 12, 2024
Merged

Conversation

davidcavazos
Copy link
Contributor

Description

Excluded packages were filtered before checking for global changes. If a package was excluded, then it looked like no packages were found so it was marked as a global change, affecting all packages.

Moving the excluded filtering after checking if a package were found solves this. Also added additional logging, more comments, and a unit test covering this case.

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

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Dec 12, 2024
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Hi @davidcavazos and reviewers,

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

This PR fixes an issue where excluded packages were incorrectly marked as global changes affecting all packages. The root cause was that the exclusion filtering happened before checking for global changes. This PR moves the exclusion filtering to occur after the global change check. Additionally, the PR includes improved logging, added comments for better readability, and a new unit test to cover this specific scenario. The changes primarily affect the following files:

  • .github/cloud-samples-tools/cmd/main.go: Added logging to stderr.
  • .github/cloud-samples-tools/pkg/config/config.go: Modified the Affected and Changed functions to handle package exclusion correctly and added logging.
  • .github/cloud-samples-tools/pkg/config/config_test.go: Added a new test case to verify the fix for excluded packages.

The intent is to ensure that the testing isolation mechanism correctly identifies and handles excluded packages, preventing unintended global changes.


And now, a little haiku to lighten the mood:

Tests run, bugs take flight,
Code reviewed, peace takes hold,
Ship it, joy abounds.

Thanks!

@ghost
Copy link

ghost commented Dec 12, 2024

Gemini encountered an error creating the review. You can try again by commenting @code-review-assist review.

@davidcavazos
Copy link
Contributor Author

@code-review-assist review

@davidcavazos davidcavazos marked this pull request as ready for review December 12, 2024 21:15
@davidcavazos davidcavazos requested review from a team as code owners December 12, 2024 21:15
@ghost
Copy link

ghost commented Dec 12, 2024

Gemini encountered an error creating the review. You can try again by commenting @code-review-assist review.

@grayside
Copy link
Collaborator

I had to read the summary a couple times, to restate:

  • Package A is detected as having a change
  • Package A is flagged as excluded, as in, do not consider it a package

Before this PR

The change is attributed as a global change, requiring testing everything

After this Change

The changed code is ignored for purposes of detecting the need to run tests.

@davidcavazos davidcavazos merged commit 22a46bd into main Dec 12, 2024
135 checks passed
@davidcavazos davidcavazos deleted the test-isolation-excluded branch December 12, 2024 23:09
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