From 6fa5fafb12a15935a0c1b41c6f560f5ea5c8f31e Mon Sep 17 00:00:00 2001 From: Daniel Choi Date: Fri, 21 Aug 2020 02:01:19 -0700 Subject: [PATCH] actions: sim, rc-sim (#463) * actions: sim, rc-sim * Update .github/workflows/release-sims.yml Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update .github/workflows/sims.yml Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * bump dep * use development * update Makefile * update Makefile PHONY * fix makefile for tests * attempt fix * change branch * include development branch * make runsim * undo * fix binary typo * WIP: test - hard code binary * try fix * move vars * fix * try go get again * fix * comments; skip-sims * final update; skip-sims Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Federico Kunze --- .github/workflows/release-sims.yml | 42 ++++++++++ .github/workflows/sims.yml | 126 +++++++++++++++++++++++++++++ .github/workflows/stale.yml | 4 +- Makefile | 67 +++++++++++---- go.mod | 2 +- go.sum | 7 +- 6 files changed, 226 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/release-sims.yml create mode 100644 .github/workflows/sims.yml diff --git a/.github/workflows/release-sims.yml b/.github/workflows/release-sims.yml new file mode 100644 index 00000000..04b5d902 --- /dev/null +++ b/.github/workflows/release-sims.yml @@ -0,0 +1,42 @@ +name: Release Sims +# Release Sims workflow runs long-lived (multi-seed & large block size) simulations of 500 blocks. +# This workflow only runs on a pull request when the branch contains rc** (rc1/vX.X.x) +# This release workflow *cannot* be skipped with the 'skip-sims' commit message. +on: + pull_request: + branches: + - "rc**" + +jobs: + cleanup-runs: + runs-on: ubuntu-latest + steps: + - uses: rokroskar/workflow-run-cleanup-action@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/development'" + + install-runsim: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip-sims')" + steps: + - name: install runsim + run: | + export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0 + - uses: actions/cache@v2.1.1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + + test-sim-multi-seed-long: + runs-on: ubuntu-latest + needs: install-runsim + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2.1.1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + - name: test-sim-multi-seed-long + run: | + make test-sim-multi-seed-long diff --git a/.github/workflows/sims.yml b/.github/workflows/sims.yml new file mode 100644 index 00000000..87b7e6f2 --- /dev/null +++ b/.github/workflows/sims.yml @@ -0,0 +1,126 @@ +name: Sims +# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import, multi-seed-short) +# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed. +# The simulations can be skipped if the commit message contains the 'skip-sims' string. +on: + pull_request: + push: + branches: + - development + +jobs: + cleanup-runs: + runs-on: ubuntu-latest + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/development'" + steps: + - uses: rokroskar/workflow-run-cleanup-action@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + install-runsim: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip-sims')" + steps: + - uses: actions/setup-go@v2.1.2 + - name: install runsim + run: | + export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0 + - uses: actions/cache@v2.1.1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + + test-sim-nondeterminism: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip-sims')" + needs: install-runsim + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v3 + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v2.1.1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + if: "env.GIT_DIFF != ''" + - name: test-sim-nondeterminism + run: | + make test-sim-nondeterminism + if: "env.GIT_DIFF != ''" + + test-sim-import-export: + runs-on: ubuntu-latest + needs: install-runsim + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v3 + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v2.1.1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + if: "env.GIT_DIFF != ''" + - name: test-sim-import-export + run: | + make test-sim-import-export + if: "env.GIT_DIFF != ''" + + test-sim-after-import: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip-sims')" + needs: install-runsim + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v3 + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v2.1.1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + if: "env.GIT_DIFF != ''" + - name: test-sim-after-import + run: | + make test-sim-after-import + if: "env.GIT_DIFF != ''" + + test-sim-multi-seed-short: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip-sims')" + needs: install-runsim + steps: + - uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v3 + with: + SUFFIX_FILTER: | + .go + .mod + .sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v2.1.1 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + if: "env.GIT_DIFF != ''" + - name: test-sim-multi-seed-short + run: | + make test-sim-multi-seed-short + if: "env.GIT_DIFF != ''" diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 6cb737e7..e702e12e 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -13,8 +13,8 @@ jobs: stale-pr-message: "This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days-before-close if no further activity occurs. Thank you for your contributions." - stale-issue-message: "This issue is stale because it has been open 30 days with no activity. Remove `stale` label or comment or this will be closed in 7 days." - days-before-stale: 21 + stale-issue-message: "This issue is stale because it has been open 45 days with no activity. Remove `stale` label or comment or this will be closed in 7 days." + days-before-stale: 45 days-before-close: 7 exempt-issue-labels: "Status: On Ice, Status: Blocked, Type: Bug, Type: Security, Type: Meta-Issue, Type: Enhancement, Epic" exempt-pr-labels: "Status: On Ice, Status: Blocked, Type: Bug, Type: Security, Type: Meta-Issue, Type: Enhancement, Epic" diff --git a/Makefile b/Makefile index 39514bb4..04ed5000 100644 --- a/Makefile +++ b/Makefile @@ -22,10 +22,8 @@ DOCKER_IMAGE = cosmos/ethermint ETHERMINT_DAEMON_BINARY = ethermintd ETHERMINT_CLI_BINARY = ethermintcli GO_MOD=GO111MODULE=on -BINDIR ?= $(GOPATH)/bin BUILDDIR ?= $(CURDIR)/build -SIMAPP = github.com/cosmos/ethermint/app -RUNSIM = $(BINDIR)/runsim +SIMAPP = ./app LEDGER_ENABLED ?= true ifeq ($(OS),Windows_NT) @@ -41,6 +39,29 @@ endif export DETECTED_OS export GO111MODULE = on +########################################## +# Find OS and Go environment +# GO contains the Go binary +# FS contains the OS file separator +########################################## + +ifeq ($(OS),Windows_NT) + GO := $(shell where go.exe 2> NUL) + FS := "\\" +else + GO := $(shell command -v go 2> /dev/null) + FS := "/" +endif + +ifeq ($(GO),) + $(error could not find go. Is it in PATH? $(GO)) +endif + +GOPATH ?= $(shell $(GO) env GOPATH) +BINDIR ?= $(GOPATH)/bin +RUNSIM = $(BINDIR)/runsim + + # process build tags build_tags = netgo @@ -128,6 +149,8 @@ install: clean: @rm -rf ./build ./vendor +.PHONY: install clean + docker-build: docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} . docker tag ${DOCKER_IMAGE}:${DOCKER_TAG} ${DOCKER_IMAGE}:latest @@ -148,16 +171,31 @@ docker-localnet: ### Tools & Dependencies ### ############################################################################### +TOOLS_DESTDIR ?= $(GOPATH)/bin +RUNSIM = $(TOOLS_DESTDIR)/runsim + # Install the runsim binary with a temporary workaround of entering an outside # directory as the "go get" command ignores the -mod option and will polute the # go.{mod, sum} files. # # ref: https://github.com/golang/go/issues/30515 +runsim: $(RUNSIM) $(RUNSIM): @echo "Installing runsim..." @(cd /tmp && go get github.com/cosmos/tools/cmd/runsim@v1.0.0) -tools: $(RUNSIM) +tools: tools-stamp +tools-stamp: runsim + # Create dummy file to satisfy dependency and avoid + # rebuilding when this Makefile target is hit twice + # in a row. + touch $@ + +tools-clean: + rm -f $(RUNSIM) + rm -f tools-stamp + +.PHONY: runsim tools tools-stamp tools-clean ############################################################################### ### Tests & Simulation ### @@ -191,31 +229,30 @@ test-sim-custom-genesis-fast: -Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h test-sim-import-export: runsim - @echo "Running Ethermint import/export simulation. This may take several minutes..." - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 25 5 TestAppImportExport + @echo "Running application import/export simulation. This may take several minutes..." + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppImportExport test-sim-after-import: runsim - @echo "Running Ethermint simulation-after-import. This may take several minutes..." - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 25 5 TestAppSimulationAfterImport + @echo "Running application simulation-after-import. This may take several minutes..." + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppSimulationAfterImport test-sim-custom-genesis-multi-seed: runsim @echo "Running multi-seed custom genesis simulation..." @echo "By default, ${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json will be used." - @$(BINDIR)/runsim -Jobs=4 -Genesis=${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json 400 5 TestFullAppSimulation + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail -Genesis=${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json 400 5 TestFullAppSimulation test-sim-multi-seed-long: runsim @echo "Running multi-seed application simulation. This may take awhile!" - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 500 50 TestFullAppSimulation + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 500 50 TestFullAppSimulation test-sim-multi-seed-short: runsim @echo "Running multi-seed application simulation. This may take awhile!" - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 10 TestFullAppSimulation + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation -.PHONY: runsim test-sim-nondeterminism test-sim-custom-genesis-fast test-sim-fast sim-import-export \ - test-sim-simulation-after-import test-sim-custom-genesis-multi-seed test-sim-multi-seed +.PHONY: test test-unit test-race test-import test-rpc -.PHONY: build install update-tools tools godocs clean format lint \ -test-cli test-race test-unit test test-import +.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-long test-sim-multi-seed-short ############################################################################### ### Linting ### diff --git a/go.mod b/go.mod index a2d858e4..8fde2b2d 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/gogo/protobuf v1.3.1 github.com/gorilla/mux v1.7.4 github.com/gorilla/websocket v1.4.2 - github.com/mattn/go-colorable v0.1.4 // indirect + github.com/mattn/go-colorable v0.1.7 // indirect github.com/onsi/ginkgo v1.11.0 // indirect github.com/onsi/gomega v1.8.1 // indirect github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 4c899230..3a9757b4 100644 --- a/go.sum +++ b/go.sum @@ -372,14 +372,13 @@ github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzR github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= +github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -725,7 +724,6 @@ golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -740,6 +738,7 @@ golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200219091948-cb0a6d8edb6c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=