-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI - check for real if proto-derived files are up to date (#6747)
- Rename check script build-changed-protos --> protos-up-to-date - Excise unused code for getting base revision - Exit with error status if dev_tools/build-protos.sh changes any content - Fail the CI if generated protos are not up to date
- Loading branch information
1 parent
756abe3
commit 3a87b33
Showing
10 changed files
with
422 additions
and
387 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
################################################################################ | ||
# Verifies that Python files generated from protobuf definitions are up to date. | ||
# | ||
# See dev_tools/build-protos.sh for building all protos. | ||
################################################################################ | ||
|
||
# Get the working directory to the repo root. | ||
thisdir="$(dirname "${BASH_SOURCE[0]}")" || exit $? | ||
topdir="$(git -C "${thisdir}" rev-parse --show-toplevel)" || exit $? | ||
cd "${topdir}" || exit $? | ||
|
||
git_status="$(git status --short)" | ||
if [[ -n "${git_status}" ]]; then | ||
echo "$0 requires a pristine worktree, but 'git status' shows" | ||
echo "some changes or untracked files." | ||
echo | ||
echo "Please commit or clean these up to try again." | ||
exit 2 | ||
fi | ||
|
||
echo "Removing generated Python files. If not restored by this script use" | ||
echo 'git restore "*_pb2.py*" to recover them back.' | ||
echo | ||
|
||
git rm --quiet "cirq-google/*_pb2.py*" | ||
# restore deleted files in git index | ||
git reset --quiet | ||
|
||
echo "Building protos in $PWD" | ||
echo | ||
|
||
dev_tools/build-protos.sh | ||
|
||
git_status="$(git status --short)" | ||
|
||
if [[ -n "${git_status}" ]]; then | ||
echo | ||
echo -e "\033[31mERROR: dev_tools/build-protos.sh changed generated files!\033[0m" | ||
echo -e "\033[31mPlease update and commit these files using dev_tools/build-protos.sh\033[0m" | ||
echo | ||
echo "Output of 'git status' (note there may be untracked new files or deleted old ones):" | ||
echo | ||
git status | ||
exit 1 | ||
fi |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.