Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ jobs:
make integration

#
# Run Protobuild
# Run Buf
#
protobuild:
name: Run Protobuild
buf:
name: Run Buf
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
Expand All @@ -116,24 +116,17 @@ jobs:
go-version: 'stable'
id: go

- name: Setup Go binary path
shell: bash
run: |
echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH

- name: Install dependencies
working-directory: src/github.com/containerd/ttrpc
run: |
sudo make install-protobuf
make install-protobuild
- name: Install buf
uses: bufbuild/buf-action@v1
with:
setup_only: true

- name: Install protoc-gen-go-ttrpc
working-directory: src/github.com/containerd/ttrpc
run: |
make install

- name: Run Protobuild
- name: Check protos
working-directory: src/github.com/containerd/ttrpc
run: |
make check-protos
33 changes: 8 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ TESTFLAGS_PARALLEL ?= 8
# Use this to replace `go test` with, for instance, `gotestsum`
GOTEST ?= $(GO) test

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

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

all: binaries

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

Expand All @@ -80,27 +80,15 @@ generate: protos

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

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

check-api-descriptors: protos ## check that protobuf changes aren't present.
@echo "$(WHALE) $@"
@test -z "$$(git status --short | grep ".pb.txt" | tee /dev/stderr)" || \
((git diff $$(find . -name '*.pb.txt') | cat) && \
(echo "$(ONI) please run 'make protos' when making changes to proto files and check-in the generated descriptor file changes" && false))

proto-fmt: ## check format of proto files
@echo "$(WHALE) $@"
@test -z "$$(find . -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
(echo "$(ONI) please indent proto files with tabs only" && false)
@test -z "$$(find . -name '*.proto' -type f -exec grep -Hn "Meta meta = " {} \; | grep -v '(gogoproto.nullable) = false' | tee /dev/stderr)" || \
(echo "$(ONI) meta fields in proto files must have option (gogoproto.nullable) = false" && false)

build: ## build the go packages
@echo "$(WHALE) $@"
@$(GO) build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} ${EXTRA_FLAGS} ${PACKAGES}
Expand All @@ -117,6 +105,10 @@ benchmark: ## run benchmarks tests
@echo "$(WHALE) $@"
@$(GO) test ${TESTFLAGS} -bench . -run Benchmark

maintainer-clean:
@echo "$(WHALE) $@"
@find . -name '*.pb.go' -delete

FORCE:

define BUILD_BINARY
Expand All @@ -139,15 +131,6 @@ install: ## install binaries
@echo "$(WHALE) $@ $(BINPACKAGES)"
@$(GO) install $(BINPACKAGES)

install-protobuf:
@echo "$(WHALE) $@"
@script/install-protobuf

install-protobuild:
@echo "$(WHALE) $@"
@$(GO) install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
@$(GO) install github.com/containerd/protobuild@14832ccc41429f5c4f81028e5af08aa233a219cf

coverage: ## generate coverprofiles from the unit tests, except tests that require root
@echo "$(WHALE) $@"
@rm -f coverage.txt
Expand Down
28 changes: 0 additions & 28 deletions Protobuild.toml

This file was deleted.

11 changes: 11 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: v2
plugins:
- remote: buf.build/protocolbuffers/go:v1.28.1
out: .
opt:
- paths=source_relative
- local: bin/protoc-gen-go-ttrpc
out: .
opt:
- paths=source_relative
- prefix=TTRPC
6 changes: 6 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated by buf. DO NOT EDIT.
version: v2
deps:
- name: buf.build/googleapis/googleapis
commit: 004180b77378443887d3b55cabc00384
digest: b5:e8f475fe3330f31f5fd86ac689093bcd274e19611a09db91f41d637cb9197881ce89882b94d13a58738e53c91c6e4bae7dc1feba85f590164c975a89e25115dc
10 changes: 10 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v2
deps:
# For google/rpc/status.proto
- buf.build/googleapis/googleapis:004180b77378443887d3b55cabc00384
modules:
- path: .
# example/ has own buf.yaml and buf.gen.yaml to not have
# TTRPC prefix.
excludes:
- example
19 changes: 0 additions & 19 deletions example/Protobuild.toml

This file was deleted.

10 changes: 10 additions & 0 deletions example/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v2
plugins:
- remote: buf.build/protocolbuffers/go:v1.28.1
out: .
opt:
- paths=source_relative
- local: ../bin/protoc-gen-go-ttrpc
out: .
opt:
- paths=source_relative
3 changes: 3 additions & 0 deletions example/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v2
modules:
- path: .
Loading
Loading