-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: update hermetic build workflow #11114
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 all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,14 +17,11 @@ set -e | |
| # 1. git | ||
| # 2. gh | ||
| # 3. docker | ||
| # 4. mvn | ||
|
|
||
| # The parameters of this script is: | ||
| # 1. target_branch, the branch into which the pull request is merged. | ||
| # 2. current_branch, the branch with which the pull request is associated. | ||
| # 3. [optional] image_tag, the tag of gcr.io/cloud-devrel-public-resources/java-library-generation. | ||
| # The value will be parsed from the generation configuration if not specified. | ||
| # 4. [optional] generation_config, the path to the generation configuration, | ||
| # 3. [optional] generation_config, the path to the generation configuration, | ||
| # the default value is generation_config.yaml in the repository root. | ||
| while [[ $# -gt 0 ]]; do | ||
| key="$1" | ||
|
|
@@ -37,10 +34,6 @@ case "${key}" in | |
| current_branch="$2" | ||
| shift | ||
| ;; | ||
| --image_tag) | ||
| image_tag="$2" | ||
| shift | ||
| ;; | ||
| --generation_config) | ||
| generation_config="$2" | ||
| shift | ||
|
|
@@ -54,22 +47,18 @@ shift | |
| done | ||
|
|
||
| if [ -z "${target_branch}" ]; then | ||
| echo "missing required argument --target_branch" | ||
| echo "Missing required argument --target_branch" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "${current_branch}" ]; then | ||
| echo "missing required argument --current_branch" | ||
| echo "Missing required argument --current_branch" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "${generation_config}" ]; then | ||
| generation_config=generation_config.yaml | ||
| echo "Use default generation config: ${generation_config}" | ||
| fi | ||
|
|
||
| if [ -z "${image_tag}" ]; then | ||
| image_tag=$(grep "gapic_generator_version" "${generation_config}" | cut -d ':' -f 2 | xargs) | ||
| echo "Using default generation config: ${generation_config}" | ||
| fi | ||
|
|
||
| workspace_name="/workspace" | ||
|
|
@@ -85,10 +74,14 @@ if [[ ! ("${change_of_last_commit}" == *"${generation_config}"*) ]]; then | |
| echo "The last commit doesn't contain any changes to the generation_config.yaml, skipping the whole generation process." || true | ||
| exit 0 | ||
| fi | ||
|
|
||
| # copy generation configuration from target branch to current branch. | ||
| git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}" | ||
| config_diff=$(diff "${generation_config}" "${baseline_generation_config}" || true) | ||
|
|
||
| # parse image tag from the generation configuration. | ||
| image_tag=$(grep "gapic_generator_version" "${generation_config}" | cut -d ':' -f 2 | xargs) | ||
|
|
||
| # get .m2 folder so it's mapped into the docker container | ||
| m2_folder=$(dirname "$(mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout)") | ||
|
|
||
|
|
@@ -101,8 +94,15 @@ docker run \ | |
| gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \ | ||
| --baseline-generation-config-path="${workspace_name}/${baseline_generation_config}" \ | ||
| --current-generation-config-path="${workspace_name}/${generation_config}" | ||
|
|
||
| # commit the change to the pull request. | ||
| git add java-* pom.xml gapic-libraries-bom/pom.xml versions.txt | ||
| if [[ $(basename "$(pwd)") == "google-cloud-java" ]]; then | ||
|
Contributor
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. Do we have to differentiate between google-cloud-java and java-* repos? Can we just do |
||
| git add java-* pom.xml gapic-libraries-bom/pom.xml versions.txt | ||
| else | ||
| # The image leaves intermediate folders and files it works with. Here we remove them | ||
| rm -rdf output googleapis "${baseline_generation_config}" | ||
| git add --all -- ':!pr_description.txt' | ||
| fi | ||
| changed_files=$(git diff --cached --name-only) | ||
| if [[ "${changed_files}" == "" ]]; then | ||
| echo "There is no generated code change with the generation config change ${config_diff}." | ||
|
|
@@ -118,4 +118,4 @@ git push | |
| if [[ -f "pr_description.txt" ]]; then | ||
| pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number") | ||
| gh pr edit "${pr_num}" --body "$(cat pr_description.txt)" | ||
| fi | ||
| fi | ||
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
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.
Can we keep the image tag as a parameter? In long term, we do want to pass it in and remove the generator version from the 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.
Sorry I missed this comment. I'll create a follow up.