Skip to content

Commit e2542b3

Browse files
authored
cleanup: speed up library generation (#12000)
`generate-libraries.sh` is used to: - drive a CI build to verify the generated libraries and support files are up to date - update the libraries after the googleapis SHA changes - update the libraries after (and during) changes to the generator The first two cases need to run `update_libraries.sh`. The last case is probably the most common case, and the slowest part was running the `update_libraries.sh`. I took the opportunity to make the output more readable when making large updates.
1 parent bdf7cc2 commit e2542b3

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

ci/cloudbuild/builds/generate-libraries.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,25 @@ else
8585
xargs -r -P "$(nproc)" -n 50 -0 sed -i 's/[[:blank:]]\+$//'
8686
fi
8787

88-
if [ -z "${GENERATE_GOLDEN_ONLY}" ]; then
88+
if [[ "${TRIGGER_TYPE:-}" != "manual" ]]; then
8989
io::log_h2 "Updating protobuf lists/deps"
9090
external/googleapis/update_libraries.sh
9191
else
92-
io::log_red "Skipping update of protobuf lists/deps."
92+
io::log_yellow "Skipping update of protobuf lists/deps."
9393
fi
9494

95-
# This build should fail if any generated files differ from what was checked
96-
# in. We only look in the google/ directory so that the build doesn't fail if
97-
# it's run while editing files in generator/...
95+
# This build should fail if any generated files differ from what was checked in.
9896
io::log_h2 "Highlight generated code differences"
99-
git diff --exit-code generator/integration_tests/golden/ google/ ci/
97+
# We use `--compact-summary` because in almost all cases the delta is at
98+
# least hundreds of lines long, and often it is thousands of lines long. The
99+
# summary is all we need in the script. The developer can do specific diffs
100+
# if needed.
101+
#
102+
# We only compare a subset of the directories because we expect changes in
103+
# generator/... (but not in generator/integration_tests/golden) while making
104+
# generator changes.
105+
git diff --exit-code --compact-summary generator/integration_tests/golden/ google/ ci/
100106

101-
io::log_h2 "Highlight new files"
102107
if [[ -n "$(git status --porcelain)" ]]; then
103108
io::log_red "New unmanaged files created by generator"
104109
git status

doc/contributor/howto-guide-update-googleapis-sha.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ git commit -m"chore: update googleapis SHA circa $(date +%Y-%m-%d)" bazel cmake
4242
## Update the generated libraries
4343

4444
```shell
45+
external/googleapis/update_libraries.sh
4546
ci/cloudbuild/build.sh -t generate-libraries-pr
4647
```
4748

0 commit comments

Comments
 (0)