Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use buf to detect for wire breaking changes #415

Merged
merged 3 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions .github/workflows/build-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,22 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: make gen-kotlin

breaking-change:
needs: docker-pull
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# This is needed because checkout action does a shallow clone
- name: Fetch main branch for comparison
run: |
git remote set-branches origin '*'
git fetch --depth=1 origin main
git branch main origin/main
- name: Run make breaking-change with json output to annotate PR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is very helpful, thank you!

It would be nice if you could add a breaking change in a new (dummy) PR based off this branch to illustrate how this would work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

# 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]})
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ 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"
tigrannajaryan marked this conversation as resolved.
Show resolved Hide resolved

PROTO_GEN_CPP_DIR ?= $(GENDIR)/cpp
PROTO_GEN_CSHARP_DIR ?= $(GENDIR)/csharp
PROTO_GEN_GO_DIR ?= $(GENDIR)/go
PROTO_GEN_JAVA_DIR ?= $(GENDIR)/java
PROTO_GEN_JS_DIR ?= $(GENDIR)/js
aabmass marked this conversation as resolved.
Show resolved Hide resolved
PROTO_GEN_KOTLIN_DIR ?= $(GENDIR)/kotlin
PROTO_GEN_OBJC_DIR ?= $(GENDIR)/objc
PROTO_GEN_OPENAPI_DIR ?= $(GENDIR)/openapi
Expand All @@ -36,6 +39,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 +143,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: breaking-change
breaking-change:
$(BUF) breaking --against $(BUF_AGAINST) $(BUF_FLAGS)
6 changes: 6 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: v1

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