mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-05 04:55:18 +00:00
The `mockery` project recommends against using a binary of `mockery` that has been created using `go install`. https://github.com/vektra/mockery/pull/456. Developers of Tendermint wishing to generate mocks should avoid having a version of `mockery` on their path that does not match the version listed in [mockery_generate.sh](10e1ac8fea/scripts/mockery_generate.sh (L11)). To make this easier for developers, the `mockery_generate.sh` script uses a containerized copy of `mockery` if `mockery` is not present on the developer's `PATH`. This containerized version of `mockery` uses the same version of mockery as our CI pipelines and allows all developers to automatically use the same version without having to manage it themselves.
#### PR checklist
- [ ] Tests written/updated, or no tests needed
- [ ] `CHANGELOG_PENDING.md` updated, or no changelog entry needed
- [ ] Updated relevant documentation (`docs/`) and code comments, or no
documentation updates needed
74 lines
2.1 KiB
YAML
74 lines
2.1 KiB
YAML
# Verify that generated code is up-to-date.
|
|
#
|
|
# Note that we run these checks regardless whether the input files have
|
|
# changed, because generated code can change in response to toolchain updates
|
|
# even if no files in the repository are modified.
|
|
name: Check generated code
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
check-mocks:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-go@v3
|
|
with:
|
|
go-version: '1.18'
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: "Check generated mocks"
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
make mockery 2>/dev/null
|
|
|
|
if ! git diff --stat --exit-code ; then
|
|
echo ">> ERROR:"
|
|
echo ">>"
|
|
echo ">> Generated mocks require update (either Mockery or source files may have changed)."
|
|
echo ">> Ensure your tools are up-to-date, re-run 'make mockery' and update this PR."
|
|
echo ">>"
|
|
exit 1
|
|
fi
|
|
|
|
check-proto:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-go@v3
|
|
with:
|
|
go-version: '1.18'
|
|
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 1 # we need a .git directory to run git diff
|
|
|
|
- name: "Check protobuf generated code"
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
# Install buf and gogo tools, so that differences that arise from
|
|
# toolchain differences are also caught.
|
|
readonly tools="$(mktemp -d)"
|
|
export PATH="${PATH}:${tools}/bin"
|
|
export GOBIN="${tools}/bin"
|
|
|
|
go install github.com/bufbuild/buf/cmd/buf
|
|
go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest
|
|
|
|
make proto-gen
|
|
|
|
if ! git diff --stat --exit-code ; then
|
|
echo ">> ERROR:"
|
|
echo ">>"
|
|
echo ">> Protobuf generated code requires update (either tools or .proto files may have changed)."
|
|
echo ">> Ensure your tools are up-to-date, re-run 'make proto-gen' and update this PR."
|
|
echo ">>"
|
|
exit 1
|
|
fi
|