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.7 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
8 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 tendermint.com
  73. @ bash tests/test_cli/test.sh
  74. fmt:
  75. @ go fmt ./...
  76. ########################################
  77. ### Formatting, linting, and vetting
  78. fmt:
  79. @go fmt ./...
  80. metalinter:
  81. @echo "==> Running linter"
  82. gometalinter.v2 --vendor --deadline=600s --disable-all \
  83. --enable=maligned \
  84. --enable=deadcode \
  85. --enable=goconst \
  86. --enable=goimports \
  87. --enable=gosimple \
  88. --enable=ineffassign \
  89. --enable=megacheck \
  90. --enable=misspell \
  91. --enable=staticcheck \
  92. --enable=safesql \
  93. --enable=structcheck \
  94. --enable=unconvert \
  95. --enable=unused \
  96. --enable=varcheck \
  97. --enable=vetshadow \
  98. ./...
  99. #--enable=gas \
  100. #--enable=dupl \
  101. #--enable=errcheck \
  102. #--enable=gocyclo \
  103. #--enable=golint \ <== comments on anything exported
  104. #--enable=gotype \
  105. #--enable=interfacer \
  106. #--enable=unparam \
  107. #--enable=vet \
  108. metalinter_all:
  109. protoc $(INCLUDE) --lint_out=. types/*.proto
  110. gometalinter.v2 --vendor --deadline=600s --enable-all --disable=lll ./...
  111. ########################################
  112. ### Docker
  113. DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local
  114. docker_build:
  115. docker build -t "tendermint/abci-dev" -f Dockerfile.develop .
  116. docker_run:
  117. docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" "tendermint/abci-dev" /bin/bash
  118. docker_run_rm:
  119. docker run -it --rm -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" "tendermint/abci-dev" /bin/bash
  120. devdoc_init:
  121. docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" tendermint/devdoc echo
  122. # TODO make this safer
  123. $(call DEVDOC_SAVE)
  124. devdoc:
  125. docker run -it -v "$(CURDIR):/go/src/github.com/tendermint/abci" -w "/go/src/github.com/tendermint/abci" devdoc:local bash
  126. devdoc_save:
  127. # TODO make this safer
  128. $(call DEVDOC_SAVE)
  129. devdoc_clean:
  130. docker rmi $$(docker images -f "dangling=true" -q)
  131. # To avoid unintended conflicts with file names, always add to .PHONY
  132. # unless there is a reason not to.
  133. # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
  134. .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