github.com/Finschia/ostracon@v1.1.5/.github/workflows/check-generated.yml (about) 1 # Verify that generated code is up-to-date. 2 # 3 # Note that we run these checks regardless whether the input files have 4 # changed, because generated code can change in response to toolchain updates 5 # even if no files in the repository are modified. 6 name: Check generated code 7 on: 8 pull_request: 9 branches: 10 - main 11 12 permissions: 13 contents: read 14 15 jobs: 16 check-mocks: 17 runs-on: ubuntu-latest 18 steps: 19 - uses: actions/setup-go@v4 20 with: 21 go-version: '1.20' 22 23 - uses: actions/checkout@v4 24 25 - name: "Check generated mocks" 26 run: | 27 set -euo pipefail 28 make mockery 2>/dev/null 29 if ! git diff --stat --exit-code ; then 30 echo ">> ERROR:" 31 echo ">>" 32 echo ">> Generated mocks require update (either Mockery or source files may have changed)." 33 echo ">> Ensure your tools are up-to-date, re-run 'make mockery' and update this PR." 34 echo ">>" 35 exit 1 36 fi 37 38 check-proto: 39 runs-on: ubuntu-latest 40 steps: 41 - uses: actions/setup-go@v4 42 with: 43 go-version: '1.20' 44 45 - uses: actions/checkout@v4 46 with: 47 fetch-depth: 1 # we need a .git directory to run git diff 48 49 - name: "Check protobuf generated code" 50 run: | 51 set -euo pipefail 52 53 # Install buf and gogo tools, so that differences that arise from 54 # toolchain differences are also caught. 55 readonly tools="$(mktemp -d)" 56 export PATH="${PATH}:${tools}/bin" 57 export GOBIN="${tools}/bin" 58 59 go install github.com/bufbuild/buf/cmd/buf 60 go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest 61 62 make proto-gen 63 64 if ! git diff --stat --exit-code ; then 65 echo ">> ERROR:" 66 echo ">>" 67 echo ">> Protobuf generated code requires update (either tools or .proto files may have changed)." 68 echo ">> Ensure your tools are up-to-date, re-run 'make proto-gen' and update this PR." 69 echo ">>" 70 exit 1 71 fi