-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: test-isolation package setup configs #3951
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
Conversation
There was a problem hiding this 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 in a few minutes. In the meantime, here's a quick summary for you and other reviewers to get up to speed:
This pull request, authored by davidcavazos, aims to improve test isolation by introducing package setup configuration files. These configuration files allow packages to specify per-package settings such as secrets, environment variables, and runtime versions.
Here's a breakdown of the changes:
config.go
: This file has been significantly modified to support loading and handling of these new setup configuration files. Specifically:- Lines 24-29: Removed the
regexp
import, simplifying the code. - Lines 32-43: Added a
Setup
struct within theConfig
struct to handle the setup file's filename and default values. - Lines 48-57: Added a
Package
struct to represent a package with its path and setup configurations. - Lines 71-79: Simplified the
LoadConfig
function by using a helper function to read JSONC files. - Lines 156-185: The
Affected
function was updated to return an array ofPackage
structs, including the setup configurations.
- Lines 24-29: Removed the
utils.go
: A new helper functionReadJsonc
was added (lines 29-40) to handle reading and parsing JSONC files, simplifying the main config loading logic..github/config/nodejs-dev.jsonc
and.github/config/nodejs-prod.jsonc
: These configuration files were updated to include the newsetup
section, specifying asetup.json
file and default values..github/workflows/ci-dev.yaml
: This file was updated (lines 70-81) to use thegoogle-github-actions/get-secretmanager-secrets@v2
action to retrieve secrets defined in thesetup.json
files.generative-ai/snippets/setup.json
: A samplesetup.json
file was added, demonstrating how to define secrets and Node.js version.
Several files also had lines removed related to the previous comment handling logic, which is now handled by the new ReadJsonc
function. The functions/http/uploadFile
sample was also removed from the ignore list in the production config file.
I'll provide a more detailed review shortly. In the meantime, please let me know if you have any questions.
And now, a little haiku to brighten your day:
Tests run, green light shows,
Configs now make setup smooth,
Code flows, clean and bright.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request introduces support for per-package setup configuration files, which is a valuable addition. The implementation looks good overall, but there are a few points to address regarding consistency, error handling, and best practices.
…ples into test-isolation-configs
…ples into test-isolation-configs
8389be9
to
37befa1
Compare
37befa1
to
9372772
Compare
…ples into test-isolation-configs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very high level review without running it myself, but overall LGTM.
@@ -29,8 +29,8 @@ import ( | |||
var usage = `usage: tools <command> ... | |||
|
|||
commands: | |||
affected path/to/config.jsonc path/to/diffs.txt | |||
run-all path/to/config.jsonc path/to/script.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double-checking... looks like run-all didn't exist before this PR? (context: didn't see "run-all" in the switch command {
section.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, run-all came from another experiment that was removed, but forgot to update this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only nits. Looks good!
|
||
var config Config | ||
err = json.Unmarshal(sourceJson, &config) | ||
// This mutates `config` so there's no need to reassign it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: I love the comments here that help me interpret what the code is doing.
Description
Supports package setup configuration files. These allow packages to provide per-package configurations like secrets, environment variables, and the runtime version. Additionally, there are some minor refactors to the existing code, just for better organization, but not changing functionality.
Default values are defined at the config file. The CI setup file is optional where each package can opt-in to custom values. The file lives within the same package directory, so there's no need for contributors to edit the workflows or any of the testing infrastructure.
This file is language agnostic, and it can contain any values, so different workflows or languages could configure them differently.
For this PR, we're also enabling
generative-ai
tests, which need secrets to run.Checklist
npm test
(see Testing)npm run lint
(see Style)GoogleCloudPlatform/nodejs-docs-samples
. Not a fork.