Skip to content

Commit d5d64fb

Browse files
committed
makefile+travis: add mod check and tidy and check modules in travis
1 parent f7593df commit d5d64fb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sudo: required
2323

2424
script:
2525
- export GO111MODULE=on
26-
- make lint unit build
26+
- make lint unit build mod-check
2727

2828
after_script:
2929
- echo "Uploading to termbin.com..." && find *.log | xargs -I{} sh -c "cat {} | nc termbin.com 9999 | xargs -r0 printf '{} uploaded to %s'"

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ GOTEST := GO111MODULE=on go test -v
77
GO_BIN := ${GOPATH}/bin
88
GOBUILD := GO111MODULE=on go build -v
99
GOINSTALL := GO111MODULE=on go install -v
10+
GOMOD := GO111MODULE=on go mod
1011

1112
COMMIT := $(shell git describe --abbrev=40 --dirty)
1213
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT)"
@@ -26,6 +27,12 @@ TEST_FLAGS = -test.timeout=20m
2627

2728
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) $(TEST_FLAGS)
2829

30+
GREEN := "\\033[0;32m"
31+
NC := "\\033[0m"
32+
define print
33+
echo $(GREEN)$1$(NC)
34+
endef
35+
2936
$(LINT_BIN):
3037
@$(call print, "Fetching linter")
3138
$(DEPGET) $(LINT_PKG)@$(LINT_COMMIT)
@@ -42,6 +49,15 @@ lint: $(LINT_BIN)
4249
@$(call print, "Linting source.")
4350
$(LINT)
4451

52+
mod-tidy:
53+
@$(call print, "Tidying modules.")
54+
$(GOMOD) tidy
55+
56+
mod-check:
57+
@$(call print, "Checking modules.")
58+
$(GOMOD) tidy
59+
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
60+
4561
# ============
4662
# INSTALLATION
4763
# ============

0 commit comments

Comments
 (0)