makefile+travis: add mod check

Add a check to travis that will tidy modules and fail if the tidy
results in changes to go.mod or go.sum.
This commit is contained in:
carla 2020-04-07 14:10:21 +02:00
parent 2ca93a2ebe
commit 02ab94db2c
No known key found for this signature in database
GPG key ID: 4CA7FE54A6213C91
2 changed files with 11 additions and 0 deletions

View file

@ -21,6 +21,7 @@ before_script:
script:
- export GO111MODULE=on
- make rpc-check
- make mod-check
- make lint unit
after_script:

View file

@ -20,6 +20,7 @@ DEPGET := cd /tmp && GO111MODULE=on go get -v
GOBUILD := GO111MODULE=on go build -v
GOINSTALL := GO111MODULE=on go install -v
GOTEST := GO111MODULE=on go test -v
GOMOD := GO111MODULE=on go mod
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
@ -117,6 +118,15 @@ lint: $(LINT_BIN)
@$(call print, "Linting source.")
$(LINT)
mod:
@$(call print, "Tidying modules.")
$(GOMOD) tidy
mod-check:
@$(call print, "Checking modules.")
$(GOMOD) tidy
if test -n "$$(git status | grep -e "go.mod\|go.sum")"; then echo "Running go mod tidy changes go.mod/go.sum"; git status; git diff; exit 1; fi
rpc:
@$(call print, "Compiling protos.")
cd ./frdrpc; ./gen_protos.sh