blob: b4bf73d8c3c64dd792b0bbcf937716b32af856d0 [file] [log] [blame]
Don Newton7577f072020-01-06 12:41:11 -05001export GO15VENDOREXPERIMENT=1
2
3PACKAGES := $(shell glide nv)
4
5GO_FILES := $(shell \
6 find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
7 -o -name '*.go' -print | cut -b3-)
8
9.PHONY: install
10install:
11 glide --version || go get github.com/Masterminds/glide
12 glide install
13
14.PHONY: build
15build:
16 go build -i $(PACKAGES)
17
18.PHONY: test
19test:
20 go test -cover -race $(PACKAGES)
21
22.PHONY: gofmt
23gofmt:
24 $(eval FMT_LOG := $(shell mktemp -t gofmt.XXXXX))
25 @gofmt -e -s -l $(GO_FILES) > $(FMT_LOG) || true
26 @[ ! -s "$(FMT_LOG)" ] || (echo "gofmt failed:" | cat - $(FMT_LOG) && false)
27
28.PHONY: govet
29govet:
30 $(eval VET_LOG := $(shell mktemp -t govet.XXXXX))
31 @go vet $(PACKAGES) 2>&1 \
32 | grep -v '^exit status' > $(VET_LOG) || true
33 @[ ! -s "$(VET_LOG)" ] || (echo "govet failed:" | cat - $(VET_LOG) && false)
34
35.PHONY: golint
36golint:
37 @go get golang.org/x/lint/golint
38 $(eval LINT_LOG := $(shell mktemp -t golint.XXXXX))
39 @cat /dev/null > $(LINT_LOG)
40 @$(foreach pkg, $(PACKAGES), golint $(pkg) >> $(LINT_LOG) || true;)
41 @[ ! -s "$(LINT_LOG)" ] || (echo "golint failed:" | cat - $(LINT_LOG) && false)
42
43.PHONY: staticcheck
44staticcheck:
45 @go get honnef.co/go/tools/cmd/staticcheck
46 $(eval STATICCHECK_LOG := $(shell mktemp -t staticcheck.XXXXX))
47 @staticcheck $(PACKAGES) 2>&1 > $(STATICCHECK_LOG) || true
48 @[ ! -s "$(STATICCHECK_LOG)" ] || (echo "staticcheck failed:" | cat - $(STATICCHECK_LOG) && false)
49
50.PHONY: lint
51lint: gofmt govet golint staticcheck
52
53.PHONY: cover
54cover:
55 ./scripts/cover.sh $(shell go list $(PACKAGES))
56 go tool cover -html=cover.out -o cover.html
57
58update-license:
59 @go get go.uber.org/tools/update-license
60 @update-license \
61 $(shell go list -json $(PACKAGES) | \
62 jq -r '.Dir + "/" + (.GoFiles | .[])')
63
64##############################################################################
65
66.PHONY: install_ci
67install_ci: install
68 go get github.com/wadey/gocovmerge
69 go get github.com/mattn/goveralls
70 go get golang.org/x/tools/cmd/cover
71
72.PHONY: test_ci
73test_ci: install_ci
74 ./scripts/cover.sh $(shell go list $(PACKAGES))