From 1fbf0396fe8f9e13932258c405c5e1d653bf7bd7 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 3 Aug 2021 15:25:20 +1200 Subject: [PATCH] Add linter for when people generate proto files inside the PR (#84) --- .github/workflows/protoc-lint.yml | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/protoc-lint.yml diff --git a/.github/workflows/protoc-lint.yml b/.github/workflows/protoc-lint.yml new file mode 100644 index 0000000..4986205 --- /dev/null +++ b/.github/workflows/protoc-lint.yml @@ -0,0 +1,37 @@ +name: Check protobuf generated files + +on: + pull_request: + paths: + - aioesphomeapi/api_options_pb2.py + - aioesphomeapi/api_pb2.py + +jobs: + protoc-update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Install protoc + run: | + sudo apt-get install protobuf-compiler + - name: Set up Python environment + run: | + pip3 install -e . + pip3 install -r requirements_test.txt + + - name: Generate protoc + run: | + script/gen-protoc + + - name: Check changes + run: | + if ! git diff --quiet; then + echo "You have altered the generated proto files but they do not match what is expected." + echo "Please check your local protobuf-compiler version." + protoc --version + exit 1 + fi