Skip to content

Commit e312f96

Browse files
committed
build(proto): address review feedback
- Swap breaking rule FILE -> WIRE so non-wire-breaking evolution (field renames, etc.) is no longer flagged as breaking. - Strictly enforce buf, protoc-gen-go, and protoc-gen-go-grpc versions in check-tools; mismatches now fail rather than warn. - Fix Proto CI: explicitly fetch refs/remotes/origin/main and compare against it (branch=main is not materialized in PR checkouts).
1 parent 50afd4a commit e312f96

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

.github/workflows/proto.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
- uses: actions/checkout@v6
2828
with:
2929
fetch-depth: 0
30+
- name: Fetch main for breaking baseline
31+
if: github.ref != 'refs/heads/main'
32+
run: git fetch --no-tags --prune origin +refs/heads/main:refs/remotes/origin/main
3033
- uses: actions/setup-go@v6
3134
with:
3235
go-version-file: 'go.mod'
@@ -39,7 +42,7 @@ jobs:
3942
- name: buf breaking (against main)
4043
if: github.ref != 'refs/heads/main'
4144
working-directory: proto
42-
run: buf breaking --against '../.git#subdir=proto,branch=main'
45+
run: buf breaking --against '../.git#subdir=proto,ref=refs/remotes/origin/main'
4346
- name: buf generate
4447
working-directory: proto
4548
run: buf generate

proto/Makefile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BUF_VERSION := 1.55.1
2-
PROTOC_GEN_GO_VERSION := v1.36.11
2+
PROTOC_GEN_GO_VERSION := 1.36.11
33
PROTOC_GEN_GO_GRPC_VERSION := 1.6.1
44

55
BUF ?= buf
@@ -15,20 +15,34 @@ check-tools:
1515
echo " go install github.com/bufbuild/buf/cmd/buf@v$(BUF_VERSION)"; \
1616
exit 1; \
1717
}
18-
@installed_buf=$$($(BUF) --version 2>/dev/null); \
19-
if [ "$$installed_buf" != "$(BUF_VERSION)" ]; then \
20-
echo "warning: buf version mismatch (expected $(BUF_VERSION), got $$installed_buf)"; \
18+
@installed=$$($(BUF) --version 2>/dev/null); \
19+
if [ "$$installed" != "$(BUF_VERSION)" ]; then \
20+
echo "buf version mismatch: expected $(BUF_VERSION), got $$installed"; \
21+
echo "install with: go install github.com/bufbuild/buf/cmd/buf@v$(BUF_VERSION)"; \
22+
exit 1; \
2123
fi
2224
@command -v protoc-gen-go >/dev/null 2>&1 || { \
2325
echo "protoc-gen-go not found; install with:"; \
24-
echo " go install google.golang.org/protobuf/cmd/protoc-gen-go@$(PROTOC_GEN_GO_VERSION)"; \
26+
echo " go install google.golang.org/protobuf/cmd/protoc-gen-go@v$(PROTOC_GEN_GO_VERSION)"; \
2527
exit 1; \
2628
}
29+
@installed=$$(protoc-gen-go --version 2>/dev/null); \
30+
if [ "$$installed" != "protoc-gen-go v$(PROTOC_GEN_GO_VERSION)" ]; then \
31+
echo "protoc-gen-go version mismatch: expected v$(PROTOC_GEN_GO_VERSION), got $$installed"; \
32+
echo "install with: go install google.golang.org/protobuf/cmd/protoc-gen-go@v$(PROTOC_GEN_GO_VERSION)"; \
33+
exit 1; \
34+
fi
2735
@command -v protoc-gen-go-grpc >/dev/null 2>&1 || { \
2836
echo "protoc-gen-go-grpc not found; install with:"; \
2937
echo " go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v$(PROTOC_GEN_GO_GRPC_VERSION)"; \
3038
exit 1; \
3139
}
40+
@installed=$$(protoc-gen-go-grpc --version 2>/dev/null); \
41+
if [ "$$installed" != "protoc-gen-go-grpc $(PROTOC_GEN_GO_GRPC_VERSION)" ]; then \
42+
echo "protoc-gen-go-grpc version mismatch: expected $(PROTOC_GEN_GO_GRPC_VERSION), got $$installed"; \
43+
echo "install with: go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v$(PROTOC_GEN_GO_GRPC_VERSION)"; \
44+
exit 1; \
45+
fi
3246

3347
breaking: check-tools
3448
@if git -C .. rev-parse --verify main >/dev/null 2>&1; then \

proto/buf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ modules:
33
- path: .
44
breaking:
55
use:
6-
- FILE
6+
- WIRE

0 commit comments

Comments
 (0)