Skip to content

api: generate and verify protos with buf - #565

Merged
yongruilin merged 2 commits into
google:mainfrom
yongruilin:ax-api-standard
Nov 10, 2026
Merged

yongruilin merged 2 commits into
google:mainfrom
yongruilin:ax-api-standard

Conversation

@yongruilin

Copy link
Copy Markdown
Collaborator

There was no make generate, and nothing checked that the checked-in *.pb.go match the .proto files. This adds both.

  • make generate formats and lints the .proto files, 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.mod tool directives, and buf runs via go run, so no protoc install is needed.
  • Generated *.pb.go change only in their version headers; ax.proto loses two blank lines (formatting).
  • AGENTS.md and CONTRIBUTING.md point to make generate.

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 mayawang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

@YoyinZyc

Copy link
Copy Markdown
Collaborator

LGTM

@yongruilin

Copy link
Copy Markdown
Collaborator Author

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

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 go run in the Makefile.

Run buf as a go.mod tool from its own module, so its version and
dependencies are pinned without touching the root go.mod.
@yongruilin

Copy link
Copy Markdown
Collaborator Author

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

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 go run in the Makefile.

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.

@yongruilin
yongruilin merged commit 80395e5 into google:main Nov 10, 2026
10 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.

3 participants