Makefile 2.0 KB

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