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.

173 lines
4.8 KiB

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