Skip to content

Commit fa7c808

Browse files
authored
chore: re-generate when config or Dockerfile is changed (#3146)
In this PR: - Re-generate common protos and iam if generation config or Dockerfile is changed. I use #3145 to verify the change.
1 parent 4cc72ad commit fa7c808

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

.github/scripts/hermetic_library_generation.sh

+5-14
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,17 @@ fi
6464

6565
image_tag=local
6666
workspace_name="/workspace"
67-
baseline_generation_config="baseline_generation_config.yaml"
6867
docker_file="library_generation.Dockerfile"
6968
message="chore: generate libraries at $(date)"
7069

71-
git checkout "${target_branch}"
7270
git checkout "${current_branch}"
73-
# if the last commit doesn't contain changes to generation configuration,
74-
# do not generate again as the result will be the same.
71+
# if the last commit doesn't contain changes to generation configuration
72+
# or Dockerfile, do not generate again as the result will be the same.
7573
change_of_last_commit="$(git diff-tree --no-commit-id --name-only HEAD~1..HEAD -r)"
7674
if [[ ! ("${change_of_last_commit}" == *"${generation_config}"* || "${change_of_last_commit}" == *"${docker_file}"*) ]]; then
7775
echo "The last commit doesn't contain any changes to the generation_config.yaml or Dockerfile, skipping the whole generation process." || true
7876
exit 0
7977
fi
80-
# copy generation configuration from target branch to current branch.
81-
git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}"
82-
config_diff=$(diff "${generation_config}" "${baseline_generation_config}" || true)
8378

8479
generator_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -pl gapic-generator-java)
8580
echo "Local generator version: ${generator_version}"
@@ -99,22 +94,18 @@ docker run \
9994
-v "$(pwd):${workspace_name}" \
10095
-v "$HOME"/.m2:/home/.m2 \
10196
-e GENERATOR_VERSION="${generator_version}" \
102-
gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \
103-
--baseline-generation-config-path="${workspace_name}/${baseline_generation_config}" \
104-
--current-generation-config-path="${workspace_name}/${generation_config}"
97+
gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}"
10598

10699
# commit the change to the pull request.
107-
rm -rdf output googleapis "${baseline_generation_config}"
100+
rm -rdf output googleapis
108101
git add --all -- ':!pr_description.txt'
109102
changed_files=$(git diff --cached --name-only)
110103
if [[ "${changed_files}" == "" ]]; then
111-
echo "There is no generated code change with the generation config and Dockerfile change ${config_diff}."
104+
echo "There is no generated code change."
112105
echo "Skip committing to the pull request."
113106
exit 0
114107
fi
115108

116-
echo "Configuration diff:"
117-
echo "${config_diff}"
118109
git commit -m "${message}"
119110
git push
120111
# set pr body if pr_description.txt is generated.

0 commit comments

Comments
 (0)