Skip to content

Commit 9074e24

Browse files
authored
Merge pull request #226 from kzys/buf
Migrate from protobuild to buf
2 parents 22392c2 + 056f619 commit 9074e24

18 files changed

Lines changed: 357 additions & 396 deletions

.github/workflows/ci.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ jobs:
9999
make integration
100100
101101
#
102-
# Run Protobuild
102+
# Run Buf
103103
#
104-
protobuild:
105-
name: Run Protobuild
104+
buf:
105+
name: Run Buf
106106
runs-on: ubuntu-22.04
107107
timeout-minutes: 5
108108
steps:
@@ -116,24 +116,17 @@ jobs:
116116
go-version: 'stable'
117117
id: go
118118

119-
- name: Setup Go binary path
120-
shell: bash
121-
run: |
122-
echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
123-
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
124-
125-
- name: Install dependencies
126-
working-directory: src/github.com/containerd/ttrpc
127-
run: |
128-
sudo make install-protobuf
129-
make install-protobuild
119+
- name: Install buf
120+
uses: bufbuild/buf-action@v1
121+
with:
122+
setup_only: true
130123

131124
- name: Install protoc-gen-go-ttrpc
132125
working-directory: src/github.com/containerd/ttrpc
133126
run: |
134127
make install
135128
136-
- name: Run Protobuild
129+
- name: Check protos
137130
working-directory: src/github.com/containerd/ttrpc
138131
run: |
139132
make check-protos

Makefile

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ TESTFLAGS_PARALLEL ?= 8
5757
# Use this to replace `go test` with, for instance, `gotestsum`
5858
GOTEST ?= $(GO) test
5959

60-
.PHONY: clean all AUTHORS build binaries test integration generate protos check-protos coverage ci check help install vendor install-protobuf install-protobuild
60+
.PHONY: clean all AUTHORS build binaries test integration generate protos check-protos coverage ci check help install vendor maintainer-clean
6161
.DEFAULT: default
6262

6363
# Forcibly set the default goal to all, in case an include above brought in a rule definition.
6464
.DEFAULT_GOAL := all
6565

6666
all: binaries
6767

68-
check: proto-fmt ## run all linters
68+
check: ## run all linters
6969
@echo "$(WHALE) $@"
7070
GOGC=75 golangci-lint run
7171

@@ -80,27 +80,15 @@ generate: protos
8080

8181
protos: bin/protoc-gen-gogottrpc bin/protoc-gen-go-ttrpc ## generate protobuf
8282
@echo "$(WHALE) $@"
83-
@(PATH="${ROOTDIR}/bin:${PATH}" protobuild --quiet ${PACKAGES})
83+
(cd example && buf generate)
84+
buf generate
8485

8586
check-protos: protos ## check if protobufs needs to be generated again
8687
@echo "$(WHALE) $@"
8788
@test -z "$$(git status --short | grep ".pb.go" | tee /dev/stderr)" || \
8889
((git diff | cat) && \
8990
(echo "$(ONI) please run 'make protos' when making changes to proto files" && false))
9091

91-
check-api-descriptors: protos ## check that protobuf changes aren't present.
92-
@echo "$(WHALE) $@"
93-
@test -z "$$(git status --short | grep ".pb.txt" | tee /dev/stderr)" || \
94-
((git diff $$(find . -name '*.pb.txt') | cat) && \
95-
(echo "$(ONI) please run 'make protos' when making changes to proto files and check-in the generated descriptor file changes" && false))
96-
97-
proto-fmt: ## check format of proto files
98-
@echo "$(WHALE) $@"
99-
@test -z "$$(find . -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
100-
(echo "$(ONI) please indent proto files with tabs only" && false)
101-
@test -z "$$(find . -name '*.proto' -type f -exec grep -Hn "Meta meta = " {} \; | grep -v '(gogoproto.nullable) = false' | tee /dev/stderr)" || \
102-
(echo "$(ONI) meta fields in proto files must have option (gogoproto.nullable) = false" && false)
103-
10492
build: ## build the go packages
10593
@echo "$(WHALE) $@"
10694
@$(GO) build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} ${EXTRA_FLAGS} ${PACKAGES}
@@ -117,6 +105,10 @@ benchmark: ## run benchmarks tests
117105
@echo "$(WHALE) $@"
118106
@$(GO) test ${TESTFLAGS} -bench . -run Benchmark
119107

108+
maintainer-clean:
109+
@echo "$(WHALE) $@"
110+
@find . -name '*.pb.go' -delete
111+
120112
FORCE:
121113

122114
define BUILD_BINARY
@@ -139,15 +131,6 @@ install: ## install binaries
139131
@echo "$(WHALE) $@ $(BINPACKAGES)"
140132
@$(GO) install $(BINPACKAGES)
141133

142-
install-protobuf:
143-
@echo "$(WHALE) $@"
144-
@script/install-protobuf
145-
146-
install-protobuild:
147-
@echo "$(WHALE) $@"
148-
@$(GO) install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
149-
@$(GO) install github.com/containerd/protobuild@14832ccc41429f5c4f81028e5af08aa233a219cf
150-
151134
coverage: ## generate coverprofiles from the unit tests, except tests that require root
152135
@echo "$(WHALE) $@"
153136
@rm -f coverage.txt

Protobuild.toml

Lines changed: 0 additions & 28 deletions
This file was deleted.

buf.gen.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: v2
2+
plugins:
3+
- remote: buf.build/protocolbuffers/go:v1.28.1
4+
out: .
5+
opt:
6+
- paths=source_relative
7+
- local: bin/protoc-gen-go-ttrpc
8+
out: .
9+
opt:
10+
- paths=source_relative
11+
- prefix=TTRPC

buf.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Generated by buf. DO NOT EDIT.
2+
version: v2
3+
deps:
4+
- name: buf.build/googleapis/googleapis
5+
commit: 004180b77378443887d3b55cabc00384
6+
digest: b5:e8f475fe3330f31f5fd86ac689093bcd274e19611a09db91f41d637cb9197881ce89882b94d13a58738e53c91c6e4bae7dc1feba85f590164c975a89e25115dc

buf.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: v2
2+
deps:
3+
# For google/rpc/status.proto
4+
- buf.build/googleapis/googleapis:004180b77378443887d3b55cabc00384
5+
modules:
6+
- path: .
7+
# example/ has own buf.yaml and buf.gen.yaml to not have
8+
# TTRPC prefix.
9+
excludes:
10+
- example

example/Protobuild.toml

Lines changed: 0 additions & 19 deletions
This file was deleted.

example/buf.gen.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: v2
2+
plugins:
3+
- remote: buf.build/protocolbuffers/go:v1.28.1
4+
out: .
5+
opt:
6+
- paths=source_relative
7+
- local: ../bin/protoc-gen-go-ttrpc
8+
out: .
9+
opt:
10+
- paths=source_relative

example/buf.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version: v2
2+
modules:
3+
- path: .

0 commit comments

Comments
 (0)