image-pushed #561
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Interchain Test | |
on: | |
repository_dispatch: | |
types: [image-pushed] | |
workflow_dispatch: | |
inputs: | |
from_version: | |
description: 'Version to upgrade from' | |
required: false | |
type: string | |
to_version: | |
description: 'Version to upgrade to (defaults to current branch/tag)' | |
required: false | |
type: string | |
upgrade_name: | |
description: 'Name of the upgrade' | |
required: false | |
type: string | |
jobs: | |
prepare-matrix: | |
runs-on: ubuntu-latest | |
steps: | |
# We need to figure out a) a ref to clone based on a docker image, and b) which tag to test | |
# If the event is a registry_package, this comes from the pushed image; for a workflow_dispatch, it's the branch/tag that the user supplied | |
- name: Get metadata | |
id: get-metadata | |
run: | | |
if [[ "${{ github.event_name }}" == 'repository_dispatch' ]]; then | |
echo "ref_name=${{ github.event.client_payload.ref_name }}" | tee -a $GITHUB_OUTPUT | |
echo "tag_name=${{ github.event.client_payload.tag_name }}" | tee -a $GITHUB_OUTPUT | |
else | |
echo "ref_name=${{ github.ref_name }}" | tee -a $GITHUB_OUTPUT | |
TO_VERSION="${{ inputs.to_version }}" | |
echo "tag_name=${TO_VERSION:-${{ github.ref_name }}}" | sed 's~/~-~g' | tee -a $GITHUB_OUTPUT | |
fi | |
- name: Check out repository code | |
uses: actions/checkout@v5 | |
with: | |
ref: ${{ steps.get-metadata.outputs.ref_name }} | |
- name: Setup go | |
uses: actions/setup-go@v5 | |
- name: Prepare matrix | |
id: generate-matrix | |
env: | |
FROM_VERSION: ${{ inputs.from_version }} | |
UPGRADE_NAME: ${{ inputs.upgrade_name }} | |
run: | | |
cd ./tests/interchain | |
# Print debug information | |
echo "Using FROM_VERSION=${FROM_VERSION:-auto}" | |
echo "Using UPGRADE_NAME=${UPGRADE_NAME:-auto}" | |
echo "matrix=$(go run ./matrix_tool/main.go ${{ steps.get-metadata.outputs.tag_name }})" | tee -a $GITHUB_OUTPUT | |
outputs: | |
matrix: ${{ steps.generate-matrix.outputs.matrix }} | |
ref_name: ${{ steps.get-metadata.outputs.ref_name }} | |
test: | |
needs: prepare-matrix | |
runs-on: ubuntu-latest | |
name: "${{ matrix.previous_version }} -> ${{ matrix.test_version }} test ${{ matrix.test_name }}" | |
strategy: | |
matrix: | |
${{fromJson(needs.prepare-matrix.outputs.matrix)}} | |
fail-fast: false | |
max-parallel: 10 | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v5 | |
with: | |
ref: ${{ needs.prepare-matrix.outputs.ref_name }} | |
- name: Setup go | |
uses: actions/setup-go@v5 | |
- name: Run test | |
env: | |
TEST_DOCKER_REGISTRY: "ghcr.io/${{ github.repository_owner }}" | |
TEST_OLD_GAIA_IMAGE_VERSION: "${{ matrix.previous_version }}" | |
TEST_NEW_GAIA_IMAGE_VERSION: "${{ matrix.test_version }}" | |
TEST_UPGRADE_NAME: "${{ matrix.upgrade_name }}" | |
run: | | |
cd ./tests/interchain | |
go install github.com/mfridman/tparse@latest | |
set -o pipefail | |
go test -v ./... -failfast -p 1 -timeout 5h -run="^${{ matrix.test_name }}" -json | tee ../../output-${{ matrix.previous_version }}-${{ matrix.test_name }}.json | tparse -follow -all | |
- name: Upload output | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: output-${{ matrix.previous_version }}-${{ matrix.test_name }} | |
path: output-${{ matrix.previous_version }}-${{ matrix.test_name }}.json | |
test-report: | |
needs: [test, prepare-matrix] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v5 | |
with: | |
path: ./outputs | |
- name: Setup go | |
uses: actions/setup-go@v5 | |
- name: Prep report | |
env: | |
TEST_MATRIX: ${{ needs.prepare-matrix.outputs.matrix }} | |
run: | | |
go install github.com/becheran/go-testreport@latest | |
TEST_VERSION=$(echo "$TEST_MATRIX" | jq -r '.test_version[0]') | |
UPGRADE_NAME=$(echo "$TEST_MATRIX" | jq -r '.upgrade_name[0]') | |
echo "$TEST_MATRIX" | jq -r '.previous_version[]' | while read PREV_VERSION; do | |
cat ./outputs/output-${PREV_VERSION}-*/*.json > combined-${PREV_VERSION}.json | |
go-testreport -vars="Title:${PREV_VERSION} -> ${UPGRADE_NAME} (${TEST_VERSION})" -output="test-report-${PREV_VERSION}.md" -input="combined-${PREV_VERSION}.json" || true | |
echo '' >> test-report-${PREV_VERSION}.md | |
done | |
cat test-report-*.md > test-report.md | |
cat test-report.md > $GITHUB_STEP_SUMMARY | |
- name: Upload output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-report | |
path: test-report.md |