You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
3.4 KiB

8 years ago
7 years ago
7 years ago
7 years ago
  1. GOTOOLS = \
  2. github.com/golang/dep/cmd/dep \
  3. github.com/tendermint/glide \
  4. # gopkg.in/alecthomas/gometalinter.v2
  5. PACKAGES=$(shell go list ./... | grep -v '/vendor/')
  6. BUILD_TAGS?=tendermint
  7. BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`"
  8. all: check build test install
  9. check: check_tools ensure_deps
  10. ########################################
  11. ### Build
  12. build:
  13. go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/tendermint ./cmd/tendermint/
  14. build_race:
  15. go build -race $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/tendermint ./cmd/tendermint
  16. install:
  17. go install $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' ./cmd/tendermint
  18. ########################################
  19. ### Distribution
  20. # dist builds binaries for all platforms and packages them for distribution
  21. dist:
  22. @BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'"
  23. ########################################
  24. ### Tools & dependencies
  25. check_tools:
  26. @# https://stackoverflow.com/a/25668869
  27. @echo "Found tools: $(foreach tool,$(notdir $(GOTOOLS)),\
  28. $(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
  29. get_tools:
  30. @echo "--> Installing tools"
  31. go get -u -v $(GOTOOLS)
  32. # @gometalinter.v2 --install
  33. update_tools:
  34. @echo "--> Updating tools"
  35. @go get -u $(GOTOOLS)
  36. #Run this from CI
  37. get_vendor_deps:
  38. @rm -rf vendor/
  39. @echo "--> Running dep"
  40. @dep ensure -vendor-only
  41. #Run this locally.
  42. ensure_deps:
  43. @rm -rf vendor/
  44. @echo "--> Running dep"
  45. @dep ensure
  46. draw_deps:
  47. @# requires brew install graphviz or apt-get install graphviz
  48. go get github.com/RobotsAndPencils/goviz
  49. @goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
  50. ########################################
  51. ### Testing
  52. test:
  53. @echo "--> Running go test"
  54. @go test $(PACKAGES)
  55. test_race:
  56. @echo "--> Running go test --race"
  57. @go test -v -race $(PACKAGES)
  58. test_integrations:
  59. @bash ./test/test.sh
  60. test_release:
  61. @go test -tags release $(PACKAGES)
  62. test100:
  63. @for i in {1..100}; do make test; done
  64. vagrant_test:
  65. vagrant up
  66. vagrant ssh -c 'make install'
  67. vagrant ssh -c 'make test_race'
  68. vagrant ssh -c 'make test_integrations'
  69. ########################################
  70. ### Formatting, linting, and vetting
  71. fmt:
  72. @go fmt ./...
  73. metalinter:
  74. @echo "--> Running linter"
  75. gometalinter.v2 --vendor --deadline=600s --disable-all \
  76. --enable=deadcode \
  77. --enable=gosimple \
  78. --enable=misspell \
  79. --enable=safesql \
  80. ./...
  81. #--enable=gas \
  82. #--enable=maligned \
  83. #--enable=dupl \
  84. #--enable=errcheck \
  85. #--enable=goconst \
  86. #--enable=gocyclo \
  87. #--enable=goimports \
  88. #--enable=golint \ <== comments on anything exported
  89. #--enable=gotype \
  90. #--enable=ineffassign \
  91. #--enable=interfacer \
  92. #--enable=megacheck \
  93. #--enable=staticcheck \
  94. #--enable=structcheck \
  95. #--enable=unconvert \
  96. #--enable=unparam \
  97. #--enable=unused \
  98. #--enable=varcheck \
  99. #--enable=vet \
  100. #--enable=vetshadow \
  101. metalinter_all:
  102. @echo "--> Running linter (all)"
  103. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  104. # To avoid unintended conflicts with file names, always add to .PHONY
  105. # unless there is a reason not to.
  106. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  107. .PHONY: check build build_race dist install check_tools get_tools update_tools get_vendor_deps draw_deps test test_race test_integrations test_release test100 vagrant_test fmt metalinter metalinter_all