Repository navigation
api: generate and verify protos with buf - #565
Conversation
Add buf.yaml, buf.gen.yaml, and `make generate` (format, lint, generate), with the protoc plugins pinned as go.mod tools. CI regenerates and fails on any diff. Regenerated *.pb.go headers; ax.proto formatting only.
mayawang
left a comment
There was a problem hiding this comment.
LGTM, really glad to have CI catch stale generated code. Tiny optional nit: buf could be a go.mod tool like the protoc plugins so all the generator versions live in one place
|
LGTM |
Thanks! Actually I tried it as a go.mod tool, but buf bumps google.golang.org/protobuf to an unreleased pseudo-version and adds ~80 go.mod lines, so I kept it pinned via |
Run buf as a go.mod tool from its own module, so its version and dependencies are pinned without touching the root go.mod.
Second thought, I think we can follow substrate's pattern to define it in hack/tools/buf with a go.mod. This also provides a place for future tool integration. Updated. |
There was no
make generate, and nothing checked that the checked-in*.pb.gomatch the.protofiles. This adds both.make generateformats and lints the.protofiles, then regenerates the Go code. CI (build-and-test) runs it and fails on any diff or untracked file.buf.yaml: STANDARD lint minus four rules AX deliberately differs on (commented). Breaking-change rules are commented out while the API is v1alpha1.buf.gen.yaml: protoc-gen-go and protoc-gen-go-grpc are go.modtooldirectives, and buf runs viago run, so no protoc install is needed.*.pb.gochange only in their version headers;ax.protoloses two blank lines (formatting).make generate.