name: Tests / E2E Upgrade
on:
  workflow_dispatch:
  pull_request:
    branches:
      - main
    paths:
      # upgrade tests will run on any changes to the upgrade_test.go file,
      # and changes to the workflow itself.
      - 'e2e/tests/upgrades/*.go'
      - '.github/workflows/e2e-upgrade.yaml'
  schedule:
    - cron: '0 0 * * *'

env:
  DOCKER_IMAGE_NAME: ghcr.io/cosmos/ibc-go-simd

jobs:
  e2e-upgrade-tests:
    runs-on: depot-ubuntu-22.04-4
    strategy:
      fail-fast: false
      matrix: 
        test-config: [
          {
            tag: v6.1.0,
            upgrade-plan: v7,
            test: TestV6ToV7ChainUpgrade
          },
          {
            tag: v7.0.0,
            upgrade-plan: v7.1,
            test: TestV7ToV7_1ChainUpgrade
          },
          {
            tag: v7.10.0,
            upgrade-plan: v8,
            test: TestV7ToV8ChainUpgrade
          },
          {
            tag: v8.0.0,
            upgrade-plan: v8.1,
            test: TestV8ToV8_1ChainUpgrade
          },
          {
            tag: v8.7.0,
            upgrade-plan: v10,
            test: TestV8ToV10ChainUpgrade
          },
          {
            tag: v8.7.0,
            upgrade-plan: v10,
            test: TestV8ToV10ChainUpgrade_Localhost
          },
        ]
    steps:
      - uses: actions/checkout@v4
        with:
          repository: cosmos/ibc-go
      - uses: actions/setup-go@v5
        with:
          go-version: '1.23'
          cache-dependency-path: 'e2e/go.sum'
      - name: Run e2e Test
        id: e2e_test
        env:
          CHAIN_IMAGE: '${{ env.DOCKER_IMAGE_NAME }}'
          CHAIN_A_TAG: "${{ matrix['test-config'].tag }}"
          CHAIN_B_TAG: "${{ matrix['test-config'].tag }}"
          CHAIN_UPGRADE_PLAN: "${{ matrix['test-config']['upgrade-plan'] }}"
          E2E_CONFIG_PATH: 'ci-e2e-config.yaml'
        run: |
          cd e2e
          make e2e-test test=${{ matrix['test-config'].test }}
      - name: Upload Diagnostics
        uses: actions/upload-artifact@v4
        if: ${{ failure() }}
        continue-on-error: true
        with:
          name: "${{ matrix['test-config'].test }}"
          path: e2e/diagnostics
          retention-days: 5
