Skip to content

Check in generated Go code for the warn/docs proto - #1498

Open
philwo wants to merge 1 commit into
bazel-contrib:mainfrom
philwo:warn-docs-proto-checkedin
Open

philwo wants to merge 1 commit into
bazel-contrib:mainfrom
philwo:warn-docs-proto-checkedin

Conversation

@philwo

@philwo philwo commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

A plain go build ./... or go mod tidy currently fails in this repo for two reasons:

  1. warn/docs imports github.com/bazelbuild/buildtools/warn/docs/proto, which only exists as a go_proto_library generated at build time by Bazel. Every other proto in the repo (api_proto, build_proto, deps_proto, extra_actions_base_proto) has its generated .pb.go checked in with a go_proto_checkedin_test freshness check, so I figured it's fine to add this missing one.
  2. go.mod is missing the go 1.21 requirement and the indirect golang.org/x/sys dependency introduced by the github.com/google/safeopen dependency (Prevent unwanted path traversal in file writes from buildtools. #1491). I think we forgot to run go mod tidy in that PR and Bazel CI didn't catch it, because building the code with Bazel works even when go.mod is not correct. This caused go install github.com/bazelbuild/buildtools/buildifier@latest to break, which is documented in the README as a valid way to install buildifier.

This PR:

  • moves docs.proto into warn/docs/proto/ to match the layout of the other proto packages,
  • checks in the generated docs.gen.pb.go and adds its freshness check to //:tests, so it cannot silently go stale (update with bazel run //warn/docs/proto:docs.gen.pb.go_copy),
  • runs go mod tidy to repair go.mod and go.sum.

After this, go build ./..., go mod tidy, and go install ...@latest work fine again alongside the Bazel build. ❤️

A plain "go build ./..." or "go mod tidy" fails in this repo for two
reasons:

- warn/docs imports github.com/bazelbuild/buildtools/warn/docs/proto,
  which only exists as a go_proto_library generated at build time by
  Bazel. Every other proto in the repo (api_proto, build_proto,
  deps_proto, extra_actions_base_proto) has its generated .pb.go
  checked in with a go_proto_checkedin_test freshness check; this one
  never got the same treatment.

- go.mod is missing the go 1.21 requirement and the indirect
  golang.org/x/sys dependency introduced by the github.com/google/safeopen
  dependency (bazel-contrib#1491). Bazel builds resolve dependencies through
  MODULE.bazel, so CI did not catch this, but it also breaks
  "go install github.com/bazelbuild/buildtools/buildifier@latest".

Move docs.proto into warn/docs/proto to match the layout of the other
proto packages, check in docs.gen.pb.go, add the freshness check test
to //:tests, and run "go mod tidy" to repair go.mod and go.sum.

Update with: bazel run //warn/docs/proto:docs.gen.pb.go_copy
@fmeum

fmeum commented Sep 2, 2026

Copy link
Copy Markdown
Member

Could you add a BazelCI job that verifies that go build ./..., go mod tidy and go install ...@latest all pass and don't modify go.mod/go.sum?

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.

2 participants