Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add check for stale generated files #30037

Merged
merged 5 commits into from
Jul 1, 2024

Conversation

jwasinger
Copy link
Contributor

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).

build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
tests/block_test.go Outdated Show resolved Hide resolved
@fjl
Copy link
Contributor

fjl commented Jun 21, 2024

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.

internal/build/archive.go Outdated Show resolved Hide resolved
@jwasinger jwasinger marked this pull request as ready for review June 25, 2024 00:43
@jwasinger jwasinger requested a review from s1na as a code owner June 25, 2024 00:43
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fjl fjl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there.

build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
@fjl
Copy link
Contributor

fjl commented Jun 28, 2024

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?

@jwasinger
Copy link
Contributor Author

This error is because the trezor files need to be updated with #30058

build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
build/ci.go Outdated Show resolved Hide resolved
@fjl fjl force-pushed the ci-lint-generated-files branch from 6d6c0bf to 9bc6b38 Compare July 1, 2024 14:34
@fjl fjl requested a review from karalabe as a code owner July 1, 2024 14:34
@fjl fjl added this to the 1.14.6 milestone Jul 1, 2024
@fjl fjl merged commit 41abab9 into ethereum:master Jul 1, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants