From 1abd0421626b0e7f805aa9ad5dbe3e657e85b7ea Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 27 Jul 2020 14:18:09 -0400 Subject: [PATCH] ci: Add check-generated And remove makefile targets that can be accomplished with --always-make --- .circleci/config.yml | 31 ++++++++++++++++++++++++++++++ GNUmakefile | 10 +--------- build-support/scripts/proto-gen.sh | 2 +- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index beb5ce7b3..f5efe3c69 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -115,6 +115,36 @@ jobs: fi - run: *notify-slack-failure + check-generated-protobuf: + docker: + - image: *GOLANG_IMAGE + environment: + <<: *ENVIRONMENT + steps: + - checkout + - run: + name: Install protobuf + command: | + wget https://github.com/protocolbuffers/protobuf/releases/download/v3.12.3/protoc-3.12.3-linux-x86_64.zip + sudo unzip -d /usr/local protoc-*.zip + sudo chmod +x /usr/local/bin/protoc + rm protoc-*.zip + - run: + name: Install gogo/protobuf + command: | + gogo_version=$(go list -m github.com/gogo/protobuf | awk '{print $2}') + mkdir -p .gotools; cd .gotools; go mod init consul-tools + go get -v github.com/hashicorp/protoc-gen-go-binary + go get -v github.com/gogo/protobuf/protoc-gen-gofast@${gogo_version} + + - run: + command: make --always-make proto + - run: | + if ! git diff --exit-code; then + echo "Generated code was not updated correctly" + exit 1 + fi + go-test: docker: - image: *GOLANG_IMAGE @@ -744,6 +774,7 @@ workflows: - stable-website - /^docs\/.*/ - /^ui\/.*/ + - check-generated-protobuf: *filter-ignore-non-go-branches - lint-consul-retry: *filter-ignore-non-go-branches - lint: *filter-ignore-non-go-branches - test-connect-ca-providers: *filter-ignore-non-go-branches diff --git a/GNUmakefile b/GNUmakefile index 6a1fcd258..fdf88643c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -363,14 +363,6 @@ else @go test -v ./agent/connect/ca endif -proto-delete: - @echo "Removing $(PROTOGOFILES)" - -@rm $(PROTOGOFILES) - @echo "Removing $(PROTOGOBINFILES)" - -@rm $(PROTOGOBINFILES) - -proto-rebuild: proto-delete proto - proto: $(PROTOGOFILES) $(PROTOGOBINFILES) @echo "Generated all protobuf Go files" @@ -387,4 +379,4 @@ module-versions: .PHONY: all ci bin dev dist cov test test-flake test-internal cover lint ui static-assets tools .PHONY: docker-images go-build-image ui-build-image static-assets-docker consul-docker ui-docker -.PHONY: version proto proto-rebuild proto-delete test-envoy-integ +.PHONY: version proto test-envoy-integ diff --git a/build-support/scripts/proto-gen.sh b/build-support/scripts/proto-gen.sh index c7acfe08f..9d94a4e21 100755 --- a/build-support/scripts/proto-gen.sh +++ b/build-support/scripts/proto-gen.sh @@ -116,7 +116,7 @@ function main { return 1 fi - BUILD_TAGS=$(sed -e '/^[:space:]*$/,$d' < "${proto_path}" | grep '// +build') + BUILD_TAGS=$(sed -e '/^[[:space:]]*$/,$d' < "${proto_path}" | grep '// +build') if test -n "${BUILD_TAGS}" then echo -e "${BUILD_TAGS}\n" >> "${proto_go_path}.new"