go-ethereum
go-ethereum copied to clipboard
build: add check for stale generated files
Calculates a hash of every code file in the source tree, runs go generate ./..., recalculates hashes for every code files, and asserts that none of the hashes differ. This allows us to catch forgetting to push generated files in the CI.
This could use a little cleanup probably. Just opening it here to see if it passes CI (having trouble getting protoc to run properly locally).
The build failed in core/tracing/hooks.go due to cmd/stringer being unavailable. This should be fixed by converting the failed invocation to be similar to how we do it everywhere else:
//go:generate go run golang.org/x/tools/cmd/stringer
This way works because we have a dummy package that pulls cmd/stringer into our module, so it is available for use with go run.
For protoc I would suggest we add a function that downloads it. They have binaries for a good number of platforms here: https://github.com/protocolbuffers/protobuf/releases/tag/v27.1. If you search in ci.go for a bit, I'm sure you can figure out how we usually download our tools and do it the same way for protoc.
go run build/ci.go generate
build/cache/protoc-27.1-linux-x86_64.zip is stale
downloading from https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-linux-x86_64.zip
10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
build/cache/protoc-gen-go.v1.34.2.linux.amd64.tar.gz is stale
downloading from https://github.com/protocolbuffers/protobuf-go/releases/download/v1.34.2/protoc-gen-go.v1.34.2.linux.amd64.tar.gz
10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
>>> /home/appveyor/.gvm/gos/go1.22.0/bin/go generate ./...
protoc-gen-go: no such flag -import_path
--go_out: protoc-gen-go: Plugin failed with status code 1.
accounts/usbwallet/trezor/trezor.go:45: running "protoc": exit status 1
Are you testing this locally?
This error is because the trezor files need to be updated with https://github.com/ethereum/go-ethereum/pull/30058