Skip to content

Commit

Permalink
Use buf to detect for wire breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass committed Jul 28, 2022
1 parent 157bedf commit 26c216b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,18 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: make gen-kotlin

breaking-change:
needs: docker-pull
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Fetch main branch for comparison
run: git fetch && git checkout main && git checkout -
- name: Run make lint with json output to annotate PR
# Formats JSON output into Github workflow commands
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message
run: >
BUF_FLAGS="--error-format json" make -s breaking-change
| jq -rs '.[] | "::error file=\(.path),line=\(.start_line),endLine=\(.end_line),title=Buf detected breaking change \(.type)::\(.message)"'
; (exit ${PIPESTATUS[0]})
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ endef
gen-all: gen-cpp gen-csharp gen-go gen-java gen-kotlin gen-objc gen-openapi gen-php gen-python gen-ruby

OTEL_DOCKER_PROTOBUF ?= otel/build-protobuf:0.9.0
BUF_DOCKER ?= bufbuild/buf:1.7.0

PROTOC := docker run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${OTEL_DOCKER_PROTOBUF} --proto_path=${PWD}
BUF := docker run --rm -v "${PWD}:/workspace" -w /workspace ${BUF_DOCKER}
BUF_AGAINST ?= ".git\#branch=main"

PROTO_GEN_CPP_DIR ?= $(GENDIR)/cpp
PROTO_GEN_CSHARP_DIR ?= $(GENDIR)/csharp
Expand All @@ -36,6 +40,7 @@ PROTO_GEN_RUBY_DIR ?= $(GENDIR)/ruby
.PHONY: docker-pull
docker-pull:
docker pull $(OTEL_DOCKER_PROTOBUF)
docker pull $(BUF_DOCKER)

# Generate gRPC/Protobuf implementation for C++.
.PHONY: gen-cpp
Expand Down Expand Up @@ -139,3 +144,7 @@ gen-ruby:
$(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) --grpc-ruby_out=./$(PROTO_GEN_RUBY_DIR) opentelemetry/proto/collector/trace/v1/trace_service.proto
$(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) --grpc-ruby_out=./$(PROTO_GEN_RUBY_DIR) opentelemetry/proto/collector/metrics/v1/metrics_service.proto
$(PROTOC) --ruby_out=./$(PROTO_GEN_RUBY_DIR) --grpc-ruby_out=./$(PROTO_GEN_RUBY_DIR) opentelemetry/proto/collector/logs/v1/logs_service.proto

.PHONY: lint
breaking-change:
$(BUF) breaking --against $(BUF_AGAINST) $(BUF_FLAGS)
7 changes: 7 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: v1

# See https://docs.buf.build/breaking/configuration
breaking:
use:
- WIRE
- WIRE_JSON

0 comments on commit 26c216b

Please sign in to comment.