Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 > tmp.out; \
  15. cat tmp.out; \
  16. if grep -q "^--- FAIL" tmp.out; then \
  17. rm tmp.out; \
  18. exit 1;\
  19. fi; \
  20. if [ -f profile.out ]; then \
  21. cat profile.out | grep -v "mode:" >> coverage.out; \
  22. rm profile.out; \
  23. fi; \
  24. done
  25. .PHONY: fmt
  26. fmt:
  27. $(GOFMT) -w $(GOFILES)
  28. .PHONY: fmt-check
  29. fmt-check:
  30. @diff=$$($(GOFMT) -d $(GOFILES)); \
  31. if [ -n "$$diff" ]; then \
  32. echo "Please run 'make fmt' and commit the result:"; \
  33. echo "$${diff}"; \
  34. exit 1; \
  35. fi;
  36. vet:
  37. $(GO) vet $(VETPACKAGES)
  38. deps:
  39. @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  40. $(GO) get -u github.com/kardianos/govendor; \
  41. fi
  42. @hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  43. $(GO) get -u github.com/campoy/embedmd; \
  44. fi
  45. embedmd:
  46. embedmd -d *.md
  47. .PHONY: lint
  48. lint:
  49. @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  50. $(GO) get -u golang.org/x/lint/golint; \
  51. fi
  52. for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
  53. .PHONY: misspell-check
  54. misspell-check:
  55. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  56. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  57. fi
  58. misspell -error $(GOFILES)
  59. .PHONY: misspell
  60. misspell:
  61. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  62. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  63. fi
  64. misspell -w $(GOFILES)
  65. .PHONY: tools
  66. tools:
  67. go install golang.org/x/lint/golint; \
  68. go install github.com/client9/misspell/cmd/misspell; \
  69. go install github.com/campoy/embedmd;