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.

138 lines
3.4 KiB

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