Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardise and clean up Makefile #5025

Merged
merged 7 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ commands:
make << parameters.target >>

jobs:
build_docs:
build-docs:
executor: docs
steps:
- checkout
Expand All @@ -46,7 +46,7 @@ jobs:
name: "Upload docs to S3"
command: make sync-docs

setup_dependencies:
setup-dependencies:
executor: golang
steps:
- checkout
Expand Down Expand Up @@ -74,42 +74,42 @@ jobs:
paths:
- ".git"

test_sim_nondeterminism:
test-sim-nondeterminism:
executor: golang
steps:
- make:
target: test_sim_nondeterminism
target: test-sim-nondeterminism
description: "Test individual module simulations"

test_sim_import_export:
test-sim-import-export:
executor: golang
steps:
- make:
target: test_sim_import_export
target: test-sim-import-export
description: "Test application import/export simulation"

test_sim_after_import:
test-sim-after-import:
executor: golang
steps:
- make:
target: test_sim_after_import
target: test-sim-after-import
description: "Test simulation after import"

test_sim_multi_seed_long:
test-sim-multi-seed-long:
executor: golang
steps:
- make:
target: test_sim_multi_seed_long
target: test-sim-multi-seed-long
description: "Test multi-seed simulation (long)"

test_sim_multi_seed_short:
test-sim-multi-seed-short:
executor: golang
steps:
- make:
target: test_sim_multi_seed_short
target: test-sim-multi-seed-short
description: "Test multi-seed simulation (short)"

test_cover:
test-cover:
executor: golang
parallelism: 4
steps:
Expand All @@ -134,7 +134,7 @@ jobs:
- store_artifacts:
path: /tmp/logs

