Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. GO ?= go
  2. GOFMT ?= gofmt "-s"
  3. PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
  4. VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/ | grep -v /examples/)
  5. GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
  6. TESTFOLDER := $(shell $(GO) list ./... | grep -E 'gin$$|binding$$|render$$' | grep -v examples)
  7. all: install
  8. install: deps
  9. govendor sync
  10. .PHONY: test
  11. test:
  12. echo "mode: count" > coverage.out
  13. for d in $(TESTFOLDER); do \
  14. $(GO) test -v -covermode=count -coverprofile=profile.out $$d; \
  15. if [ -f profile.out ]; then \
  16. cat profile.out | grep -v "mode:" >> coverage.out; \
  17. rm profile.out; \
  18. fi; \
  19. done
  20. .PHONY: fmt
  21. fmt:
  22. $(GOFMT) -w $(GOFILES)
  23. .PHONY: fmt-check
  24. fmt-check:
  25. @diff=$$($(GOFMT) -d $(GOFILES)); \
  26. if [ -n "$$diff" ]; then \
  27. echo "Please run 'make fmt' and commit the result:"; \
  28. echo "$${diff}"; \
  29. exit 1; \
  30. fi;
  31. vet:
  32. $(GO) vet $(VETPACKAGES)
  33. deps:
  34. @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  35. $(GO) get -u github.com/kardianos/govendor; \
  36. fi
  37. @hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  38. $(GO) get -u github.com/campoy/embedmd; \
  39. fi
  40. embedmd:
  41. embedmd -d *.md
  42. .PHONY: lint
  43. lint:
  44. @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  45. $(GO) get -u golang.org/x/lint/golint; \
  46. fi
  47. for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
  48. .PHONY: misspell-check
  49. misspell-check:
  50. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  51. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  52. fi
  53. misspell -error $(GOFILES)
  54. .PHONY: misspell
  55. misspell:
  56. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  57. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  58. fi
  59. misspell -w $(GOFILES)