From 9382184bfd3ba102028d7a8bbd193bc88f9f31d9 Mon Sep 17 00:00:00 2001 From: poorphd Date: Thu, 20 Jul 2023 20:35:37 +0900 Subject: [PATCH] feat: simulation workflow --- .github/workflows/sims.yml | 242 ++++++++++++++++++------------------- Makefile | 22 ++-- 2 files changed, 132 insertions(+), 132 deletions(-) diff --git a/.github/workflows/sims.yml b/.github/workflows/sims.yml index c9447eb0..88e8c82a 100644 --- a/.github/workflows/sims.yml +++ b/.github/workflows/sims.yml @@ -1,121 +1,121 @@ -#name: Sims -# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import) -# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed -# Temporary disable until it is fixed -#on: -# pull_request: -# push: -# branches: -# - main -# - develop -# -#jobs: -# build: -# runs-on: ubuntu-latest -# if: "!contains(github.event.head_commit.message, 'skip-sims')" -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-go@v2.1.3 -# with: -# go-version: 1.18 -# - name: Display go version -# run: go version -# - run: make build -# -# install-runsim: -# runs-on: ubuntu-latest -# needs: build -# steps: -# - uses: actions/setup-go@v2.1.3 -# with: -# go-version: 1.18 -# - name: Display go version -# run: go version -# - name: Install runsim -# run: export GO111MODULE="on" && go install github.com/cosmos/tools/cmd/runsim@v1.0.0 -# - uses: actions/cache@v2.1.6 -# with: -# path: ~/go/bin -# key: ${{ runner.os }}-go-runsim-binary -# -# test-sim-nondeterminism: -# runs-on: ubuntu-latest -# needs: [build, install-runsim] -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-go@v2.1.3 -# with: -# go-version: 1.18 -# - name: Display go version -# run: go version -# - uses: technote-space/get-diff-action@v4 -# with: -# PATTERNS: | -# **/**.go -# go.mod -# go.sum -# - uses: actions/cache@v2.1.6 -# 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: [build, install-runsim] -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-go@v2.1.3 -# with: -# go-version: 1.18 -# - name: Display go version -# run: go version -# - uses: technote-space/get-diff-action@v4 -# with: -# SUFFIX_FILTER: | -# **/**.go -# go.mod -# go.sum -# SET_ENV_NAME_INSERTIONS: 1 -# SET_ENV_NAME_LINES: 1 -# - uses: actions/cache@v2.1.6 -# 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 -# needs: [build, install-runsim] -# steps: -# - uses: actions/checkout@v2 -# - uses: actions/setup-go@v2.1.3 -# with: -# go-version: 1.18 -# - name: Display go version -# run: go version -# - uses: technote-space/get-diff-action@v4 -# with: -# SUFFIX_FILTER: | -# **/**.go -# go.mod -# go.sum -# SET_ENV_NAME_INSERTIONS: 1 -# SET_ENV_NAME_LINES: 1 -# - uses: actions/cache@v2.1.6 -# 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 +name: Sims + Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import) + This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed + Temporary disable until it is fixed +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + build: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'skip-sims')" + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2.1.3 + with: + go-version: 1.18 + - name: Display go version + run: go version + - run: make build + + install-runsim: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/setup-go@v2.1.3 + with: + go-version: 1.18 + - name: Display go version + run: go version + - name: Install runsim + run: export GO111MODULE="on" && go install github.com/cosmos/tools/cmd/runsim@v1.0.0 + - uses: actions/cache@v2.1.6 + with: + path: ~/go/bin + key: ${{ runner.os }}-go-runsim-binary + + test-sim-nondeterminism: + runs-on: ubuntu-latest + needs: [build, install-runsim] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2.1.3 + with: + go-version: 1.18 + - name: Display go version + run: go version + - uses: technote-space/get-diff-action@v4 + with: + PATTERNS: | + **/**.go + go.mod + go.sum + - uses: actions/cache@v2.1.6 + 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: [build, install-runsim] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2.1.3 + with: + go-version: 1.18 + - name: Display go version + run: go version + - uses: technote-space/get-diff-action@v4 + with: + SUFFIX_FILTER: | + **/**.go + go.mod + go.sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v2.1.6 + 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 + needs: [build, install-runsim] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2.1.3 + with: + go-version: 1.18 + - name: Display go version + run: go version + - uses: technote-space/get-diff-action@v4 + with: + SUFFIX_FILTER: | + **/**.go + go.mod + go.sum + SET_ENV_NAME_INSERTIONS: 1 + SET_ENV_NAME_LINES: 1 + - uses: actions/cache@v2.1.6 + 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 diff --git a/Makefile b/Makefile index b1c43811..835b9142 100755 --- a/Makefile +++ b/Makefile @@ -371,12 +371,12 @@ test-rpc-pending: test-sim-nondeterminism: @echo "Running non-determinism test..." @go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \ - -NumBlocks=10 -BlockSize=100 -Commit=true -Period=1 -v -timeout 1h + -NumBlocks=20 -BlockSize=100 -Commit=true -Period=1 -v -timeout 10m test-sim-nondeterminism-long: - @echo "Running non-determinism test..." + @echo "Running non-determinism-long test..." @go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \ - -NumBlocks=100 -BlockSize=200 -Commit=true -Period=1 -v -timeout 1h + -NumBlocks=100 -BlockSize=200 -Commit=true -Period=1 -v -timeout 10h test-sim-custom-genesis-fast: @echo "Running custom genesis simulation..." @@ -386,21 +386,21 @@ test-sim-custom-genesis-fast: test-sim-import-export: runsim @echo "Running application import/export simulation. This may take several minutes..." - $(eval SEED := $(shell awk 'BEGIN{srand(); for (i=1; i<=5; i++) {n=int(10000*rand())+1; printf "%d%s", n, (i==5 ? "" : ",")}}')) - @$(BINDIR)/runsim -Jobs=1 -SimAppPkg=$(SIMAPP) -Seeds="$(SEED)" -ExitOnFail 10 1 TestAppImportExport + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -Seeds=1,10,100,1000 -ExitOnFail 50 5 TestAppImportExport test-sim-import-export-long: runsim - @echo "Running application import/export simulation. This may take several minutes..." - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppImportExport + @echo "Running application simulation-import-export-long. This may take several minutes..." + $(eval SEED := $(shell awk 'BEGIN{srand(); for (i=1; i<=50; i++) {n=int(10000*rand())+1; printf "%d%s", n, (i==50 ? "" : ",")}}')) + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -Seeds="$(SEED)" -ExitOnFail 500 5 TestAppImportExport test-sim-after-import: runsim @echo "Running application simulation-after-import. This may take several minutes..." - $(eval SEED := $(shell awk 'BEGIN{srand(); for (i=1; i<=5; i++) {n=int(10000*rand())+1; printf "%d%s", n, (i==5 ? "" : ",")}}')) - @$(BINDIR)/runsim -Jobs=1 -SimAppPkg=$(SIMAPP) -Seeds="$(SEED)" -ExitOnFail 10 1 TestAppSimulationAfterImport + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -Seeds=1,10,100,1000 -ExitOnFail 50 5 TestAppSimulationAfterImport test-sim-after-import-long: runsim - @echo "Running application simulation-after-import. This may take several minutes..." - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppSimulationAfterImport + @echo "Running application simulation-after-import-long. This may take several minutes..." + $(eval SEED := $(shell awk 'BEGIN{srand(); for (i=1; i<=50; i++) {n=int(10000*rand())+1; printf "%d%s", n, (i==50 ? "" : ",")}}')) + @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -Seeds="$(SEED)" -ExitOnFail 500 5 TestAppSimulationAfterImport test-sim-custom-genesis-multi-seed: runsim @echo "Running multi-seed custom genesis simulation..."