From 77bc45ae624225f7f19f6c5efc5ac992ad4f040c Mon Sep 17 00:00:00 2001 From: Johan Brandhorst-Satzkorn Date: Fri, 17 Jun 2022 11:58:37 -0400 Subject: [PATCH] chore: Split proto breaking change detection config (#2212) We generally care about preserving JSON compatibility for protobuf files, but for some files, where we only use pure gRPC, we only care about preserving wire compatibility. Split our buf breaking invocation into two invocations, one that checks for WIRE_JSON compatibility, and one that checks only for WIRE compatibility. The former check ignores protos in controller/servers, since they do not need to adhere to this stricter definition. --- Makefile | 8 +++++++- internal/proto/buf.breaking.json.yaml | 21 +++++++++++++++++++++ internal/proto/buf.breaking.wire.yaml | 20 ++++++++++++++++++++ internal/proto/buf.yaml | 12 ------------ 4 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 internal/proto/buf.breaking.json.yaml create mode 100644 internal/proto/buf.breaking.wire.yaml diff --git a/Makefile b/Makefile index 2488dbdb5a..642018d5ea 100644 --- a/Makefile +++ b/Makefile @@ -211,7 +211,13 @@ protobuild: .PHONY: protolint protolint: @buf lint - @buf breaking --against 'https://github.com/hashicorp/boundary.git#branch=stable-website' + # First check all protos except controller/servers for WIRE_JSON compatibility + cd internal/proto && buf breaking --against 'https://github.com/hashicorp/boundary.git#branch=stable-website,subdir=internal/proto' \ + --exclude-path=controller/servers \ + --config buf.breaking.json.yaml + # Next check all protos for WIRE compatibility. WIRE is a subset of WIRE_JSON so we don't need to exclude any files. + cd internal/proto && buf breaking --against 'https://github.com/hashicorp/boundary.git#branch=stable-website,subdir=internal/proto' \ + --config buf.breaking.wire.yaml .PHONY: website # must have nodejs and npm installed diff --git a/internal/proto/buf.breaking.json.yaml b/internal/proto/buf.breaking.json.yaml new file mode 100644 index 0000000000..ce4090a95b --- /dev/null +++ b/internal/proto/buf.breaking.json.yaml @@ -0,0 +1,21 @@ +# This file defines the breaking change configuration we use for +# files for which we require only JSON level compatibility checks, +# such as those used to describe the HTTP/JSON API we expose to the CLI, +# the Desktop client and the admin UI. +version: v1 +name: buf.build/hashicorp/boundary +deps: + - buf.build/googleapis/googleapis + - buf.build/grpc-ecosystem/grpc-gateway +breaking: + use: + - WIRE_JSON + ignore_only: + FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED: + # The proto files in controller/api are only exposed as json files so enforcing + # proto backward compatability doesn't make sense, except for maybe the names. + - controller/api + # Storage protos are used by gorm. Gorm relies on go tags and the json + # names to determine what columns to update so we don't care of the field + # numbers remain the same. + - controller/storage diff --git a/internal/proto/buf.breaking.wire.yaml b/internal/proto/buf.breaking.wire.yaml new file mode 100644 index 0000000000..1b567da204 --- /dev/null +++ b/internal/proto/buf.breaking.wire.yaml @@ -0,0 +1,20 @@ +# This file defines the breaking change configuration we use for +# files for which we require only WIRE level compatibility checks, +# such as those used to describe the gRPC API between worker and controller. +version: v1 +name: buf.build/hashicorp/boundary +deps: + - buf.build/googleapis/googleapis + - buf.build/grpc-ecosystem/grpc-gateway +breaking: + use: + - WIRE + ignore_only: + FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED: + # The proto files in controller/api are only exposed as json files so enforcing + # proto backward compatability doesn't make sense, except for maybe the names. + - controller/api + # Storage protos are used by gorm. Gorm relies on go tags and the json + # names to determine what columns to update so we don't care of the field + # numbers remain the same. + - controller/storage diff --git a/internal/proto/buf.yaml b/internal/proto/buf.yaml index c951d7b3c0..7dbb9f9d2c 100644 --- a/internal/proto/buf.yaml +++ b/internal/proto/buf.yaml @@ -3,18 +3,6 @@ name: buf.build/hashicorp/boundary deps: - buf.build/googleapis/googleapis - buf.build/grpc-ecosystem/grpc-gateway -breaking: - use: - - WIRE_JSON - ignore_only: - FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED: - # The proto files in controller/api are only exposed as json files so enforcing - # proto backward compatability doesn't make sense, except for maybe the names. - - controller/api - # Storage protos are used by gorm. Gorm relies on go tags and the json - # names to determine what columns to update so we don't care of the field - # numbers remain the same. - - controller/storage lint: use: - DEFAULT