upload_coverage:
upload-coverage:
executor: golang
steps:
- attach_workspace:
Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:
name: upload
command: bash <(curl -s https://codecov.io/bash) -f coverage.txt

check_statik:
update-swagger-docs:
executor: golang
steps:
- make:
Expand All @@ -173,44 +173,44 @@ workflows:
version: 2
test-suite:
jobs:
- check_statik:
- update-swagger-docs:
requires:
- setup_dependencies
- setup_dependencies:
- setup-dependencies
- setup-dependencies:
# This filter enables the job for tags
filters:
tags:
only:
- /^v.*/
- test_sim_nondeterminism:
- test-sim-nondeterminism:
requires:
- setup_dependencies
- test_sim_import_export:
- setup-dependencies
- test-sim-import-export:
requires:
- setup_dependencies
- test_sim_after_import:
- setup-dependencies
- test-sim-after-import:
requires:
- setup_dependencies
- test_sim_multi_seed_short:
- setup-dependencies
- test-sim-multi-seed-short:
requires:
- setup_dependencies
- test_sim_multi_seed_long:
- setup-dependencies
- test-sim-multi-seed-long:
requires:
- setup_dependencies
- setup-dependencies
# These filters ensure that the long sim only runs during release
filters:
branches:
ignore: /.*/
tags:
only:
- /^v.*/
- test_cover:
- test-cover:
requires:
- setup_dependencies
- upload_coverage:
- setup-dependencies
- upload-coverage:
requires:
- test_cover
- build_docs:
- test-cover
- build-docs:
context: docs-deployment-master
filters:
branches:
Expand All @@ -219,7 +219,7 @@ workflows:
tags:
ignore:
- /^v.*/
- build_docs:
- build-docs:
context: docs-deployment-release
filters:
branches:
Expand Down
68 changes: 37 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,89 +83,95 @@ sync-docs:
echo "CI job = ${CIRCLE_BUILD_URL}" >> version.html ; \
aws s3 sync . s3://${WEBSITE_BUCKET} --profile terraform --delete ; \
aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --profile terraform --path "/*" ;
.PHONY: sync_docs
.PHONY: sync-docs

########################################
### Testing

test: test_unit
test: test-unit
test-all: test-unit test-ledger-mock test-race test-cover

test_ledger_mock:
test-ledger-mock:
@go test -mod=readonly `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger test_ledger_mock'

test_ledger: test_ledger_mock
test-ledger: test-ledger-mock
@go test -mod=readonly -v `go list github.com/cosmos/cosmos-sdk/crypto` -tags='cgo ledger'

test_unit:
test-unit:
@VERSION=$(VERSION) go test -mod=readonly $(PACKAGES_NOSIMULATION) -tags='ledger test_ledger_mock'

test_race:
test-race:
@VERSION=$(VERSION) go test -mod=readonly -race $(PACKAGES_NOSIMULATION)

test_sim_nondeterminism:
.PHONY: test test-all test-ledger-mock test-ledger test-unit test-race

test-sim-nondeterminism:
@echo "Running non-determinism test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h

test_sim_custom_genesis_fast:
test-sim-custom-genesis-fast:
@echo "Running custom genesis simulation..."
@echo "By default, ${HOME}/.gaiad/config/genesis.json will be used."
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.gaiad/config/genesis.json \
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h

test_sim_import_export: runsim
test-sim-import-export: runsim
@echo "Running application import/export simulation. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 5 TestAppImportExport

test_sim_after_import: runsim
test-sim-after-import: runsim
@echo "Running application simulation-after-import. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 5 TestAppSimulationAfterImport

test_sim_custom_genesis_multi_seed: runsim
test-sim-custom-genesis-multi-seed: runsim
@echo "Running multi-seed custom genesis simulation..."
@echo "By default, ${HOME}/.gaiad/config/genesis.json will be used."
@$(BINDIR)/runsim -Genesis=${HOME}/.gaiad/config/genesis.json -SimAppPkg=$(SIMAPP) 400 5 TestFullAppSimulation

test_sim_multi_seed_long: runsim
test-sim-multi-seed-long: runsim
@echo "Running long multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 500 50 TestFullAppSimulation

test_sim_multi_seed_short: runsim
test-sim-multi-seed-short: runsim
@echo "Running short multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 10 TestFullAppSimulation

test_sim_benchmark_invariants:
test-sim-benchmark-invariants:
@echo "Running simulation invariant benchmarks..."
@go test -mod=readonly $(SIMAPP) -benchmem -bench=BenchmarkInvariants -run=^$ \
-Enabled=true -NumBlocks=1000 -BlockSize=200 \
-Period=1 -Commit=true -Seed=57 -v -timeout 24h

.PHONY: test \
test_sim_nondeterminism \
test_sim_custom_genesis_fast \
test_sim_import_export \
test_sim_after_import \
test_sim_custom_genesis_multi_seed \
test_sim_multi_seed \
test_sim_multi_seed_short \
test_sim_benchmark_invariants
.PHONY: \
test-sim-nondeterminism \
test-sim-custom-genesis-fast \
test-sim-import-export \
test-sim-after-import \
test-sim-custom-genesis-multi-seed \
test-sim-multi-seed-short \
test-sim-multi-seed-long \
test-sim-benchmark-invariants

SIM_NUM_BLOCKS ?= 500
SIM_BLOCK_SIZE ?= 200
SIM_COMMIT ?= true

test_sim_benchmark:
test-sim-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$$ \
-Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h

test_sim_profile:
test-sim-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$$ \
-Enabled=true -NumBlocks=$(SIM_NUM_BLOCKS) -BlockSize=$(SIM_BLOCK_SIZE) -Commit=$(SIM_COMMIT) -timeout 24h -cpuprofile cpu.out -memprofile mem.out

test_cover:
.PHONY: test-sim-profile test-sim-benchmark

test-cover:
@export VERSION=$(VERSION); bash -x tests/test_cover.sh
.PHONY: test-cover

lint: golangci-lint
$(BINDIR)/golangci-lint run
Expand All @@ -188,22 +194,22 @@ benchmark:

DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local

devdoc_init:
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:
devdoc-save:
# TODO make this safer
$(call DEVDOC_SAVE)

devdoc_clean:
devdoc-clean:
docker rmi -f $$(docker images -f "dangling=true" -q)

devdoc_update:
devdoc-update:
docker pull tendermint/devdoc

.PHONY: devdoc devdoc_clean devdoc_init devdoc_save devdoc_update
.PHONY: devdoc devdoc-clean devdoc-init devdoc-save devdoc-update
10 changes: 2 additions & 8 deletions contrib/devtools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ TOOLS_DESTDIR ?= $(GOPATH)/bin

GOLANGCI_LINT = $(TOOLS_DESTDIR)/golangci-lint
STATIK = $(TOOLS_DESTDIR)/statik
GOIMPORTS = $(TOOLS_DESTDIR)/goimports
RUNSIM = $(TOOLS_DESTDIR)/runsim

all: tools

tools: statik runsim goimports golangci-lint
tools: statik runsim golangci-lint

golangci-lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT): $(mkfile_dir)/install-golangci-lint.sh
Expand All @@ -60,18 +59,13 @@ $(STATIK):
@echo "Get statik"
@go get github.com/rakyll/statik

goimports: $(GOIMPORTS)
$(GOIMPORTS):
@echo "Get goimports@v0.0.0-20190628034336-212fb13d595e"
@go get golang.org/x/tools/cmd/goimports@v0.0.0-20190628034336-212fb13d595e

runsim: $(RUNSIM)
$(RUNSIM):
@echo "Get runsim"
@go get github.com/cosmos/tools/cmd/runsim

tools-clean:
rm -f $(STATIK) $(GOIMPORTS) $(GOLANGCI_LINT) $(RUNSIM)
rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM)
rm -f tools-stamp

.PHONY: all tools tools-clean