Skip to content

Commit

Permalink
Support wasm tests on forks (cosmos#5234)
Browse files Browse the repository at this point in the history
* chore: support wasm tests on forks

* chore: use correct needs

* chore: install python deps

* chore: adding flag for forks

* chore: use chain image passed in CI

* Update e2e/testsuite/testconfig.go

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>

---------

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
  • Loading branch information
3 people committed Dec 4, 2023
1 parent b7d6a30 commit 54e2172
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
53 changes: 53 additions & 0 deletions .github/workflows/e2e-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,31 @@ jobs:
env:
TEST_EXCLUSIONS: 'TestUpgradeTestSuite,TestGrandpaTestSuite'

# dynamically build a matrix of test/test suite pairs to run
build-test-matrix-wasm:
if: ${{ github.event.pull_request.head.repo.fork || github.actor == 'dependabot[bot]' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- id: set-matrix
run: echo "matrix=$(go run cmd/build_test_matrix/main.go)" >> $GITHUB_OUTPUT
env:
TEST_ENTRYPOINT: 'TestGrandpaTestSuite'


# e2e-fork runs the e2e tests directly by using a matrix strategy.
e2e-fork:
env:
CHAIN_A_TAG: latest
CHAIN_B_TAG: latest
CHAIN_IMAGE: ibc-go-simd
RELAYER_ID: "hermes" # by default use hermes for fork e2es.
FORK: "true"
if: ${{ github.event.pull_request.head.repo.fork || github.actor == 'dependabot[bot]' || github.event_name == 'workflow_dispatch' }}
needs:
- build-test-matrix
Expand All @@ -52,3 +70,38 @@ jobs:
run: |
cd e2e
make e2e-test test=${{ matrix.test }}
# this workflow runs only the wasm tests.
e2e-fork-wasm:
env:
CHAIN_A_TAG: latest
CHAIN_B_TAG: latest
CHAIN_IMAGE: ibc-go-wasm-simd
RELAYER_ID: "hyperspace" # by default use hyperspace relayer for fork wasm tests.
FORK: "true"
if: ${{ github.event.pull_request.head.repo.fork || github.actor == 'dependabot[bot]' || github.event_name == 'workflow_dispatch' }}
needs: build-test-matrix-wasm
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.build-test-matrix-wasm.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: make python-install-deps
- name: Docker Build Wasm
run: |
version="$(scripts/get-libwasm-version.py --get-version)"
checksum="$(scripts/get-libwasm-version.py --get-checksum)"
docker build . -t "${CHAIN_IMAGE}:${CHAIN_A_TAG}" -f modules/light-clients/08-wasm/Dockerfile --build-arg LIBWASM_VERSION=${version} --build-arg LIBWASM_CHECKSUM=${checksum}
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run e2e Test
run: |
cd e2e
make e2e-test test=${{ matrix.test }}
2 changes: 1 addition & 1 deletion e2e/tests/wasm/grandpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestGrandpaTestSuite(t *testing.T) {

// TODO: this value should be passed in via the config file / CI, not hard coded in the test.
// This configuration can be handled in https://github.com/cosmos/ibc-go/issues/4697
if testsuite.IsCI() {
if testsuite.IsCI() && !testsuite.IsFork() {
t.Setenv(testsuite.ChainImageEnv, wasmSimdImage)
}

Expand Down
5 changes: 5 additions & 0 deletions e2e/testsuite/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ func IsCI() bool {
return strings.ToLower(os.Getenv("CI")) == "true"
}

// IsFork returns true if the tests are running in fork mode, false is returned otherwise.
func IsFork() bool {
return strings.ToLower(os.Getenv("FORK")) == "true"
}

// ChainOptions stores chain configurations for the chains that will be
// created for the tests. They can be modified by passing ChainOptionConfiguration
// to E2ETestSuite.GetChains.
Expand Down

0 comments on commit 54e2172

Please sign in to comment.