Skip to content

Commit

Permalink
chore: trigger generation on PRs affecting any file
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp committed Jul 18, 2024
1 parent e5a0e18 commit 62b92b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
22 changes: 5 additions & 17 deletions .github/scripts/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#!/bin/bash
set -e
# This script should be run at the root of the repository.
# This script is used to, when a pull request changes the generation
# configuration (generation_config.yaml by default):
# 1. Find whether the last commit in this pull request contains changes to
# the generation configuration and exit early if it doesn't have such a change
# since the generation result would be the same.
# 2. Compare generation configurations in the current branch (with which the
# This script is used to, when a pull request changes any file in the repo:
# 1. Compare generation configurations in the current branch (with which the
# pull request associated) and target branch (into which the pull request is
# merged);
# 3. Generate changed libraries using library_generation image;
# 4. Commit the changes to the pull request, if any.
# 5. Edit the PR body with generated pull request description, if applicable.
# 2. Generate changed libraries using library_generation image;
# 3. Commit the changes to the pull request, if any.
# 4. Edit the PR body with generated pull request description, if applicable.

# The following commands need to be installed before running the script:
# 1. git
Expand Down Expand Up @@ -67,13 +63,6 @@ message="chore: generate libraries at $(date)"

git checkout "${target_branch}"
git checkout "${current_branch}"
# if the last commit doesn't contain changes to generation configuration,
# do not generate again as the result will be the same.
change_of_last_commit="$(git diff-tree --no-commit-id --name-only HEAD~1..HEAD -r)"
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)
Expand All @@ -87,7 +76,6 @@ docker run \
-u "$(id -u):$(id -g)" \
-v "$(pwd):${workspace_name}" \
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}"


Expand Down
4 changes: 2 additions & 2 deletions generation_config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
gapic_generator_version: 2.42.0
googleapis_commitish: 19577edb4d439db98d2fb1f6f48f2e1b29fba099
libraries_bom_version: 26.43.0
googleapis_commitish: 6f289d775912966eb0cf04bda91e5e355c998d30
libraries_bom_version: 26.38.0
libraries:
- api_shortname: firestore
name_pretty: Cloud Firestore
Expand Down

0 comments on commit 62b92b8

Please sign in to comment.