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.

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