Skip to content

Commit

Permalink
Merge branch 'main' into cirq_google-restore-api.v2-protos
Browse files Browse the repository at this point in the history
  • Loading branch information
pavoljuhas committed Sep 27, 2024
2 parents daea49a + 3a87b33 commit b5cebd3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 75 deletions.
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

0 comments on commit b5cebd3

Please sign in to comment.