-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
chore: add a GitHub Action for generating new clients using the hermetic build scripts #10488
chore: add a GitHub Action for generating new clients using the hermetic build scripts #10488
Conversation
WIP fix #10496 This is unrelated to the work of this PR |
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.
It's interesting that you had to create a new document and a new workflow.
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.
Can we rename this file to something like add-new-client-config.py
?
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.
Done
|
||
client_documentation = f"https://cloud.google.com/java/docs/reference/{distribution_name_short}/latest/overview" | ||
|
||
if library_name is None: |
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 think library_name
is not required and will be default to api_shortname
in our scripts, so we don't have to specify 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.
Makes sense, I removed this.
type: string | ||
description: | | ||
`proto_path`: Path to proto file from the root of the googleapis repository to the | ||
directory that contains the proto files (without the version). |
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.
Why not just use the versioned proto_path? I think it fits better since we can just add it as a GAPIC directly.
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 is to match the existing new-client.py
script. The old one accepts root-level proto_path
s, so a PR with all the released versions get created. See this example PR
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 was initially forcing the user to provide a versioned path until I saw the behavior of the old script
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 don't think we have to follow the same behavior, its a tool that is used only by our own team, if the new behavior means less code and no additional toil, then we should go for 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.
I don't think we have to follow the same behavior, its a tool that is used only by our own team, if the new behavior means less code and no additional toil, then we should go for 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.
Agreed. As discussed, I modified the script to support versioned proto_paths only.
def __is_releasable_version(versioned_proto_path): | ||
"""true if the library definition found in `versioned_proto_path`: | ||
- has a BUILD file | ||
- the BUILD file has a `java_gapic_assembly_gradle_pkg` rule |
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.
Is there any use case that the BUILD file does not have a java_gapic_assembly_gradle_pkg
rule?
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 is the heuristic we determined with @JoeWang1127 to tell if a library version has been released. @JoeWang1127 Would you mind adding a link to some doc or source to validate 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.
For example, https://github.com/googleapis/googleapis/tree/master/google/bigtable/v1 has no BUILD file, but I'm still looking for one that doesn't have a java_gapic_assembly_gradle_pkg
rule.
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.
Here is a search query of a few libraries that do not have the java_gapic_assembly_gradle_pkg
rule.
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 removing this logic in favor of supporting versioned proto_paths only
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 remembered I have seen an example of this, however I can't find it now.
We can ignore this case since we plan to use versioned proto_path.
name: Generate new GAPIC client library (Hermetic Build) | ||
on: | ||
workflow_dispatch: | ||
# some inputs are ommited due to limit of 10 input arguments |
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 know this is an existing limitation of Github actions, but IMO this is a indication that Github action may not be a good fit for new client library generation. Because we are clearly omitting some parameters here, they may not be "required" to generate a new library, but repo_metadata.json
would be missing some info without those parameters.
I think we should find a different way sooner than later, but it would be out of scope for this PR. cc: @suztomo
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.
repo_metadata.json would be missing some info without those parameters.
What are missing?
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.
For example, these four in repo_metadata.json, we might be able to get them heuristically, but if we want to override them, there is no way other than manually adding them.
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.
As we discussed today, the long term solution is to
- Make the PR generation logic more generic so that it can recognize any changes to the generation config
- Trigger the generation process on every generation config change.
- Create a PR(Manually or still use this Github action) that adds a new section for the new client, which should trigger the process above.
CC: @JoeWang1127
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.
Thank you for the example.
manually adding them.
The best way is to automatically get the data from the service config yaml.
return f'java-{library["api_shortname"]}' | ||
|
||
|
||
def __get_proto_paths(proto_path: str, committish: str) -> List[str]: |
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 whole function can go away if we provide versioned proto path, so we have less code to maintain.
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.
Done
generation_config.yaml
Outdated
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 guess this is an unintentional change?
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.
Phew, yes it was. I restored it.
generation_config.yaml
Outdated
@@ -1,6 +1,6 @@ | |||
gapic_generator_version: 2.37.0 | |||
protobuf_version: '25.2' | |||
googleapis_commitish: 6500290663163ba7dc6e0a35231772f5f78c3b62 | |||
googleapis_commitish: e960a82d36e3ddaeb62f549dbd4c300e11e240dc |
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.
It shows as changing but it's the same as the latest:
googleapis_commitish: e960a82d36e3ddaeb62f549dbd4c300e11e240dc |
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.
Can we revert this whole file?
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.
LGTM. Please resolve merge conflict before merging.
This PR enables new client generation using the hermetic build docker image.
It uses a combination of
Why a new workflow and README?
We do have https://github.com/googleapis/google-cloud-java/blob/main/.github/workflows/generate_new_client.yaml already, which relies on the (from now) old generation scripts. We are not replacing this workflow because we want to keep a fall back option in case anything happens while we roll out the hermetic build scripts.
Steps
new_client_hermetic_build/new-client.py
that adds an entry togeneration_config.yaml
with the specified arguments. The arguments are the 10 minimal arguments we find in https://github.com/googleapis/google-cloud-java/blob/main/.github/workflows/generate_new_client.yamla. It will search for all versioned
proto_path
s found in the rootproto_path
. If the givenproto_path
is versioned, the script will fail with a messageDemo PR
diegomarquezp#19
Demo diff - generate
cloudcontrolspartner
with both github actions:I generated the libraries using a more up-to-date
googleapis_committish
We are currently ignoring differences in README and
metadata['repo']
in our ITsnew-library/cloudcontrolspartner-EvjMm
comes from the old generation workflownew-library/cloudcontrolspartner-56m5l
comes from the hermetic build generation