Skip to content

Commit a3cc3d9

Browse files
authoredJun 23, 2022
makefile: change buf to use tools.go ; backport v0.34 (#8852)
* makefile: update buf commands to use tools.go (#8609) This will keep the version of `buf` consistent between all developer machines.
1 parent fe02452 commit a3cc3d9

File tree

9 files changed

+1046
-8
lines changed

9 files changed

+1046
-8
lines changed
 

‎Makefile

+18-8
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,36 @@ install:
7474
### Protobuf ###
7575
###############################################################################
7676

77-
proto-all: proto-gen proto-lint proto-check-breaking
78-
.PHONY: proto-all
77+
check-proto-deps:
78+
ifeq (,$(shell which protoc-gen-gogofaster))
79+
$(error "gogofaster plugin for protoc is required. Run 'go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest' to install")
80+
endif
81+
.PHONY: check-proto-deps
7982

8083
proto-gen:
81-
@docker pull -q tendermintdev/docker-build-proto
8284
@echo "Generating Protobuf files"
83-
@docker run -v $(shell pwd):/workspace --workdir /workspace tendermintdev/docker-build-proto sh ./scripts/protocgen.sh
85+
@go run github.com/bufbuild/buf/cmd/buf generate
86+
@mv ./proto/tendermint/abci/types.pb.go ./abci/types/
8487
.PHONY: proto-gen
8588

86-
proto-lint:
87-
@$(DOCKER_BUF) check lint --error-format=json
89+
# These targets are provided for convenience and are intended for local
90+
# execution only.
91+
proto-lint: check-proto-deps
92+
@echo "Linting Protobuf files"
93+
@go run github.com/bufbuild/buf/cmd/buf lint
8894
.PHONY: proto-lint
8995

9096
proto-format:
9197
@echo "Formatting Protobuf files"
9298
docker run -v $(shell pwd):/workspace --workdir /workspace tendermintdev/docker-build-proto find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;
9399
.PHONY: proto-format
94100

95-
proto-check-breaking:
96-
@$(DOCKER_BUF) check breaking --against-input .git#branch=master
101+
proto-check-breaking: check-proto-deps
102+
@echo "Checking for breaking changes in Protobuf files against local branch"
103+
@echo "Note: This is only useful if your changes have not yet been committed."
104+
@echo " Otherwise read up on buf's \"breaking\" command usage:"
105+
@echo " https://docs.buf.build/breaking/usage"
106+
@go run github.com/bufbuild/buf/cmd/buf breaking --against ".git"
97107
.PHONY: proto-check-breaking
98108

99109
proto-check-breaking-ci:

‎buf.gen.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: v1
2+
plugins:
3+
- name: gogofaster
4+
out: ./proto/
5+
opt:
6+
- Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types
7+
- Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration
8+
- plugins=grpc
9+
- paths=source_relative

‎buf.work.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version: v1
2+
directories:
3+
- proto

‎go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ require (
4444
)
4545

4646
require (
47+
github.com/bufbuild/buf v1.6.0 // indirect
4748
github.com/prometheus/common v0.34.0 // indirect
4849
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca
4950
)

‎go.sum

+60
Large diffs are not rendered by default.

‎proto/buf.lock

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Generated by buf. DO NOT EDIT.
2+
version: v1
3+
deps:
4+
- remote: buf.build
5+
owner: gogo
6+
repository: protobuf
7+
commit: 4df00b267f944190a229ce3695781e99

‎proto/buf.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: v1
2+
deps:
3+
- buf.build/gogo/protobuf
4+
breaking:
5+
use:
6+
- FILE
7+
lint:
8+
use:
9+
- BASIC
10+
- FILE_LOWER_SNAKE_CASE
11+
- UNARY_RPC

‎proto/tendermint/rpc/grpc/types.pb.go

+924
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tools/tools.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build tools
2+
3+
// This file uses the recommended method for tracking developer tools in a go module.
4+
//
5+
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
6+
7+
package tools
8+
9+
import (
10+
_ "github.com/bufbuild/buf/cmd/buf"
11+
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
12+
_ "github.com/vektra/mockery/v2"
13+
)

0 commit comments

Comments
 (0)
Please sign in to comment.