From 35d1d34ee03015f0423c2a2df24bc82543f187a8 Mon Sep 17 00:00:00 2001 From: Stanislav Bogatyrev Date: Wed, 12 Aug 2020 19:04:15 +0300 Subject: [PATCH] [#45] Add buf linter call Signed-off-by: Stanislav Bogatyrev --- .gitignore | 4 ++-- Makefile | 39 ++++++++++++--------------------------- buf.yaml | 10 ++++++++++ 3 files changed, 24 insertions(+), 29 deletions(-) create mode 100644 buf.yaml diff --git a/.gitignore b/.gitignore index 1df644c..c6ef218 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -vendor -**/*.pb.go +.idea + diff --git a/Makefile b/Makefile index 6e78b17..76ee25b 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,21 @@ -NETMAP_VERSION=v1.7.0 -GOGOPROTO_VERSION=v1.3.1 +#!/usr/bin/make -f +SHELL=bash -NETMAP_URL=https://github.com/nspcc-dev/netmap/archive/$(NETMAP_VERSION).tar.gz -GOGOPROTO_URL=https://github.com/gogo/protobuf/archive/$(GOGOPROTO_VERSION).tar.gz +# BRanch to match for BRaking changes +BRBR?=master -.PHONY: deps docgen - -deps: - @echo "⇒ Prepare" - @rm -rf ./vendor/github.com/gogo/protobuf - @rm -rf ./vendor/github.com/nspcc-dev/netmap - @mkdir -p ./vendor/github.com/gogo/protobuf - @mkdir -p ./vendor/github.com/nspcc-dev/netmap - - @echo "⇒ Download" - @curl -sL -o ./vendor/gogo.tar.gz $(GOGOPROTO_URL) - @curl -sL -o ./vendor/netmap.tar.gz $(NETMAP_URL) - - @echo "⇒ Vendoring" - @tar -xzf ./vendor/gogo.tar.gz --strip-components 1 -C ./vendor/github.com/gogo/protobuf - @tar -xzf ./vendor/netmap.tar.gz --strip-components 1 -C ./vendor/github.com/nspcc-dev/netmap - - @echo "⇒ Cleanup" - @rm ./vendor/gogo.tar.gz - @rm ./vendor/netmap.tar.gz +.PHONY: lint +lint: + buf check lint + buf check breaking --against-input '.git#branch=$(BRBR)' +.PHONY: doc # Regenerate documentation for protot files: -docgen: deps - @for f in `find . -type f -name '*.proto' -not -path './vendor/*' -exec dirname {} \; | sort -u `; do \ +doc: + @for f in `find . -type f -name '*.proto' -exec dirname {} \; | sort -u `; do \ echo "${B}${G}⇒ Documentation for $$(basename $$f) ${R}"; \ protoc \ --doc_opt=.github/markdown.tmpl,$${f}.md \ - --proto_path=.:./vendor:/usr/local/include \ + --proto_path=.:/usr/local/include \ --doc_out=proto-docs/ $${f}/*.proto; \ done diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 0000000..2006bea --- /dev/null +++ b/buf.yaml @@ -0,0 +1,10 @@ +lint: + use: + - DEFAULT + - COMMENTS + - ENUM_FIRST_VALUE_ZERO + except: + - PACKAGE_DIRECTORY_MATCH + - PACKAGE_VERSION_SUFFIX + - ENUM_VALUE_PREFIX + - ENUM_ZERO_VALUE_SUFFIX