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.

174 lines
4.9 KiB

7 years ago
8 years ago
7 years ago
7 years ago
9 years ago
9 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. GOTOOLS = \
  2. github.com/mitchellh/gox \
  3. github.com/golang/dep/cmd/dep \
  4. gopkg.in/alecthomas/gometalinter.v2 \
  5. github.com/gogo/protobuf/protoc-gen-gogo \
  6. github.com/gogo/protobuf/gogoproto
  7. GOTOOLS_CHECK = gox dep gometalinter.v2 protoc protoc-gen-gogo
  8. PACKAGES=$(shell go list ./... | grep -v '/vendor/')
  9. INCLUDE = -I=. -I=${GOPATH}/src -I=${GOPATH}/src/github.com/gogo/protobuf/protobuf
  10. all: check get_vendor_deps protoc build test install metalinter
  11. check: check_tools
  12. ########################################
  13. ### Build
  14. protoc:
  15. ## If you get the following error,
  16. ## "error while loading shared libraries: libprotobuf.so.14: cannot open shared object file: No such file or directory"
  17. ## See https://stackoverflow.com/a/25518702
  18. protoc $(INCLUDE) --gogo_out=plugins=grpc:. types/*.proto
  19. @echo "--> adding nolint declarations to protobuf generated files"
  20. @awk '/package types/ { print "//nolint: gas"; print; next }1' types/types.pb.go > types/types.pb.go.new
  21. @mv types/types.pb.go.new types/types.pb.go
  22. build:
  23. @go build -i ./cmd/...
  24. dist:
  25. @bash scripts/dist.sh
  26. @bash scripts/publish.sh
  27. install:
  28. @go install ./cmd/...
  29. ########################################
  30. ### Tools & dependencies
  31. check_tools:
  32. @# https://stackoverflow.com/a/25668869
  33. @echo "Found tools: $(foreach tool,$(GOTOOLS_CHECK),\
  34. $(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
  35. get_tools:
  36. @echo "--> Installing tools"
  37. go get -u -v $(GOTOOLS)
  38. @gometalinter.v2 --install
  39. get_protoc:
  40. @# https://github.com/google/protobuf/releases
  41. curl -L https://github.com/google/protobuf/releases/download/v3.4.1/protobuf-cpp-3.4.1.tar.gz | tar xvz && \
  42. cd protobuf-3.4.1 && \
  43. DIST_LANG=cpp ./configure && \
  44. make && \
  45. make install && \
  46. cd .. && \
  47. rm -rf protobuf-3.4.1
  48. update_tools:
  49. @echo "--> Updating tools"
  50. @go get -u $(GOTOOLS)
  51. get_vendor_deps:
  52. @rm -rf vendor/
  53. @echo "--> Running dep ensure"
  54. @dep ensure
  55. ########################################
  56. ### Testing
  57. test:
  58. @find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \;
  59. @echo "==> Running go test"
  60. @go test $(PACKAGES)
  61. test_race:
  62. @find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \;
  63. @echo "==> Running go test --race"
  64. @go test -v -race $(PACKAGES)
  65. ### three tests tested by Jenkins
  66. test_cover:
  67. @ bash tests/test_cover.sh
  68. test_apps:
  69. # test the counter using a go test script
  70. @ bash tests/test_app/test.sh
  71. test_cli:
  72. # test the cli against the examples in the tutorial at:
  73. # http://tendermint.readthedocs.io/projects/tools/en/master/abci-cli.html
  74. #
  75. # XXX: if this test fails, fix it and update the docs at:
  76. # https://github.com/tendermint/tendermint/blob/develop/docs/abci-cli.rst
  77. @ bash tests/test_cli/test.sh
  78. ########################################
  79. ### Formatting, linting, and vetting
  80. fmt:
  81. @go fmt ./...
  82. metalinter:
  83. @echo "==> Running linter"
  84. gometalinter.v2 --vendor --deadline=600s --disable-all \
  85. --enable=maligned \
  86. --enable=deadcode \
  87. --enable=goconst \
  88. --enable=goimports \
  89. --enable=gosimple \
  90. --enable=ineffassign \
  91. --enable=megacheck \
  92. --enable=misspell \
  93. --enable=staticcheck \
  94. --enable=safesql \
  95. --enable=structcheck \
  96. --enable=unconvert \
  97. --enable=unused \
  98. --enable=varcheck \
  99. --enable=vetshadow \
  100. ./...
  101. #--enable=gas \
  102. #--enable=dupl \
  103. #--enable=errcheck \
  104. #--enable=gocyclo \
  105. #--enable=golint \ <== comments on anything exported
  106. #--enable=gotype \
  107. #--enable=interfacer \
  108. #--enable=unparam \
  109. #--enable=vet \
  110. metalinter_all:
  111. protoc $(INCLUDE) --lint_out=. types/*.proto
  112. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  113. ########################################
  114. ### Docker
  115. DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local
  116. docker_build:
  117. docker build -t "tendermint/abci-dev" -f Dockerfile.develop .
  118. docker_run:
  119. docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" "tendermint/abci-dev" /bin/bash
  120. docker_run_rm:
  121. docker run -it --rm -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" "tendermint/abci-dev" /bin/bash
  122. devdoc_init:
  123. docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" tendermint/devdoc echo
  124. # TODO make this safer
  125. $(call DEVDOC_SAVE)
  126. devdoc:
  127. docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" devdoc:local bash
  128. devdoc_save:
  129. # TODO make this safer
  130. $(call DEVDOC_SAVE)
  131. devdoc_clean:
  132. docker rmi $$(docker images -f "dangling=true" -q)
  133. # To avoid unintended conflicts with file names, always add to .PHONY
  134. # unless there is a reason not to.
  135. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  136. .PHONY: check protoc build dist install check_tools get_tools get_protoc update_tools get_vendor_deps test test_race fmt metalinter metalinter_all docker_build docker_run docker_run_rm devdoc_init devdoc devdoc_save devdoc_clean