Skip to content

Commit

Permalink
CI check for uncommitted generated proto files (#3159)
Browse files Browse the repository at this point in the history
  • Loading branch information
balopat authored Jul 21, 2020
1 parent 4bf14c1 commit a16824f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion check/build-changed-protos
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ changed=$(git diff --name-only ${rev} -- \
| sed -e "s/\.proto$//"
)
if [[ ! -z "$changed" ]]; then
for base in $changed:
for base in $changed
do
echo -e "Found changed proto: '${base}.proto'"
done
Expand Down Expand Up @@ -94,6 +94,19 @@ do
(set -x; bazel build "${base}_proto"; \
bazel build "${base}_py_proto"; \
bazel build "${base}_cc_proto")

python -m grpc_tools.protoc -I=. --python_out=. --mypy_out=. ${base}.proto
done

# Filenames with spaces will be ugly (each part will be listed separately)
# but the error logic will still work.
untracked=$(git status --porcelain 2>/dev/null | grep "^?? cirq/google" | cut -d " " -f 2)

if [[ ! -z "$untracked" ]]; then
echo -e "\033[31mERROR: Uncommitted generated files found! Please generate and commit these files:\033[0m"
for generated in $untracked
do
echo -e "\033[31m ${generated}\033[0m"
done
exit 1
fi

0 comments on commit a16824f

Please sign in to comment.