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.

189 lines
5.0 KiB

6 years ago
8 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. get_deps_bin_size:
  50. @# Copy of build recipe with additional flags to perform binary size analysis
  51. $(eval $(shell go build -work -a $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/tendermint ./cmd/tendermint/ 2>&1))
  52. @find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log
  53. @echo "Results can be found here: $(CURDIR)/deps_bin_size.log"
  54. ########################################
  55. ### Testing
  56. ## required to be run first by most tests
  57. build_docker_test_image:
  58. docker build -t tester -f ./test/docker/Dockerfile .
  59. ### coverage, app, persistence, and libs tests
  60. test_cover:
  61. # run the go unit tests with coverage
  62. bash test/test_cover.sh
  63. test_apps:
  64. # run the app tests using bash
  65. # requires `abci-cli` and `tendermint` binaries installed
  66. bash test/app/test.sh
  67. test_persistence:
  68. # run the persistence tests using bash
  69. # requires `abci-cli` installed
  70. docker run --name run_persistence -t tester bash test/persist/test_failure_indices.sh
  71. # TODO undockerize
  72. # bash test/persist/test_failure_indices.sh
  73. test_p2p:
  74. docker rm -f rsyslog || true
  75. rm -rf test/logs || true
  76. mkdir test/logs
  77. cd test/
  78. docker run -d -v "logs:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog
  79. cd ..
  80. # requires 'tester' the image from above
  81. bash test/p2p/test.sh tester
  82. need_abci:
  83. bash scripts/install_abci_apps.sh
  84. test_integrations:
  85. make build_docker_test_image
  86. make get_tools
  87. make get_vendor_deps
  88. make install
  89. make need_abci
  90. make test_cover
  91. make test_apps
  92. make test_persistence
  93. make test_p2p
  94. test_libs:
  95. # checkout every github.com/tendermint dir and run its tests
  96. # NOTE: on release-* or master branches only (set by Jenkins)
  97. docker run --name run_libs -t tester bash test/test_libs.sh
  98. test_release:
  99. @go test -tags release $(PACKAGES)
  100. test100:
  101. @for i in {1..100}; do make test; done
  102. vagrant_test:
  103. vagrant up
  104. vagrant ssh -c 'make test_integrations'
  105. ### go tests
  106. test:
  107. @echo "--> Running go test"
  108. @go test $(PACKAGES)
  109. test_race:
  110. @echo "--> Running go test --race"
  111. @go test -v -race $(PACKAGES)
  112. ########################################
  113. ### Formatting, linting, and vetting
  114. fmt:
  115. @go fmt ./...
  116. metalinter:
  117. @echo "--> Running linter"
  118. @gometalinter.v2 --vendor --deadline=600s --disable-all \
  119. --enable=deadcode \
  120. --enable=gosimple \
  121. --enable=misspell \
  122. --enable=safesql \
  123. ./...
  124. #--enable=gas \
  125. #--enable=maligned \
  126. #--enable=dupl \
  127. #--enable=errcheck \
  128. #--enable=goconst \
  129. #--enable=gocyclo \
  130. #--enable=goimports \
  131. #--enable=golint \ <== comments on anything exported
  132. #--enable=gotype \
  133. #--enable=ineffassign \
  134. #--enable=interfacer \
  135. #--enable=megacheck \
  136. #--enable=staticcheck \
  137. #--enable=structcheck \
  138. #--enable=unconvert \
  139. #--enable=unparam \
  140. #--enable=unused \
  141. #--enable=varcheck \
  142. #--enable=vet \
  143. #--enable=vetshadow \
  144. metalinter_all:
  145. @echo "--> Running linter (all)"
  146. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  147. # To avoid unintended conflicts with file names, always add to .PHONY
  148. # unless there is a reason not to.
  149. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  150. .PHONY: check build build_race dist install check_tools get_tools update_tools get_vendor_deps draw_deps test_cover test_apps test_persistence test_p2p test test_race test_libs test_integrations test_release test100 vagrant_test fmt