[#45] Add buf linter call

Signed-off-by: Stanislav Bogatyrev <stanislav@nspcc.ru>
This commit is contained in:
Stanislav Bogatyrev 2020-08-12 19:04:15 +03:00 committed by Alex Vanin
parent a77480582d
commit 35d1d34ee0
3 changed files with 24 additions and 29 deletions

4
.gitignore vendored
View file

@ -1,2 +1,2 @@
vendor
**/*.pb.go
.idea

View file

@ -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

10
buf.yaml Normal file
View file

@ -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