2019-04-15 06:00:28 -07:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
2018-07-25 13:47:00 -07:00
|
|
|
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
|
|
|
|
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
|
2019-01-29 21:00:06 -08:00
|
|
|
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
|
2019-01-22 12:16:29 -08:00
|
|
|
COMMIT := $(shell git log -1 --format='%H')
|
2018-07-13 19:17:53 -07:00
|
|
|
LEDGER_ENABLED ?= true
|
2019-05-13 15:33:34 -07:00
|
|
|
BINDIR ?= $(GOPATH)/bin
|
2019-05-18 01:42:24 -07:00
|
|
|
SIMAPP = github.com/cosmos/cosmos-sdk/simapp
|
2019-06-19 05:24:11 -07:00
|
|
|
MOCKS_DIR = $(CURDIR)/tests/mocks
|
2019-03-18 05:45:25 -07:00
|
|
|
|
|
|
|
export GO111MODULE = on
|
2019-01-24 02:18:45 -08:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
all: tools build lint test
|
2019-03-04 12:31:55 -08:00
|
|
|
|
|
|
|
# The below include contains the tools target.
|
2019-04-09 02:41:00 -07:00
|
|
|
include contrib/devtools/Makefile
|
2019-03-04 12:31:55 -08:00
|
|
|
|
|
|
|
########################################
|
|
|
|
### CI
|
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
ci: tools build test_cover lint test
|
2019-03-04 12:31:55 -08:00
|
|
|
|
|
|
|
########################################
|
2019-05-18 01:42:24 -07:00
|
|
|
### Build
|
2019-03-04 12:31:55 -08:00
|
|
|
|
2019-03-18 05:45:25 -07:00
|
|
|
build: go.sum
|
2019-05-18 01:42:24 -07:00
|
|
|
@go build -mod=readonly ./...
|
2018-07-13 19:17:53 -07:00
|
|
|
|
2019-05-28 06:46:26 -07:00
|
|
|
update-swagger-docs:
|
|
|
|
@statik -src=client/lcd/swagger-ui -dest=client/lcd -f -m
|
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
dist:
|
|
|
|
@bash publish/dist.sh
|
|
|
|
@bash publish/publish.sh
|
2017-01-28 09:29:32 -08:00
|
|
|
|
2019-06-19 05:24:11 -07:00
|
|
|
mocks: $(MOCKS_DIR)
|
|
|
|
mockgen -source=x/auth/types/account_retriever.go -package mocks -destination tests/mocks/account_retriever.go
|
|
|
|
|
|
|
|
$(MOCKS_DIR):
|
|
|
|
mkdir -p $(MOCKS_DIR)
|
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
|
|
|
### Tools & dependencies
|
2017-08-30 11:42:24 -07:00
|
|
|
|
2019-03-18 05:45:25 -07:00
|
|
|
go-mod-cache: go.sum
|
|
|
|
@echo "--> Download go modules to local cache"
|
|
|
|
@go mod download
|
2018-08-28 09:53:56 -07:00
|
|
|
|
2019-05-02 09:30:29 -07:00
|
|
|
go.sum: go.mod
|
2019-03-19 09:52:43 -07:00
|
|
|
@echo "--> Ensure dependencies have not been modified"
|
2019-03-18 05:45:25 -07:00
|
|
|
@go mod verify
|
2019-07-04 07:54:06 -07:00
|
|
|
@go mod tidy
|
2018-01-16 11:23:32 -08:00
|
|
|
|
2018-12-20 10:03:59 -08:00
|
|
|
clean:
|
2019-04-01 18:01:12 -07:00
|
|
|
rm -rf snapcraft-local.yaml build/
|
2018-01-16 11:23:32 -08:00
|
|
|
|
2019-05-13 15:33:34 -07:00
|
|
|
distclean: clean
|
|
|
|
rm -rf \
|
|
|
|
gitian-build-darwin/ \
|
|
|
|
gitian-build-linux/ \
|
|
|
|
gitian-build-windows/ \
|
|
|
|
.gitian-builder-cache/
|
2019-01-29 14:25:43 -08:00
|
|
|
|
2018-01-20 15:03:35 -08:00
|
|
|
########################################
|
|
|
|
### Documentation
|
|
|
|
|
|
|
|
godocs:
|
|
|
|
@echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/cosmos-sdk/types"
|
|
|
|
godoc -http=:6060
|
|
|
|
|
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
|
|
|
### Testing
|
|
|
|
|
2018-05-07 15:44:03 -07:00
|
|
|
test: test_unit
|
2017-06-15 08:16:00 -07:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_ledger_mock:
|
|
|
|
@go test -mod=readonly `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger test_ledger_mock'
|
2018-02-20 13:13:27 -08:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_ledger: test_ledger_mock
|
2019-03-19 09:52:43 -07:00
|
|
|
@go test -mod=readonly -v `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger'
|
2019-02-05 10:21:04 -08:00
|
|
|
|
2017-06-15 12:11:47 -07:00
|
|
|
test_unit:
|
2019-03-19 09:52:43 -07:00
|
|
|
@VERSION=$(VERSION) go test -mod=readonly $(PACKAGES_NOSIMULATION) -tags='ledger test_ledger_mock'
|
2017-01-11 21:07:56 -08:00
|
|
|
|
2018-06-11 18:12:37 -07:00
|
|
|
test_race:
|
2019-03-19 09:52:43 -07:00
|
|
|
@VERSION=$(VERSION) go test -mod=readonly -race $(PACKAGES_NOSIMULATION)
|
2018-06-11 18:12:37 -07:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_sim_app_nondeterminism:
|
2018-08-17 07:19:33 -07:00
|
|
|
@echo "Running nondeterminism test..."
|
2019-05-18 01:42:24 -07:00
|
|
|
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -SimulationEnabled=true -v -timeout 10m
|
2018-08-17 07:19:33 -07:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_sim_app_custom_genesis_fast:
|
2019-01-29 14:53:42 -08:00
|
|
|
@echo "Running custom genesis simulation..."
|
|
|
|
@echo "By default, ${HOME}/.gaiad/config/genesis.json will be used."
|
2019-05-18 01:42:24 -07:00
|
|
|
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -SimulationGenesis=${HOME}/.gaiad/config/genesis.json \
|
2019-01-29 14:53:42 -08:00
|
|
|
-SimulationEnabled=true -SimulationNumBlocks=100 -SimulationBlockSize=200 -SimulationCommit=true -SimulationSeed=99 -SimulationPeriod=5 -v -timeout 24h
|
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_sim_app_fast:
|
|
|
|
@echo "Running quick application simulation. This may take several minutes..."
|
|
|
|
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -SimulationEnabled=true -SimulationNumBlocks=100 -SimulationBlockSize=200 -SimulationCommit=true -SimulationSeed=99 -SimulationPeriod=5 -v -timeout 24h
|
2018-08-16 08:36:15 -07:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_sim_app_import_export: runsim
|
|
|
|
@echo "Running application import/export simulation. This may take several minutes..."
|
|
|
|
$(BINDIR)/runsim -e $(SIMAPP) 25 5 TestAppImportExport
|
2018-11-08 16:28:28 -08:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_sim_app_simulation_after_import: runsim
|
|
|
|
@echo "Running application simulation-after-import. This may take several minutes..."
|
|
|
|
$(BINDIR)/runsim -e $(SIMAPP) 25 5 TestAppSimulationAfterImport
|
2018-11-26 04:21:23 -08:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_sim_app_custom_genesis_multi_seed: runsim
|
2019-01-29 14:53:42 -08:00
|
|
|
@echo "Running multi-seed custom genesis simulation..."
|
|
|
|
@echo "By default, ${HOME}/.gaiad/config/genesis.json will be used."
|
2019-05-18 01:42:24 -07:00
|
|
|
$(BINDIR)/runsim -g ${HOME}/.gaiad/config/genesis.json $(SIMAPP) 400 5 TestFullAppSimulation
|
2019-01-29 14:53:42 -08:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_sim_app_multi_seed: runsim
|
|
|
|
@echo "Running multi-seed application simulation. This may take awhile!"
|
|
|
|
$(BINDIR)/runsim $(SIMAPP) 400 5 TestFullAppSimulation
|
2018-07-11 10:43:25 -07:00
|
|
|
|
2019-04-12 15:52:16 -07:00
|
|
|
test_sim_benchmark_invariants:
|
|
|
|
@echo "Running simulation invariant benchmarks..."
|
2019-05-18 01:42:24 -07:00
|
|
|
@go test -mod=readonly $(SIMAPP) -benchmem -bench=BenchmarkInvariants -run=^$ \
|
2019-04-12 15:52:16 -07:00
|
|
|
-SimulationEnabled=true -SimulationNumBlocks=1000 -SimulationBlockSize=200 \
|
|
|
|
-SimulationCommit=true -SimulationSeed=57 -v -timeout 24h
|
|
|
|
|
2019-04-23 06:01:59 -07:00
|
|
|
# Don't move it into tools - this will be gone once gaia has moved into the new repo
|
2019-05-13 15:33:34 -07:00
|
|
|
runsim: $(BINDIR)/runsim
|
2019-07-04 07:54:06 -07:00
|
|
|
$(BINDIR)/runsim:
|
|
|
|
go get github.com/cosmos/tools/cmd/runsim/
|
|
|
|
go mod tidy
|
2019-04-23 06:01:59 -07:00
|
|
|
|
2018-10-29 16:10:39 -07:00
|
|
|
SIM_NUM_BLOCKS ?= 500
|
2018-09-01 19:04:44 -07:00
|
|
|
SIM_BLOCK_SIZE ?= 200
|
|
|
|
SIM_COMMIT ?= true
|
2019-05-18 01:42:24 -07:00
|
|
|
|
|
|
|
test_sim_app_benchmark:
|
|
|
|
@echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
|
|
|
|
@go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \
|
2019-01-29 14:53:42 -08:00
|
|
|
-SimulationEnabled=true -SimulationNumBlocks=$(SIM_NUM_BLOCKS) -SimulationBlockSize=$(SIM_BLOCK_SIZE) -SimulationCommit=$(SIM_COMMIT) -timeout 24h
|
2018-09-01 19:04:44 -07:00
|
|
|
|
2019-05-18 01:42:24 -07:00
|
|
|
test_sim_app_profile:
|
|
|
|
@echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!"
|
|
|
|
@go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \
|
2019-01-29 14:53:42 -08:00
|
|
|
-SimulationEnabled=true -SimulationNumBlocks=$(SIM_NUM_BLOCKS) -SimulationBlockSize=$(SIM_BLOCK_SIZE) -SimulationCommit=$(SIM_COMMIT) -timeout 24h -cpuprofile cpu.out -memprofile mem.out
|
2018-09-01 19:04:44 -07:00
|
|
|
|
2018-01-17 17:00:48 -08:00
|
|
|
test_cover:
|
2019-02-06 14:45:15 -08:00
|
|
|
@export VERSION=$(VERSION); bash -x tests/test_cover.sh
|
2018-01-17 17:00:48 -08:00
|
|
|
|
2019-06-28 07:11:26 -07:00
|
|
|
lint: golangci-lint
|
2019-03-19 09:52:43 -07:00
|
|
|
golangci-lint run
|
2018-06-27 17:32:06 -07:00
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
|
2019-03-18 05:45:25 -07:00
|
|
|
go mod verify
|
2018-04-27 12:20:12 -07:00
|
|
|
|
2019-03-19 09:52:43 -07:00
|
|
|
format: tools
|
2018-10-04 04:00:24 -07:00
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s
|
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w
|
2018-11-26 11:20:43 -08:00
|
|
|
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/cosmos/cosmos-sdk
|
2018-06-29 00:37:16 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
benchmark:
|
2019-03-19 09:52:43 -07:00
|
|
|
@go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)
|
2017-01-28 09:29:32 -08:00
|
|
|
|
2017-03-14 00:25:42 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
########################################
|
|
|
|
### Devdoc
|
|
|
|
|
|
|
|
DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local
|
|
|
|
|
|
|
|
devdoc_init:
|
|
|
|
docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" tendermint/devdoc echo
|
|
|
|
# TODO make this safer
|
|
|
|
$(call DEVDOC_SAVE)
|
|
|
|
|
|
|
|
devdoc:
|
|
|
|
docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" devdoc:local bash
|
|
|
|
|
|
|
|
devdoc_save:
|
|
|
|
# TODO make this safer
|
|
|
|
$(call DEVDOC_SAVE)
|
|
|
|
|
|
|
|
devdoc_clean:
|
|
|
|
docker rmi -f $$(docker images -f "dangling=true" -q)
|
2017-06-02 09:06:48 -07:00
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
devdoc_update:
|
|
|
|
docker pull tendermint/devdoc
|
2017-03-14 00:25:42 -07:00
|
|
|
|
2017-06-19 05:16:38 -07:00
|
|
|
|
2019-01-28 15:00:17 -08:00
|
|
|
########################################
|
|
|
|
### Packaging
|
|
|
|
|
2019-02-03 16:35:13 -08:00
|
|
|
snapcraft-local.yaml: snapcraft-local.yaml.in
|
2019-01-28 15:00:17 -08:00
|
|
|
sed "s/@VERSION@/${VERSION}/g" < $< > $@
|
|
|
|
|
2018-01-16 11:23:32 -08:00
|
|
|
# To avoid unintended conflicts with file names, always add to .PHONY
|
|
|
|
# unless there is a reason not to.
|
|
|
|
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
|
2019-06-19 05:24:11 -07:00
|
|
|
.PHONY: build dist clean test test_unit test_cover lint mocks \
|
2019-05-18 01:42:24 -07:00
|
|
|
benchmark devdoc_init devdoc devdoc_save devdoc_update runsim \
|
|
|
|
format test_sim_app_nondeterminism test_sim_modules test_sim_app_fast \
|
|
|
|
test_sim_app_custom_genesis_fast test_sim_app_custom_genesis_multi_seed \
|
|
|
|
test_sim_app_multi_seed test_sim_app_import_export test_sim_benchmark_invariants \
|
2019-03-19 09:52:43 -07:00
|
|
|
go-mod-cache
|