Skip to content

Commit

Permalink
Merge pull request #59 from oraichain/gh-actions
Browse files Browse the repository at this point in the history
Feat: Write GH actions for automation interchain test
  • Loading branch information
GNaD13 authored Jan 6, 2025
2 parents 8e6dacc + a45e3a3 commit d384b01
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Update to cometbft to v0.38.15
([\#49](https://github.com/oraichain/wasmd/pull/49))
131 changes: 131 additions & 0 deletions .github/workflows/interchaintest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Interchain Tests

on:
pull_request:
push:
branches:
- release/**

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}

- name: Build and push
id: build_push_image
uses: docker/build-push-action@v5
with:
file: ict.Dockerfile
context: .
push: true
platforms: linux/amd64
tags: |
ghcr.io/oraichain/oraid-ictest:latest
test-basic:
runs-on: ubuntu-latest
needs: build-and-push-image # This job must run after build and push image
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '1.22.7'

- name: checkout code
uses: actions/checkout@v4

- run: make ictest-basic
env:
BRANCH_CI: "latest"
ictest-interchain-account:
runs-on: ubuntu-latest
needs: build-and-push-image # This job must run after build and push image
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '1.22.7'

- name: checkout code
uses: actions/checkout@v4

- run: make ictest-interchain-account
env:
BRANCH_CI: "latest"
ictest-tf-param-change:
runs-on: ubuntu-latest
needs: build-and-push-image # This job must run after build and push image
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '1.22.7'

- name: checkout code
uses: actions/checkout@v4

- run: make ictest-tf-param-change
env:
BRANCH_CI: "latest"
ictest-tf-set-metadata:
runs-on: ubuntu-latest
needs: build-and-push-image # This job must run after build and push image
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '1.22.7'

- name: checkout code
uses: actions/checkout@v4

- run: make ictest-tf-set-metadata
env:
BRANCH_CI: "latest"
ictest-ibchooks:
runs-on: ubuntu-latest
needs: build-and-push-image # This job must run after build and push image
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '1.22.7'

- name: checkout code
uses: actions/checkout@v4

- run: make ictest-ibchooks
env:
BRANCH_CI: "latest"
ictest-wasm-gasless:
runs-on: ubuntu-latest
needs: build-and-push-image # This job must run after build and push image
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '1.22.7'

- name: checkout code
uses: actions/checkout@v4

- run: make ictest-wasm-gasless
env:
BRANCH_CI: "latest"
65 changes: 2 additions & 63 deletions tests/interchaintest/ibc_hooks_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package interchaintest

import (
"context"
"fmt"
"testing"

Expand All @@ -11,11 +10,8 @@ import (
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/relayer"
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
)

// TestStartOrai is a basic test to assert that spinning up a Orai network with 1 validator works properly.
Expand All @@ -25,66 +21,9 @@ func TestIbcHooks(t *testing.T) {
}

t.Parallel()

ctx := context.Background()

numVals := 1
numFullNodes := 1

cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Name: "orai",
ChainConfig: oraiConfig,
NumValidators: &numVals,
NumFullNodes: &numFullNodes,
},
{
Name: "gaia",
Version: GaiaImageVersion,
NumValidators: &numVals,
NumFullNodes: &numFullNodes,
},
})

// Get chains from the chain factory
chains, err := cf.Chains(t.Name())
require.NoError(t, err)

chains := CreateChains(t, 1, 1)
orai, gaia := chains[0].(*cosmos.CosmosChain), chains[1].(*cosmos.CosmosChain)

// Create relayer factory to utilize the go-relayer
client, network := interchaintest.DockerSetup(t)
r := interchaintest.NewBuiltinRelayerFactory(
ibc.CosmosRly,
zaptest.NewLogger(t),
relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000"),
).Build(t, client, network)

ic := interchaintest.NewInterchain().
AddChain(orai).
AddChain(gaia).
AddRelayer(r, "rly").
AddLink(interchaintest.InterchainLink{
Chain1: orai,
Chain2: gaia,
Relayer: r,
Path: pathOraiGaia,
})

rep := testreporter.NewNopReporter()
eRep := rep.RelayerExecReporter(t)

err = ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{
TestName: t.Name(),
Client: client,
NetworkID: network,
SkipPathCreation: false,

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: interchaintest.DefaultBlockDatabaseFilepath(),
})
require.NoError(t, err)

ic, r, ctx, _, eRep, _ := BuildInitialChain(t, chains)
t.Cleanup(func() {
_ = ic.Close()
})
Expand Down
14 changes: 9 additions & 5 deletions tests/interchaintest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (

// Chain and relayer version inf
IBCRelayerImage = "ghcr.io/cosmos/relayer"
OraidICTestRepo = "ghcr.io/oraichain/oraid-ictest"
IBCRelayerVersion = "latest"
GaiaImageVersion = "v21.0.0"
OsmosisImageVersion = "v22.0.1"
Expand Down Expand Up @@ -77,9 +78,9 @@ func oraiEncoding() *moduletestutil.TestEncodingConfig {
// If testing locally, user should run `make docker-build-debug` and interchaintest will use the local image.
func GetDockerImageInfo() (repo, version string) {
branchVersion, found := os.LookupEnv("BRANCH_CI")
repo = OraidICTestRepo
if !found {
// make local-image
fmt.Println("Testing local image")
repo = "orai"
branchVersion = "debug"
}
Expand Down Expand Up @@ -131,8 +132,11 @@ func CreateChains(t *testing.T, numVals, numFullNodes int, opts ...func(*ibc.Cha
NumFullNodes: &numFullNodes,
},
{
Name: "gaia",
Version: GaiaImageVersion,
Name: "gaia",
Version: GaiaImageVersion,
ChainConfig: ibc.ChainConfig{
GasPrices: "1uatom",
},
NumValidators: &numVals,
NumFullNodes: &numFullNodes,
},
Expand Down Expand Up @@ -185,7 +189,7 @@ func BuildInitialChainNoIbc(t *testing.T, chain ibc.Chain) (*interchaintest.Inte
return ic, ctx
}

func BuildInitialChain(t *testing.T, chains []ibc.Chain) (*interchaintest.Interchain, ibc.Relayer, context.Context, *client.Client, string) {
func BuildInitialChain(t *testing.T, chains []ibc.Chain) (*interchaintest.Interchain, ibc.Relayer, context.Context, *client.Client, *testreporter.RelayerExecReporter, string) {
// Create a new Interchain object which describes the chains, relayers, and IBC connections we want to use
require.Equal(t, len(chains), 2) // we only initial 2 chain for now
ic := interchaintest.NewInterchain()
Expand Down Expand Up @@ -224,5 +228,5 @@ func BuildInitialChain(t *testing.T, chains []ibc.Chain) (*interchaintest.Interc
})
require.NoError(t, err)

return ic, r, ctx, client, network
return ic, r, ctx, client, eRep, network
}
2 changes: 1 addition & 1 deletion tests/interchaintest/tokenfactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestTokenfactoryParamChange(t *testing.T) {
t.Parallel()
chains := CreateChains(t, 1, 1)
orai := chains[0].(*cosmos.CosmosChain)
ic, _, ctx, _, _ := BuildInitialChain(t, chains)
ic, _, ctx, _, _, _ := BuildInitialChain(t, chains)
t.Cleanup(func() {
_ = ic.Close()
})
Expand Down

0 comments on commit d384b01

Please sign in to comment.