makefile+travis: add mod check and tidy and check modules in travis

pull/211/head
carla 4 years ago
parent f7593dfc15
commit d5d64fb97a
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91

@ -23,7 +23,7 @@ sudo: required
script:
- export GO111MODULE=on
- make lint unit build
- make lint unit build mod-check
after_script:
- echo "Uploading to termbin.com..." && find *.log | xargs -I{} sh -c "cat {} | nc termbin.com 9999 | xargs -r0 printf '{} uploaded to %s'"

@ -7,6 +7,7 @@ GOTEST := GO111MODULE=on go test -v
GO_BIN := ${GOPATH}/bin
GOBUILD := GO111MODULE=on go build -v
GOINSTALL := GO111MODULE=on go install -v
GOMOD := GO111MODULE=on go mod
COMMIT := $(shell git describe --abbrev=40 --dirty)
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT)"
@ -26,6 +27,12 @@ TEST_FLAGS = -test.timeout=20m
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) $(TEST_FLAGS)
GREEN := "\\033[0;32m"
NC := "\\033[0m"
define print
echo $(GREEN)$1$(NC)
endef
$(LINT_BIN):
@$(call print, "Fetching linter")
$(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)
@ -42,6 +49,15 @@ lint: $(LINT_BIN)
@$(call print, "Linting source.")
$(LINT)
mod-tidy:
@$(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
# ============
# INSTALLATION
# ============

Loading…
Cancel
Save