Skip to content

Commit

Permalink
feat: Add legacy simapp testing via build tags (#12121)
Browse files Browse the repository at this point in the history
## Description

This is a PoC just to know what the team thinks of it.

Pros:

- No need to re-write tests
- We make sure that we are running all the same tests on both files

Cons:

- We need to run tests twice (although we would be running them twice if we copy&paste all of them)

Closes: #12068



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
facundomedica authored Jul 1, 2022
1 parent 9b58729 commit 0cc82cf
Show file tree
Hide file tree
Showing 3 changed files with 835 additions and 2 deletions.
152 changes: 152 additions & 0 deletions .github/workflows/legacy-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Legacy App Testing
on:
schedule:
- cron: "0 0,12 * * *"
release:
types: [published]

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/main'"
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-arch: ["amd64", "arm", "arm64"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build
run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build

- name: Build cosmovisor
run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make cosmovisor

- name: Install runsim
run: go install github.com/cosmos/tools/cmd/[email protected]
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary

test-submodules:
runs-on: ubuntu-latest
container: tendermintdev/docker-tm-db-testing
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Run submodule tests and create test coverage profile.
# GIT_DIFF is passed to the scripts
run: bash scripts/module-tests.sh
if: env.GIT_DIFF
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-go-submodules-coverage"
path: ./coverage-go-submod-profile.out

split-test-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Create a file with all core Cosmos SDK pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 4 files
run: split -d -n l/4 pkgs.txt pkgs.txt.part.
# cache multiple
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-00"
path: ./pkgs.txt.part.00
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-01"
path: ./pkgs.txt.part.01
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-02"
path: ./pkgs.txt.part.02
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-03"
path: ./pkgs.txt.part.03

tests:
runs-on: ubuntu-latest
needs: split-test-files
strategy:
fail-fast: false
matrix:
part: ["00", "01", "02", "03"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/download-artifact@v3
with:
name: "${{ github.sha }}-${{ matrix.part }}"
if: env.GIT_DIFF
- name: test & coverage report creation
run: |
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='legacy_simapp norace ledger test_ledger_mock'
if: env.GIT_DIFF
- uses: actions/upload-artifact@v3
with:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out

sims-notify-success:
needs:
[tests]
runs-on: ubuntu-latest
if: ${{ success() }}
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Get previous workflow status
uses: ./.github/actions/last-workflow-status
id: last_status
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Notify Slack on success
if: ${{ steps.last_status.outputs.last_status == 'failure' }}
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: cosmos-sdk-legacy-app
SLACK_USERNAME: Legacy App Tests
SLACK_ICON_EMOJI: ":white_check_mark:"
SLACK_COLOR: good
SLACK_MESSAGE: Legacy app tests are passing
SLACK_FOOTER: ""

sims-notify-failure:
needs:
[tests]
runs-on: ubuntu-latest
if: ${{ failure() }}
steps:
- name: Notify Slack on failure
uses: rtCamp/action-slack-notify@12e36fc18b0689399306c2e0b3e0f2978b7f1ee7
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: cosmos-sdk-legacy-app
SLACK_USERNAME: Legacy App Tests
SLACK_ICON_EMOJI: ":skull:"
SLACK_COLOR: danger
SLACK_MESSAGE: Legacy app tests are failing
SLACK_FOOTER: ""
4 changes: 2 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !legacy_simapp

package simapp

import (
Expand Down Expand Up @@ -151,8 +153,6 @@ type SimApp struct {
appCodec codec.Codec
interfaceRegistry codectypes.InterfaceRegistry

invCheckPeriod uint

// keys to access the substores
keys map[string]*storetypes.KVStoreKey

Expand Down
Loading

0 comments on commit 0cc82cf

Please sign in to comment.