Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI - check for real if proto-derived files are up to date #6747

Merged
merged 10 commits into from
Sep 27, 2024
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ jobs:
run: |
pip install -r dev_tools/requirements/deps/protos.txt
- name: Build protos
run: check/build-changed-protos
run: check/protos-up-to-date
coverage:
name: Coverage check
runs-on: ubuntu-20.04
Expand Down
74 changes: 0 additions & 74 deletions check/build-changed-protos

This file was deleted.

47 changes: 47 additions & 0 deletions check/protos-up-to-date
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
70 changes: 40 additions & 30 deletions cirq-google/cirq_google/api/v1/operations_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading