From a4de1b7fb7c296cfe53f63a50c9c7b88c17c804b Mon Sep 17 00:00:00 2001 From: Nick DeLuca Date: Wed, 30 Nov 2022 11:02:16 -0700 Subject: [PATCH] Update proto breaking CI check to pass on release branches (#1407) * modify proto check breaking to check against the previous commit by default * add additional proto breaking check for pull requests to master * always check proto breaking against target branch when making a pull request --- .github/workflows/proto.yml | 5 ++++- build/proto.mk | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index d81499d9..e1a08f61 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -1,7 +1,8 @@ name: Protobuf Checks on: - push + push: + pull_request: jobs: check-proto: @@ -19,6 +20,8 @@ jobs: - run: make check-proto-lint - run: make check-proto-format - run: make check-proto-breaking-remote + - run: BUF_CHECK_BREAKING_AGAINST="branch=$GITHUB_BASE_REF" make check-proto-breaking-remote + if: github.event_name == 'pull_request' - run: make check-proto-gen - run: make check-proto-gen-doc - run: make check-proto-gen-swagger diff --git a/build/proto.mk b/build/proto.mk index d93acd4c..6f77fc21 100644 --- a/build/proto.mk +++ b/build/proto.mk @@ -43,15 +43,17 @@ proto-format: install-build-deps check-proto-format: proto-format @git diff --exit-code proto/**/*.proto > /dev/null || (echo "Protobuf format is not up to date! Please run \`make proto-format\`."; exit 1) +BUF_CHECK_BREAKING_AGAINST ?= ref=HEAD~1 + .PHONY: check-proto-breaking check-proto-breaking: install-build-deps @echo "Checking for proto backward compatibility" - @$(BUF) breaking --against '.git#branch=master' + @$(BUF) breaking --against '.git#$(BUF_CHECK_BREAKING_AGAINST)' .PHONY: check-proto-breaking-remote check-proto-breaking-remote: install-build-deps @echo "Checking for proto backward compatibility" - @$(BUF) breaking --against '$(HTTPS_GIT)#branch=master' + @$(BUF) breaking --against '$(HTTPS_GIT)#$(BUF_CHECK_BREAKING_AGAINST)' .PHONY: proto-gen-all proto-gen-all: proto-gen proto-gen-doc proto-gen-swagger