khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 1 | export GO15VENDOREXPERIMENT=1 |
| 2 | |
| 3 | PACKAGES := $(shell glide nv) |
| 4 | |
| 5 | GO_FILES := $(shell \ |
| 6 | find . '(' -path '*/.*' -o -path './vendor' ')' -prune \ |
| 7 | -o -name '*.go' -print | cut -b3-) |
| 8 | |
| 9 | .PHONY: install |
| 10 | install: |
| 11 | glide --version || go get github.com/Masterminds/glide |
| 12 | glide install |
| 13 | |
| 14 | .PHONY: build |
| 15 | build: |
| 16 | go build -i $(PACKAGES) |
| 17 | |
| 18 | .PHONY: test |
| 19 | test: |
| 20 | go test -cover -race $(PACKAGES) |
| 21 | |
| 22 | .PHONY: gofmt |
| 23 | gofmt: |
| 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 |
| 29 | govet: |
| 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 |
| 36 | golint: |
Scott Baker | 8461e15 | 2019-10-01 14:44:30 -0700 | [diff] [blame] | 37 | @go get golang.org/x/lint/golint |
khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame] | 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 |
| 44 | staticcheck: |
| 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 |
| 51 | lint: gofmt govet golint staticcheck |
| 52 | |
| 53 | .PHONY: cover |
| 54 | cover: |
| 55 | ./scripts/cover.sh $(shell go list $(PACKAGES)) |
| 56 | go tool cover -html=cover.out -o cover.html |
| 57 | |
| 58 | update-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 |
| 67 | install_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 |
| 73 | test_ci: install_ci |
| 74 | ./scripts/cover.sh $(shell go list $(PACKAGES)) |