Makefile 1.5 KB

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