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.

332 lines
12 KiB

[RPC] Static swagger (#3880) * manually swagging Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * three definitions with polymorphism Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * added blockchain and block Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * low quality generation, commit, block_response and validators Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * genesis and consensus states endpoints Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * fix indentation Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * consensus parameters Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * fix indentation Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add height to consensus parameters endpoint Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * unconfirmed_txs and num_unconfirmed_txs Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add missing query parameter Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add ABCI queries Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * added index document for swagger documentation Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add missing routes Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * contract tests added on CCI Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * contract tests job should be in the test suite Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * simplify requirements to test Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * typo Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * build is a prerequisite to start localnet Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * reduce nodejs size, move goodman to get_tools, add docs, fix comments Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * Update scripts/get_tools.sh That's cleaner, thanks! Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * xz not supported by cci image, let's keep it simple Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * REMOVE-indirect debug of CCI paths Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * dirty experiment, volume is empty but binary has been produced Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * dirty experiment, volume is empty but binary has been produced Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * dirty experiment going on Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * locally works, CCI have difficulties with second layaer containers volumes Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * restore experiment, use machine instead of docker for contract tests Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * simplify a bit Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * rollback on machine golang Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * Document the changes Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * Changelog Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * comments Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com>
5 years ago
[RPC] Static swagger (#3880) * manually swagging Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * three definitions with polymorphism Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * added blockchain and block Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * low quality generation, commit, block_response and validators Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * genesis and consensus states endpoints Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * fix indentation Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * consensus parameters Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * fix indentation Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add height to consensus parameters endpoint Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * unconfirmed_txs and num_unconfirmed_txs Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add missing query parameter Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add ABCI queries Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * added index document for swagger documentation Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * add missing routes Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * contract tests added on CCI Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * contract tests job should be in the test suite Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * simplify requirements to test Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * typo Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * build is a prerequisite to start localnet Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * reduce nodejs size, move goodman to get_tools, add docs, fix comments Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * Update scripts/get_tools.sh That's cleaner, thanks! Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * xz not supported by cci image, let's keep it simple Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * REMOVE-indirect debug of CCI paths Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * dirty experiment, volume is empty but binary has been produced Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * dirty experiment, volume is empty but binary has been produced Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * dirty experiment going on Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * locally works, CCI have difficulties with second layaer containers volumes Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * restore experiment, use machine instead of docker for contract tests Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * simplify a bit Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * rollback on machine golang Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * Document the changes Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * Changelog Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * comments Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com>
5 years ago
build: Make sure to test packages with external tests (backport #7608) (#7635) * build: Make sure to test packages with external tests (#7608) The test filter was looking for "TestGoFiles", which does not include tests in a separate package (e.g., "package foo_test" for "package foo"). This caused several packages not to be tested in CI, including: github.com/tendermint/tendermint/abci/client github.com/tendermint/tendermint/crypto github.com/tendermint/tendermint/crypto/tmhash github.com/tendermint/tendermint/internal/eventbus github.com/tendermint/tendermint/internal/evidence github.com/tendermint/tendermint/internal/inspect github.com/tendermint/tendermint/internal/jsontypes github.com/tendermint/tendermint/internal/libs/protoio github.com/tendermint/tendermint/internal/libs/sync github.com/tendermint/tendermint/internal/p2p/pex github.com/tendermint/tendermint/internal/pubsub github.com/tendermint/tendermint/internal/pubsub/query github.com/tendermint/tendermint/internal/pubsub/query/syntax github.com/tendermint/tendermint/internal/state/indexer github.com/tendermint/tendermint/internal/state/indexer/block/kv github.com/tendermint/tendermint/libs/json github.com/tendermint/tendermint/libs/log github.com/tendermint/tendermint/libs/os github.com/tendermint/tendermint/light github.com/tendermint/tendermint/light/provider/http github.com/tendermint/tendermint/privval/grpc github.com/tendermint/tendermint/proto/tendermint/blocksync github.com/tendermint/tendermint/proto/tendermint/consensus github.com/tendermint/tendermint/proto/tendermint/statesync github.com/tendermint/tendermint/rpc/client github.com/tendermint/tendermint/rpc/client/mock github.com/tendermint/tendermint/test/e2e/tests github.com/tendermint/tendermint/test/fuzz/mempool github.com/tendermint/tendermint/test/fuzz/p2p/secretconnection github.com/tendermint/tendermint/test/fuzz/rpc/jsonrpc/server Updates #7626 and #7634. (cherry picked from commit aea428d322a557c1618e2a39882c683684c2ebb4) * Fix build tags to satisfy Go 1.16. Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
2 years ago
build: Make sure to test packages with external tests (backport #7608) (#7635) * build: Make sure to test packages with external tests (#7608) The test filter was looking for "TestGoFiles", which does not include tests in a separate package (e.g., "package foo_test" for "package foo"). This caused several packages not to be tested in CI, including: github.com/tendermint/tendermint/abci/client github.com/tendermint/tendermint/crypto github.com/tendermint/tendermint/crypto/tmhash github.com/tendermint/tendermint/internal/eventbus github.com/tendermint/tendermint/internal/evidence github.com/tendermint/tendermint/internal/inspect github.com/tendermint/tendermint/internal/jsontypes github.com/tendermint/tendermint/internal/libs/protoio github.com/tendermint/tendermint/internal/libs/sync github.com/tendermint/tendermint/internal/p2p/pex github.com/tendermint/tendermint/internal/pubsub github.com/tendermint/tendermint/internal/pubsub/query github.com/tendermint/tendermint/internal/pubsub/query/syntax github.com/tendermint/tendermint/internal/state/indexer github.com/tendermint/tendermint/internal/state/indexer/block/kv github.com/tendermint/tendermint/libs/json github.com/tendermint/tendermint/libs/log github.com/tendermint/tendermint/libs/os github.com/tendermint/tendermint/light github.com/tendermint/tendermint/light/provider/http github.com/tendermint/tendermint/privval/grpc github.com/tendermint/tendermint/proto/tendermint/blocksync github.com/tendermint/tendermint/proto/tendermint/consensus github.com/tendermint/tendermint/proto/tendermint/statesync github.com/tendermint/tendermint/rpc/client github.com/tendermint/tendermint/rpc/client/mock github.com/tendermint/tendermint/test/e2e/tests github.com/tendermint/tendermint/test/fuzz/mempool github.com/tendermint/tendermint/test/fuzz/p2p/secretconnection github.com/tendermint/tendermint/test/fuzz/rpc/jsonrpc/server Updates #7626 and #7634. (cherry picked from commit aea428d322a557c1618e2a39882c683684c2ebb4) * Fix build tags to satisfy Go 1.16. Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
2 years ago
  1. #!/usr/bin/make -f
  2. BUILDDIR ?= $(CURDIR)/build
  3. BUILD_TAGS?=tendermint
  4. # If building a release, please checkout the version tag to get the correct version setting
  5. ifneq ($(shell git symbolic-ref -q --short HEAD),)
  6. VERSION := unreleased-$(shell git symbolic-ref -q --short HEAD)-$(shell git rev-parse HEAD)
  7. else
  8. VERSION := $(shell git describe)
  9. endif
  10. LD_FLAGS = -X github.com/tendermint/tendermint/version.TMVersion=$(VERSION)
  11. BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)"
  12. HTTPS_GIT := https://github.com/tendermint/tendermint.git
  13. BUILD_IMAGE := ghcr.io/tendermint/docker-build-proto
  14. BASE_BRANCH := v0.35.x
  15. DOCKER_PROTO := docker run -v $(shell pwd):/workspace --workdir /workspace $(BUILD_IMAGE)
  16. CGO_ENABLED ?= 0
  17. # handle nostrip
  18. ifeq (,$(findstring nostrip,$(TENDERMINT_BUILD_OPTIONS)))
  19. BUILD_FLAGS += -trimpath
  20. LD_FLAGS += -s -w
  21. endif
  22. # handle race
  23. ifeq (race,$(findstring race,$(TENDERMINT_BUILD_OPTIONS)))
  24. CGO_ENABLED=1
  25. BUILD_FLAGS += -race
  26. endif
  27. # handle cleveldb
  28. ifeq (cleveldb,$(findstring cleveldb,$(TENDERMINT_BUILD_OPTIONS)))
  29. CGO_ENABLED=1
  30. BUILD_TAGS += cleveldb
  31. endif
  32. # handle badgerdb
  33. ifeq (badgerdb,$(findstring badgerdb,$(TENDERMINT_BUILD_OPTIONS)))
  34. BUILD_TAGS += badgerdb
  35. endif
  36. # handle rocksdb
  37. ifeq (rocksdb,$(findstring rocksdb,$(TENDERMINT_BUILD_OPTIONS)))
  38. CGO_ENABLED=1
  39. BUILD_TAGS += rocksdb
  40. endif
  41. # handle boltdb
  42. ifeq (boltdb,$(findstring boltdb,$(TENDERMINT_BUILD_OPTIONS)))
  43. BUILD_TAGS += boltdb
  44. endif
  45. # allow users to pass additional flags via the conventional LDFLAGS variable
  46. LD_FLAGS += $(LDFLAGS)
  47. all: check build test install
  48. .PHONY: all
  49. include test/Makefile
  50. ###############################################################################
  51. ### Build Tendermint ###
  52. ###############################################################################
  53. build: $(BUILDDIR)/
  54. CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(BUILDDIR)/ ./cmd/tendermint/
  55. .PHONY: build
  56. install:
  57. CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint
  58. .PHONY: install
  59. $(BUILDDIR)/:
  60. mkdir -p $@
  61. ###############################################################################
  62. ### Protobuf ###
  63. ###############################################################################
  64. proto-all: proto-gen proto-lint proto-check-breaking
  65. .PHONY: proto-all
  66. proto-gen:
  67. @echo "Generating Go packages for .proto files"
  68. @$(DOCKER_PROTO) sh ./scripts/protocgen.sh
  69. .PHONY: proto-gen
  70. proto-lint:
  71. @echo "Running lint checks for .proto files"
  72. @$(DOCKER_PROTO) buf lint --error-format=json
  73. .PHONY: proto-lint
  74. proto-format:
  75. @echo "Formatting .proto files"
  76. @$(DOCKER_PROTO) find ./ -not -path "./third_party/*" -name '*.proto' -exec clang-format -i {} \;
  77. .PHONY: proto-format
  78. proto-check-breaking:
  79. @echo "Checking for breaking changes in .proto files"
  80. @$(DOCKER_PROTO) buf breaking --against .git#branch=$(BASE_BRANCH)
  81. .PHONY: proto-check-breaking
  82. proto-check-breaking-ci:
  83. @echo "Checking for breaking changes in .proto files"
  84. @$(DOCKER_PROTO) buf breaking --against $(HTTPS_GIT)#branch=$(BASE_BRANCH)
  85. .PHONY: proto-check-breaking-ci
  86. ###############################################################################
  87. ### Build ABCI ###
  88. ###############################################################################
  89. build_abci:
  90. @go build -mod=readonly -i ./abci/cmd/...
  91. .PHONY: build_abci
  92. install_abci:
  93. @go install -mod=readonly ./abci/cmd/...
  94. .PHONY: install_abci
  95. ###############################################################################
  96. ### Privval Server ###
  97. ###############################################################################
  98. build_privval_server:
  99. @go build -mod=readonly -o $(BUILDDIR)/ -i ./cmd/priv_val_server/...
  100. .PHONY: build_privval_server
  101. generate_test_cert:
  102. # generate self signing ceritificate authority
  103. @certstrap init --common-name "root CA" --expires "20 years"
  104. # generate server cerificate
  105. @certstrap request-cert -cn server -ip 127.0.0.1
  106. # self-sign server cerificate with rootCA
  107. @certstrap sign server --CA "root CA"
  108. # generate client cerificate
  109. @certstrap request-cert -cn client -ip 127.0.0.1
  110. # self-sign client cerificate with rootCA
  111. @certstrap sign client --CA "root CA"
  112. .PHONY: generate_test_cert
  113. ###############################################################################
  114. ### Distribution ###
  115. ###############################################################################
  116. # dist builds binaries for all platforms and packages them for distribution
  117. # TODO add abci to these scripts
  118. dist:
  119. @BUILD_TAGS=$(BUILD_TAGS) sh -c "'$(CURDIR)/scripts/dist.sh'"
  120. .PHONY: dist
  121. go-mod-cache: go.sum
  122. @echo "--> Download go modules to local cache"
  123. @go mod download
  124. .PHONY: go-mod-cache
  125. go.sum: go.mod
  126. @echo "--> Ensure dependencies have not been modified"
  127. @go mod verify
  128. @go mod tidy
  129. draw_deps:
  130. @# requires brew install graphviz or apt-get install graphviz
  131. go get github.com/RobotsAndPencils/goviz
  132. @goviz -i github.com/tendermint/tendermint/cmd/tendermint -d 3 | dot -Tpng -o dependency-graph.png
  133. .PHONY: draw_deps
  134. get_deps_bin_size:
  135. @# Copy of build recipe with additional flags to perform binary size analysis
  136. $(eval $(shell go build -work -a $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(BUILDDIR)/ ./cmd/tendermint/ 2>&1))
  137. @find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log
  138. @echo "Results can be found here: $(CURDIR)/deps_bin_size.log"
  139. .PHONY: get_deps_bin_size
  140. ###############################################################################
  141. ### Libs ###
  142. ###############################################################################
  143. # generates certificates for TLS testing in remotedb and RPC server
  144. gen_certs: clean_certs
  145. certstrap init --common-name "tendermint.com" --passphrase ""
  146. certstrap request-cert --common-name "server" -ip "127.0.0.1" --passphrase ""
  147. certstrap sign "server" --CA "tendermint.com" --passphrase ""
  148. mv out/server.crt rpc/jsonrpc/server/test.crt
  149. mv out/server.key rpc/jsonrpc/server/test.key
  150. rm -rf out
  151. .PHONY: gen_certs
  152. # deletes generated certificates
  153. clean_certs:
  154. rm -f rpc/jsonrpc/server/test.crt
  155. rm -f rpc/jsonrpc/server/test.key
  156. .PHONY: clean_certs
  157. ###############################################################################
  158. ### Formatting, linting, and vetting ###
  159. ###############################################################################
  160. format:
  161. find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s
  162. find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/tendermint/tendermint
  163. .PHONY: format
  164. lint:
  165. @echo "--> Running linter"
  166. go run github.com/golangci/golangci-lint/cmd/golangci-lint run
  167. .PHONY: lint
  168. DESTINATION = ./index.html.md
  169. ###############################################################################
  170. ### Documentation ###
  171. ###############################################################################
  172. # todo remove once tendermint.com DNS is solved
  173. build-docs:
  174. @cd docs && \
  175. while read -r branch path_prefix; do \
  176. (git checkout $${branch} && npm ci && VUEPRESS_BASE="/$${path_prefix}/" npm run build) ; \
  177. mkdir -p ~/output/$${path_prefix} ; \
  178. cp -r .vuepress/dist/* ~/output/$${path_prefix}/ ; \
  179. cp ~/output/$${path_prefix}/index.html ~/output ; \
  180. done < versions ; \
  181. mkdir -p ~/output/master ; \
  182. cp -r .vuepress/dist/* ~/output/master/
  183. .PHONY: build-docs
  184. ###############################################################################
  185. ### Docker image ###
  186. ###############################################################################
  187. build-docker: build-linux
  188. cp $(BUILDDIR)/tendermint DOCKER/tendermint
  189. docker build --label=tendermint --tag="tendermint/tendermint" -f DOCKER/Dockerfile .
  190. rm -rf DOCKER/tendermint
  191. .PHONY: build-docker
  192. ###############################################################################
  193. ### Mocks ###
  194. ###############################################################################
  195. mockery:
  196. go generate -run="./scripts/mockery_generate.sh" ./...
  197. .PHONY: mockery
  198. ###############################################################################
  199. ### Local testnet using docker ###
  200. ###############################################################################
  201. # Build linux binary on other platforms
  202. build-linux:
  203. GOOS=linux GOARCH=amd64 $(MAKE) build
  204. .PHONY: build-linux
  205. build-docker-localnode:
  206. @cd networks/local && make
  207. .PHONY: build-docker-localnode
  208. # Runs `make build TENDERMINT_BUILD_OPTIONS=cleveldb` from within an Amazon
  209. # Linux (v2)-based Docker build container in order to build an Amazon
  210. # Linux-compatible binary. Produces a compatible binary at ./build/tendermint
  211. build_c-amazonlinux:
  212. $(MAKE) -C ./DOCKER build_amazonlinux_buildimage
  213. docker run --rm -it -v `pwd`:/tendermint tendermint/tendermint:build_c-amazonlinux
  214. .PHONY: build_c-amazonlinux
  215. # Run a 4-node testnet locally
  216. localnet-start: localnet-stop build-docker-localnode
  217. @if ! [ -f build/node0/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/tendermint:Z tendermint/localnode testnet --config /etc/tendermint/config-template.toml --o . --starting-ip-address 192.167.10.2; fi
  218. docker-compose up
  219. .PHONY: localnet-start
  220. # Stop testnet
  221. localnet-stop:
  222. docker-compose down
  223. .PHONY: localnet-stop
  224. # Build hooks for dredd, to skip or add information on some steps
  225. build-contract-tests-hooks:
  226. ifeq ($(OS),Windows_NT)
  227. go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests.exe ./cmd/contract_tests
  228. else
  229. go build -mod=readonly $(BUILD_FLAGS) -o build/contract_tests ./cmd/contract_tests
  230. endif
  231. .PHONY: build-contract-tests-hooks
  232. # Run a nodejs tool to test endpoints against a localnet
  233. # The command takes care of starting and stopping the network
  234. # prerequisits: build-contract-tests-hooks build-linux
  235. # the two build commands were not added to let this command run from generic containers or machines.
  236. # The binaries should be built beforehand
  237. contract-tests:
  238. dredd
  239. .PHONY: contract-tests
  240. clean:
  241. rm -rf $(CURDIR)/artifacts/ $(BUILDDIR)/
  242. build-reproducible:
  243. docker rm latest-build || true
  244. docker run --volume=$(CURDIR):/sources:ro \
  245. --env TARGET_PLATFORMS='linux/amd64 linux/arm64 darwin/amd64 windows/amd64' \
  246. --env APP=tendermint \
  247. --env COMMIT=$(shell git rev-parse --short=8 HEAD) \
  248. --env VERSION=$(shell git describe --tags) \
  249. --name latest-build cosmossdk/rbuilder:latest
  250. docker cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/
  251. .PHONY: build-reproducible
  252. # Implements test splitting and running. This is pulled directly from
  253. # the github action workflows for better local reproducibility.
  254. GO_TEST_FILES != find $(CURDIR) -name "*_test.go"
  255. # default to four splits by default
  256. NUM_SPLIT ?= 4
  257. $(BUILDDIR):
  258. mkdir -p $@
  259. # The format statement filters out all packages that don't have tests.
  260. # Note we need to check for both in-package tests (.TestGoFiles) and
  261. # out-of-package tests (.XTestGoFiles).
  262. $(BUILDDIR)/packages.txt:$(GO_TEST_FILES) $(BUILDDIR)
  263. go list -f "{{ if (or .TestGoFiles .XTestGoFiles) }}{{ .ImportPath }}{{ end }}" ./... | sort > $@
  264. split-test-packages:$(BUILDDIR)/packages.txt
  265. split -d -n l/$(NUM_SPLIT) $< $<.
  266. test-group-%:split-test-packages
  267. cat $(BUILDDIR)/packages.txt.$* | xargs go test -mod=readonly -timeout=15m -race -coverprofile=$(BUILDDIR)/$*.profile.out