github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/Makefile (about) 1 #!/usr/bin/make -f 2 3 PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation') 4 PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') 5 VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//') 6 COMMIT := $(shell git log -1 --format='%H') 7 LEDGER_ENABLED ?= true 8 BINDIR ?= $(GOPATH)/bin 9 SIMAPP = ./simapp 10 MOCKS_DIR = $(CURDIR)/tests/mocks 11 12 export GO111MODULE = on 13 14 all: tools build lint test 15 16 # The below include contains the tools and runsim targets. 17 include contrib/devtools/Makefile 18 19 ######################################## 20 ### Build 21 22 build: go.sum 23 @go build -mod=readonly ./... 24 .PHONY: build 25 26 update-swagger-docs: statik 27 $(BINDIR)/statik -src=client/lcd/swagger-ui -dest=client/lcd -f -m 28 @if [ -n "$(git status --porcelain)" ]; then \ 29 echo "\033[91mSwagger docs are out of sync!!!\033[0m";\ 30 exit 1;\ 31 else \ 32 echo "\033[92mSwagger docs are in sync\033[0m";\ 33 fi 34 .PHONY: update-swagger-docs 35 36 mocks: $(MOCKS_DIR) 37 mockgen -source=x/auth/types/account_retriever.go -package mocks -destination tests/mocks/account_retriever.go 38 mockgen -source=types/handler.go -package mocks -destination tests/mocks/types_handler.go 39 .PHONY: mocks 40 41 $(MOCKS_DIR): 42 mkdir -p $(MOCKS_DIR) 43 44 ######################################## 45 ### Tools & dependencies 46 47 go-mod-cache: go.sum 48 @echo "--> Download go modules to local cache" 49 @go mod download 50 .PHONY: go-mod-cache 51 52 go.sum: go.mod 53 @echo "--> Ensure dependencies have not been modified" 54 @go mod verify 55 @go mod tidy 56 57 distclean: 58 rm -rf \ 59 gitian-build-darwin/ \ 60 gitian-build-linux/ \ 61 gitian-build-windows/ \ 62 .gitian-builder-cache/ 63 .PHONY: distclean 64 65 ######################################## 66 ### Documentation 67 68 godocs: 69 @echo "--> Wait a few seconds and visit http://localhost:6060/pkg/github.com/cosmos/cosmos-sdk/types" 70 godoc -http=:6060 71 72 build-docs: 73 @cd docs && \ 74 while read p; do \ 75 (git checkout $${p} && npm install && VUEPRESS_BASE="/$${p}/" npm run build) ; \ 76 mkdir -p ~/output/$${p} ; \ 77 cp -r .vuepress/dist/* ~/output/$${p}/ ; \ 78 cp ~/output/$${p}/index.html ~/output ; \ 79 done < versions ; 80 81 sync-docs: 82 cd ~/output && \ 83 echo "role_arn = ${DEPLOYMENT_ROLE_ARN}" >> /root/.aws/config ; \ 84 echo "CI job = ${CIRCLE_BUILD_URL}" >> version.html ; \ 85 aws s3 sync . s3://${WEBSITE_BUCKET} --profile terraform --delete ; \ 86 aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --profile terraform --path "/*" ; 87 .PHONY: sync-docs 88 89 ######################################## 90 ### Testing 91 92 test: test-unit 93 test-all: test-unit test-ledger-mock test-race test-cover 94 95 test-ledger-mock: 96 @go test -mod=readonly `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger test_ledger_mock' 97 98 test-ledger: test-ledger-mock 99 @go test -mod=readonly -v `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger' 100 101 test-unit: 102 @VERSION=$(VERSION) go test -mod=readonly $(PACKAGES_NOSIMULATION) -tags='ledger test_ledger_mock' 103 104 test-race: 105 @VERSION=$(VERSION) go test -mod=readonly -race $(PACKAGES_NOSIMULATION) 106 107 .PHONY: test test-all test-ledger-mock test-ledger test-unit test-race 108 109 test-sim-nondeterminism: 110 @echo "Running non-determinism test..." 111 @go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \ 112 -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h 113 114 test-sim-custom-genesis-fast: 115 @echo "Running custom genesis simulation..." 116 @echo "By default, ${HOME}/.gaiad/config/genesis.json will be used." 117 @go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.gaiad/config/genesis.json \ 118 -Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h 119 120 test-sim-import-export: runsim 121 @echo "Running application import/export simulation. This may take several minutes..." 122 @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 5 TestAppImportExport 123 124 test-sim-after-import: runsim 125 @echo "Running application simulation-after-import. This may take several minutes..." 126 @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 5 TestAppSimulationAfterImport 127 128 test-sim-custom-genesis-multi-seed: runsim 129 @echo "Running multi-seed custom genesis simulation..." 130 @echo "By default, ${HOME}/.gaiad/config/genesis.json will be used." 131 @$(BINDIR)/runsim -Genesis=${HOME}/.gaiad/config/genesis.json -SimAppPkg=$(SIMAPP) 400 5 TestFullAppSimulation 132 133 test-sim-multi-seed-long: runsim 134 @echo "Running long multi-seed application simulation. This may take awhile!" 135 @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 500 50 TestFullAppSimulation 136 137 test-sim-multi-seed-short: runsim 138 @echo "Running short multi-seed application simulation. This may take awhile!" 139 @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 10 TestFullAppSimulation 140 141 test-sim-benchmark-invariants: 142 @echo "Running simulation invariant benchmarks..." 143 @go test -mod=readonly $(SIMAPP) -benchmem -bench=BenchmarkInvariants -run=^$ \ 144 -Enabled=true -NumBlocks=1000 -BlockSize=200 \ 145 -Period=1 -Commit=true -Seed=57 -v -timeout 24h 146 147 .PHONY: \ 148 test-sim-nondeterminism \ 149 test-sim-custom-genesis-fast \ 150 test-sim-import-export \ 151 test-sim-after-import \ 152 test-sim-custom-genesis-multi-seed \ 153 test-sim-multi-seed-short \ 154 test-sim-multi-seed-long \ 155 test-sim-benchmark-invariants 156 157 SIM_NUM_BLOCKS ?= 500 158 SIM_BLOCK_SIZE ?= 200 159 SIM_COMMIT ?= true 160 161 test-sim-benchmark: 162 @echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!" 163 @go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \ 164 -Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h 165 166 test-sim-profile: 167 @echo "Running application benchmark for numBlocks=$(SIM_NUM_BLOCKS), blockSize=$(SIM_BLOCK_SIZE). This may take awhile!" 168 @go test -mod=readonly -benchmem -run=^$$ $(SIMAPP) -bench ^BenchmarkFullAppSimulation$$ \ 169 -Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h -cpuprofile cpu.out -memprofile mem.out 170 171 .PHONY: test-sim-profile test-sim-benchmark 172 173 test-cover: 174 @export VERSION=$(VERSION); bash -x tests/test_cover.sh 175 .PHONY: test-cover 176 177 lint: golangci-lint 178 $(BINDIR)/golangci-lint run 179 find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s 180 go mod verify 181 .PHONY: lint 182 183 format: tools 184 find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s 185 find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w 186 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 187 .PHONY: format 188 189 benchmark: 190 @go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION) 191 .PHONY: benchmark 192 193 ######################################## 194 ### Devdoc 195 196 DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local 197 198 devdoc-init: 199 docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" tendermint/devdoc echo 200 # TODO make this safer 201 $(call DEVDOC_SAVE) 202 203 devdoc: 204 docker run -it -v "$(CURDIR):/go/src/github.com/cosmos/cosmos-sdk" -w "/go/src/github.com/cosmos/cosmos-sdk" devdoc:local bash 205 206 devdoc-save: 207 # TODO make this safer 208 $(call DEVDOC_SAVE) 209 210 devdoc-clean: 211 docker rmi -f $$(docker images -f "dangling=true" -q) 212 213 devdoc-update: 214 docker pull tendermint/devdoc 215 216 .PHONY: devdoc devdoc-clean devdoc-init devdoc-save devdoc-update