Skip to content

Commit 0c6cf73

Browse files
committed
Revert "chore: trigger generation on changes to any file"
This reverts commit b6da7c8.
1 parent 0e4e06d commit 0c6cf73

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

.github/scripts/hermetic_library_generation.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#!/bin/bash
22
set -e
33
# This script should be run at the root of the repository.
4-
# This script is used to, when a pull request changes any file in the repo:
5-
# 1. Compare generation configurations in the current branch (with which the
4+
# This script is used to, when a pull request changes the generation
5+
# configuration (generation_config.yaml by default):
6+
# 1. Find whether the last commit in this pull request contains changes to
7+
# the generation configuration and exit early if it doesn't have such a change
8+
# since the generation result would be the same.
9+
# 2. Compare generation configurations in the current branch (with which the
610
# pull request associated) and target branch (into which the pull request is
711
# merged);
8-
# 2. Generate changed libraries using library_generation image;
9-
# 3. Commit the changes to the pull request, if any.
10-
# 4. Edit the PR body with generated pull request description, if applicable.
12+
# 3. Generate changed libraries using library_generation image;
13+
# 4. Commit the changes to the pull request, if any.
14+
# 5. Edit the PR body with generated pull request description, if applicable.
1115

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

6468
git checkout "${target_branch}"
6569
git checkout "${current_branch}"
70+
# if the last commit doesn't contain changes to generation configuration,
71+
# do not generate again as the result will be the same.
72+
change_of_last_commit="$(git diff-tree --no-commit-id --name-only HEAD~1..HEAD -r)"
73+
if [[ ! ("${change_of_last_commit}" == *"${generation_config}"*) ]]; then
74+
echo "The last commit doesn't contain any changes to the generation_config.yaml, skipping the whole generation process." || true
75+
exit 0
76+
fi
6677
# copy generation configuration from target branch to current branch.
6778
git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}"
6879
config_diff=$(diff "${generation_config}" "${baseline_generation_config}" || true)

0 commit comments

Comments
 (0)