From 02ab94db2cc2e9e3fc677d41a497f35ff09d845d Mon Sep 17 00:00:00 2001 From: carla Date: Tue, 7 Apr 2020 14:10:21 +0200 Subject: [PATCH] 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. --- .travis.yml | 1 + Makefile | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index 057326e..220cdf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ before_script: script: - export GO111MODULE=on - make rpc-check + - make mod-check - make lint unit after_script: diff --git a/Makefile b/Makefile index 847adfe..5a2d990 100644 --- a/Makefile +++ b/Makefile @@ -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