Skip to content

fix(codegen): modify generator scripts after separation of bazel rules - #1351

Merged
emmileaf merged 4 commits into
mainfrom
codegen-bazel-split
Nov 21, 2022
Merged

fix(codegen): modify generator scripts after separation of bazel rules#1351
emmileaf merged 4 commits into
mainfrom
codegen-bazel-split

Conversation

@emmileaf

@emmileaf emmileaf commented Nov 21, 2022

Copy link
Copy Markdown
Contributor

This PR: edits generator scripts given the separation of the java_gapic_spring_library rule in googleapis/sdk-platform-java#1065 (please see its description for context of edits).

The script now makes local edits to:

  • googleapis/repository_rules.bzl (add switch)
  • google/cloud/<client_lib_name>/v1/BUILD.bazel (add rule name to load, and rule definition using similar arguments as java_gapic_library)

Note for review: the initial goal of these changes is to have something to unblock the code generation workflow, but there's currently a lot of perl mess so any suggestions on cleaner/more reliable file processing would be welcomed!

@zhumin8 zhumin8 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree on unblocking the generation workflow. So we could probably merge this in while working on improvements.
On making it more robust, I found this buildozer tool that looks neat. E.g. these two commands can achieve most of what we want building the java_gapic_spring_library rule.

# Add a new rule at the end of the file
buildozer 'new java_library foo' //pkg:__pkg__

# Copy an attribute from `protolib` to `py_protolib`.
buildozer 'copy testonly protolib' //pkg:py_protolib

Drawback is that it has dependencies on Go. But GithubAction does have https://github.com/actions/setup-go, so I guess it's not that bad.

@emmileaf

emmileaf commented Nov 21, 2022

Copy link
Copy Markdown
Contributor Author

On making it more robust, I found this buildozer tool that looks neat. E.g. these two commands can achieve most of what we want building the java_gapic_spring_library rule.

Oh buildozer does look like a better tool for handling BUILD.bazel file changes (esp. copying over attributes) - thanks for the suggestion @zhumin8 ! I’ll look into how to bring it in for our workflow, and will mark this PR as ready for review in the meanwhile.

@emmileaf
emmileaf marked this pull request as ready for review November 21, 2022 16:25
Comment thread generator/generate-one.sh Outdated

@diegomarquezp diegomarquezp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@emmileaf
emmileaf merged commit 631a1af into main Nov 21, 2022
@emmileaf
emmileaf deleted the codegen-bazel-split branch November 21, 2022 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants