Diff generated code from proto files (#4863)

Add a static check that ensures the generated files from the proto definitions have not changed. 

Fix #4669

Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
This commit is contained in:
Zahari Dichev 2020-08-18 11:44:33 +03:00 committed by GitHub
parent ac2bfb387b
commit 2e7c00aa37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -30,6 +30,17 @@ jobs:
uses: actions/checkout@722adc6 uses: actions/checkout@722adc6
- name: Format - name: Format
run: bin/fmt run: bin/fmt
proto_diff:
name: Proto diff
runs-on: ubuntu-18.04
container:
image: golang:1.13.4
steps:
- name: Checkout code
# actions/checkout@v2
uses: actions/checkout@722adc6
- name: Diff proto files
run: bin/protoc-diff
shellcheck: shellcheck:
name: shellcheck name: shellcheck
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04

22
bin/protoc-diff Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env sh
set -eu
# Install unzip if not already installed (Linux only)
system=$(uname -s)
if [ "$system" = Linux ] && ! [ -x "$(command -v unzip)" ]; then
apt-get update
apt-get install unzip
fi
bin/protoc-go.sh
dir_dirty=$(git diff HEAD)
if [ -z "$dir_dirty" ]; then
echo "Protobuf definitions match generated code"
exit 0
else
echo "Protobuf definitions diverge from generated code:"
echo "$(git status)"
exit 64
fi