-
Notifications
You must be signed in to change notification settings - Fork 68
feat: add a CLI tool to validate generation configuration #2691
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
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
26d4888
feat: validate generation config
JoeWang1127 58c05eb
add unit tests
JoeWang1127 8130ead
fix unit tests
JoeWang1127 a3652b3
change err message
JoeWang1127 8b0b8e1
refactor unit tests
JoeWang1127 1674469
Merge branch 'main' into feat/add-config-check
JoeWang1127 8aac838
specify level
JoeWang1127 f2dc50f
add gapic level
JoeWang1127 1cd4b95
test library dict in error message
JoeWang1127 8dca4ed
refactor
JoeWang1127 bd53ac4
Merge branch 'main' into feat/add-config-check
JoeWang1127 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
..._generation/test/resources/test-config/generation_config_with_duplicate_library_name.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| gapic_generator_version: 2.34.0 | ||
| protoc_version: 25.2 | ||
| googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026 | ||
| libraries_bom_version: 26.37.0 | ||
| owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409 | ||
| synthtool_commitish: 6612ab8f3afcd5e292aecd647f0fa68812c9f5b5 | ||
| template_excludes: | ||
| - ".github/*" | ||
| - ".kokoro/*" | ||
| - "samples/*" | ||
| - "CODE_OF_CONDUCT.md" | ||
| - "CONTRIBUTING.md" | ||
| - "LICENSE" | ||
| - "SECURITY.md" | ||
| - "java.header" | ||
| - "license-checks.xml" | ||
| - "renovate.json" | ||
| - ".gitignore" | ||
| libraries: | ||
| - api_shortname: cloudasset | ||
| name_pretty: Cloud Asset | ||
| product_documentation: "https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview" | ||
| api_description: "provides inventory services based on a time series database." | ||
| library_name: "asset" | ||
| client_documentation: "https://cloud.google.com/java/docs/reference/google-cloud-asset/latest/overview" | ||
| distribution_name: "com.google.cloud:google-cloud-asset" | ||
| release_level: "stable" | ||
| issue_tracker: "https://issuetracker.google.com/issues/new?component=187210&template=0" | ||
| api_reference: "https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview" | ||
| codeowner_team: "@googleapis/analytics-dpe" | ||
| excluded_poms: proto-google-iam-v1-bom,google-iam-policy,proto-google-iam-v1 | ||
| excluded_dependencies: google-iam-policy | ||
| GAPICs: | ||
| - proto_path: google/cloud/asset/v1 | ||
| - proto_path: google/cloud/asset/v1p1beta1 | ||
| - proto_path: google/cloud/asset/v1p2beta1 | ||
| - proto_path: google/cloud/asset/v1p5beta1 | ||
| - proto_path: google/cloud/asset/v1p7beta1 | ||
|
|
||
| - api_shortname: another-cloudasset | ||
| name_pretty: Cloud Asset Inventory | ||
| product_documentation: "https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview" | ||
| api_description: "provides inventory services based on a time series database." | ||
| library_name: "asset" | ||
| client_documentation: "https://cloud.google.com/java/docs/reference/google-cloud-asset/latest/overview" | ||
| distribution_name: "com.google.cloud:google-cloud-asset" | ||
| release_level: "stable" | ||
| issue_tracker: "https://issuetracker.google.com/issues/new?component=187210&template=0" | ||
| api_reference: "https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview" | ||
| GAPICs: | ||
| - proto_path: google/cloud/asset/v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,10 +130,6 @@ def prepare_repo( | |
| # use absolute path because docker requires absolute path | ||
| # in volume name. | ||
| absolute_library_path = str(Path(library_path).resolve()) | ||
| if absolute_library_path in libraries: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this check because the Generation object is validated when reaches this point. |
||
| # check whether the java_library is unique among all libraries | ||
| # because two libraries should not go to the same destination. | ||
| raise ValueError(f"{absolute_library_path} already exists.") | ||
| libraries[absolute_library_path] = library | ||
| # remove existing .repo-metadata.json | ||
| json_name = ".repo-metadata.json" | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm still not a fan of parameterized tests, but I know this test was pre-existing, and in this case, the name of test yamls are kind of self-explanatory, so it's fine.
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.
I replaced this parameterized test to several individual tests.