blob: dfc63d9db4f8d5460f33c230396b08258d8236d4 [file] [log] [blame]
khenaidooac637102019-01-14 15:44:34 -05001PACKAGES := $(shell glide nv)
2# Many Go tools take file globs or directories as arguments instead of packages.
3PACKAGE_FILES ?= *.go
4
5
6# The linting tools evolve with each Go version, so run them only on the latest
7# stable release.
8GO_VERSION := $(shell go version | cut -d " " -f 3)
9GO_MINOR_VERSION := $(word 2,$(subst ., ,$(GO_VERSION)))
10LINTABLE_MINOR_VERSIONS := 7 8
11ifneq ($(filter $(LINTABLE_MINOR_VERSIONS),$(GO_MINOR_VERSION)),)
12SHOULD_LINT := true
13endif
14
15
16export GO15VENDOREXPERIMENT=1
17
18
19.PHONY: build
20build:
21 go build -i $(PACKAGES)
22
23
24.PHONY: install
25install:
26 glide --version || go get github.com/Masterminds/glide
27 glide install
28
29
30.PHONY: test
31test:
32 go test -cover -race $(PACKAGES)
33
34
35.PHONY: install_ci
36install_ci: install
37 go get github.com/wadey/gocovmerge
38 go get github.com/mattn/goveralls
39 go get golang.org/x/tools/cmd/cover
40ifdef SHOULD_LINT
41 go get github.com/golang/lint/golint
42endif
43
44.PHONY: lint
45lint:
46ifdef SHOULD_LINT
47 @rm -rf lint.log
48 @echo "Checking formatting..."
49 @gofmt -d -s $(PACKAGE_FILES) 2>&1 | tee lint.log
50 @echo "Checking vet..."
51 @$(foreach dir,$(PACKAGE_FILES),go tool vet $(dir) 2>&1 | tee -a lint.log;)
52 @echo "Checking lint..."
53 @$(foreach dir,$(PKGS),golint $(dir) 2>&1 | tee -a lint.log;)
54 @echo "Checking for unresolved FIXMEs..."
55 @git grep -i fixme | grep -v -e vendor -e Makefile | tee -a lint.log
56 @[ ! -s lint.log ]
57else
58 @echo "Skipping linters on" $(GO_VERSION)
59endif
60
61
62.PHONY: test_ci
63test_ci: install_ci build
64 ./scripts/cover.sh $(shell go list $(PACKAGES))