-
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: update hermetic library generation workflow #10693
Conversation
The workflows are tests in a forked repo: |
shell: bash | ||
run: | | ||
diff generation_config.yaml baseline/generation_config.yaml | ||
git show ${{ github.base_ref }}:generation_config.yaml > baseline_generation_config.yaml | ||
- name: show configuration diff |
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 extract most of the logics here to a shell script so that we can call the script directly here? That way we can easily call it in local and possibly in a non-Github environment in the future.
Ideally, we should try to put this logic into Docker container as well, so that this logic could be reused by handwritten libraries, otherwise we would need to duplicate this in every handwritten repos. Bake it into Docker can be a future enhancement, but I think we should at least extract it to a separate 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.
Moved command lines to a script.
base_branch: main | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup branch for pull request |
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.
Same comment as above. Let's extract it to a script for now, and think about ways to make it more reusable.
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.
Moved command lines to a script.
Should we remove "Verify GAPIC client library generation" or rewrite it using hermetic build 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.
LGTM, just a couple nits and a question
@@ -1,7 +1,7 @@ | |||
name: Generate new GAPIC client library (Hermetic Build) | |||
on: | |||
workflow_dispatch: | |||
# some inputs are ommited due to limit of 10 input arguments | |||
# some inputs are emitted 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.
nit: ommited
should be omitted
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.
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.
nit (maybe not in scope): What's the purpose of this script? Maybe a one-liner comment can help.
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.
There's a one-liner comment in each job in the workflow.
message="chore: generate libraries at $(date)" | ||
|
||
git checkout "${target_branch}" | ||
git checkout "${current_branch}" |
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.
qq: Has this double checkout
statement a special effect?
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.
In the action, the fetch-depth is 0 so it needs git checkout "${target_branch}"
to load target_branch.
We want to copy generation_config.yaml
from target branch to current branch.
jobs: | ||
library_generation: | ||
runs-on: ubuntu-latest | ||
env: | ||
library_generation_image_tag: latest | ||
repo_volumes: "-v repo-google-cloud-java:/workspace/google-cloud-java" | ||
library_generation_image_tag: 2.39.0 |
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 this configured to be updated renovate bot?
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 plan to update renovate config in separate PR.
@@ -20,7 +20,7 @@ on: | |||
pull_request: | |||
name: generation diff | |||
env: | |||
library_generation_image_tag: latest | |||
library_generation_image_tag: 2.39.0 |
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 this configured to be updated renovate bot?
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 plan to update renovate config in separate PR.
# copy generation configuration from target branch to current branch. | ||
git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}" | ||
diff "${generation_config}" "${baseline_generation_config}" || echo "config diff" | ||
# bind docker volume to include google-cloud-java in docker running environment. |
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 script is not specific to google-cloud-java
anymore, can we mention something more generic?
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.
paths: | ||
- generation_config.yaml | ||
- "generation_config.yaml" |
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 the trigger only for main branch? If yes, can this be configured to be triggered for other branches, like a future LTS branch?
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 can be triggered when a pull request changes generation_config.yaml
.
Therefore, it can be used in any branch since the pull request is not necessarily based on main
.
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 see any configuration for a target branch, does it mean if I create a PR with generation_config.yaml
changes against a release/2.x
branch, this workflow would be triggered too?
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.
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.
Really like this script! This script is generic enough to be reused by any repo. We need to come up with a way to reused this script, but worst case we can just copy this script to every handwritten repos.
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 you remind me what this file is used for?
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 workflow is used to verify generated files, e.g., owlbot.py
, are not modified by pull request. Each job verifies one 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.
What if we do want to update owlbot.py
for a certain library? Also does it mean we run the generation for the whole repo on every 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.
What if we do want to update owlbot.py for a certain library?
The check will fail. This is a not required check only to remain the author the change is indeed intentional.
Also does it mean we run the generation for the whole repo on every PR?
root pom and gapic-libraries-bom are generated through hermetic build cli script (just like repo-level post processing). Other checks are done through shell script in this repo, which are not generating any java file, so they are relatively fast.
runs-on: ubuntu-22.04 | ||
env: | ||
# the branch into which the pull request is merged | ||
base_branch: lts-11 |
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 this lts-11
intentional?
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.
No, this is a test value. I changed it to main
.
I think we can remove it as the logic of "new client generation" is part of the hermetic build scripts now. |
I'll remove this check in another 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.
LGTM. Please update the PR title to make it more meaningful before merging, and update relevant docs after merging.
In this PR:
generation_config.yaml
is changed in a pull request, to generate changed libraries and push commits to the corresponding pull request.generation_config.yaml
.2.39.0
Follow up of googleapis/sdk-platform-java#2616
For the goal of series of PRs, please refer to improvement proposal.