Skip to content

Reusable e2e tests workflow #17

Reusable e2e tests workflow

Reusable e2e tests workflow #17

name: Reusable e2e tests workflow
on:
workflow_dispatch:
inputs:
e2eBranch:
description: "Name of the e2e target branch"
type: string
required: false
default: "main"
parachainDocker:
description: "Name of the parachain docker reference"
type: string
required: false
default: "mangatasolutions/mangata-node:latest"
skipBuild:
description: "Skip build phase"
type: string
required: false
default: false
globalVersion:
description: "Set Mangata node version."
type: string
required: true
workflow_call:
inputs:
e2eBranch:
description: "Name of the e2e target branch"
type: string
required: false
default: "main"
parachainDocker:
description: "Name of the parachain docker reference"
type: string
required: false
default: "mangatasolutions/mangata-node:latest"
skipBuild:
description: "Skip build phase"
type: string
required: false
default: false
globalVersion:
description: "Set Mangata node version."
type: string
required: true
permissions:
contents: write
id-token: write
deployments: write
checks: write
jobs:
setup-report:
runs-on: [ubuntu-latest]
outputs:
testmo-run-id: ${{ steps.setTestRun.outputs.testmo-run-id }}
steps:
- name: Install testmo
run: npm install --no-save @testmo/testmo-cli
- name: Add url
run: |
npx testmo automation:resources:add-field --name git --type string \
--value ${GITHUB_SHA:0:7} --resources resources.json
RUN_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
npx testmo automation:resources:add-link --name build \
--url $RUN_URL --resources resources.json
- name: Create test run
run: |
npx testmo automation:run:create \
--instance https://mangata-finance.testmo.net \
--project-id 2 \
--name "BE tests from node-repo" \
--resources resources.json \
--source "BE-e2e-regression" > testmo-run-id.txt
ID=$(cat testmo-run-id.txt)
echo "testmo-run-id=$ID" >> $GITHUB_OUTPUT
echo "ID=$ID" >> $GITHUB_ENV
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
id: setTestRun
e2e-test-matrix:
needs: [setup-report]
strategy:
fail-fast: false
matrix:
include:
- command: "yarn test-parallel --max-workers=10"
fast: false
- command: "yarn test-sequential-no-bootstrap"
fast: false
- command: "yarn test-seqgasless"
fast: false
- command: "yarn test-maintenance"
fast: true
- command: "yarn test-bootstrap"
fast: false
- command: "yarn test-rewards-bootstrap"
fast: false
- command: "yarn test-parallel-autocompound"
fast: true
- command: "yarn test-sequential-autocompound"
fast: true
- command: "yarn test-poolliquidity"
fast: true
- command: "yarn test-governance"
fast: true
- command: "yarn test-multiswap"
fast: false
- command: "yarn test-experimentalStaking"
fast: true
- command: "yarn test-crowdloan"
fast: false
runs-on: [self-hosted, compile]
timeout-minutes: 180
env:
API_URL: "ws://127.0.0.1:9946"
TEST_PALLET_ADDRESS: ${{ secrets.E2E_TEST_PALLET_ADDRESS }}
E2E_TREASURY_PALLET_ADDRESS: ${{ secrets.E2E_TREASURY_PALLET_ADDRESS }}
E2E_XYK_PALLET_ADDRESS: ${{ secrets.E2E_XYK_PALLET_ADDRESS }}
E2E_TREASURY_BURN_PALLET_ADDRESS: ${{ secrets.E2E_TREASURY_BURN_PALLET_ADDRESS }}
TEST_SUDO_NAME: "//Alice"
MANGATA_NODE_VERSION: ${{ inputs.globalVersion }}
E2EBRANCHNAME: "main"
PARACHAIN_DOCKER_IMAGE: ${{ inputs.parachainDocker || format('mangatasolutions/mangata-node:{0}', inputs.globalVersion) }}
steps:
- uses: actions/checkout@v3 ####IDK, but this is neccesary for reports
- name: Adapt if fast runtime
if: ${{ !contains(env.PARACHAIN_DOCKER_IMAGE, 'fast') && matrix.fast == true }}
run: echo "PARACHAIN_DOCKER_IMAGE=${{ env.PARACHAIN_DOCKER_IMAGE }}-fast" >> $GITHUB_ENV
- name: Adapt if fast runtime
if: ${{ !contains(env.PARACHAIN_DOCKER_IMAGE, 'fast') && matrix.fast == true }}
run: echo "PARACHAIN_DOCKER_IMAGE=${{ env.PARACHAIN_DOCKER_IMAGE }}-fast" >> $GITHUB_ENV
- name: Download node Docker image
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-build') && inputs.skipBuild != 'true' }}
run: docker pull ${{ env.PARACHAIN_DOCKER_IMAGE }}
- name: E2E- Get branch name
id: branch-name
uses: tj-actions/[email protected]
- name: E2E- Get target branch.
run: |
echo "This job name branch is: ${{ steps.branch-name.outputs.current_branch }}"
- name: E2E- Calculate if run e2e feature branch or main.
run: |
echo DEFAULT: E2E test will run with: $E2EBRANCHNAME
echo "Running on: ${{ steps.branch-name.outputs.current_branch }}"
if [ -n "$(git ls-remote --heads https://github.com/mangata-finance/mangata-e2e.git ${{ steps.branch-name.outputs.current_branch }} --force --quiet)" ]; then echo "E2EBRANCHNAME=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV; echo "MATCH - OK" ; elif [ -n "$(git ls-remote --heads https://github.com/mangata-finance/mangata-e2e.git ${{ github.base_ref }} --force --quiet)" ]; then echo "E2EBRANCHNAME=${{ github.base_ref }}" >> $GITHUB_ENV; echo "MATCH - OK" ; fi
- name: Decide if main - branch or parameter
# if we have something in e2eBranch - override E2EBranchName, else -> E2EBRANCHNAME , that
# by default will be main.
run: echo "E2EBRANCHNAME=${{ inputs.e2eBranch || env.E2EBRANCHNAME }}" >> $GITHUB_ENV
- name: E2E- Get target branch.
run: |
echo "${{ env.E2EBRANCHNAME }}"
- name: Checkout tests
uses: actions/checkout@v3
with:
repository: mangata-finance/mangata-e2e
ref: "${{ env.E2EBRANCHNAME }}"
path: e2eTests
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
- name: Print parachain docker image reference
run: |
echo ${{ env.PARACHAIN_DOCKER_IMAGE }}
- name: Replace parachain docker image reference in config
working-directory: devops/parachain-launch
run: sed -i 's+mangatasolutions/mangata-node:.*+${{ env.PARACHAIN_DOCKER_IMAGE }}+g' config.yml
- name: Install e2e tests dependencies
working-directory: e2eTests
run: yarn
- name: Run parachain launch
working-directory: devops/parachain-launch
run: npx @open-web3/parachain-launch generate config.yml
- name: Docker ps
run: docker ps --no-trunc
- name: Docker network ls
run: docker network ls
- name: Stop previous parachain if running
working-directory: devops/parachain-launch/output
run: |
docker kill $(docker ps -q) 2>/dev/null && echo $?
docker-compose down -v
- name: Start mangata-node parachain
working-directory: devops/parachain-launch/output
run: docker-compose up -d --build
- name: Docker ps
run: docker ps --no-trunc
- name: Sleep for 2 minutes
run: sleep 120s #close buffers of videos.
- name: Run tests
working-directory: e2eTests
run: ${{ matrix.command }}
- name: Test Report
uses: dorny/[email protected]
continue-on-error: true
if: success() || failure() # run this step even if previous step failed
with:
name: E2E report ${{ matrix.command }} # Name of the check run which will be created
path: e2eTests/reports/junit-*.xml # Path to test results
reporter: jest-junit # Format of test results
- name: Install testmo
if: always()
run: npm install --no-save @testmo/testmo-cli
- name: Submit results to the testmo-run
if: always()
run: |
npx testmo automation:run:submit-thread \
--instance https://mangata-finance.testmo.net \
--run-id ${{needs.setup-report.outputs.testmo-run-id}} \
--results e2eTests/reports/*.xml
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
continue-on-error: true
- name: Collect docker logs on failure
if: failure()
uses: jwalton/[email protected]
with:
dest: "./logs"
- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs
- name: Create images snapshots
if: failure()
run: |
docker commit $(docker ps | grep parachain-2110-1 | awk '{print $1}') mangata_test_run/mangata_bob_1
docker save --output=/tmp/mangata_bob_1.tar mangata_test_run/mangata_bob_1
docker commit $(docker ps | grep parachain-2110-0 | awk '{print $1}') mangata_test_run/mangata_alice_1
docker save --output=/tmp/mangata_alice_1.tar mangata_test_run/mangata_alice_1
- name: Upload logs and docker images to GitHub
if: failure()
uses: actions/[email protected]
with:
name: logsAndImages
path: |
./logs.tgz
/tmp/mangata_bob_1.tar
/tmp/mangata_alice_1.tar
- name: Stop previous parachain if running
working-directory: devops/parachain-launch/output
run: |
docker kill $(docker ps -q) 2>/dev/null && echo $?
docker-compose down -v
- name: Fix permissions on self-hosted runner
if: always()
run: chown -R 1100:1100 $GITHUB_WORKSPACE
test-complete:
needs: [setup-report, e2e-test-matrix]
if: always()
runs-on: ubuntu-latest
steps:
- name: Install testmo
run: npm install --no-save @testmo/testmo-cli
- name: Complete test run
run: |
npx testmo automation:run:complete \
--instance https://mangata-finance.testmo.net \
--run-id ${{needs.setup-report.outputs.testmo-run-id}} \
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
continue-on-error: true
slack-notify-nook:
needs: [e2e-test-matrix]
if: failure()
runs-on: ubuntu-latest
steps:
- name: Slack Notification - Error
uses: bryannice/[email protected]
env:
SLACK_INCOMING_WEBHOOK: ${{ secrets.BNB_E2E_NOTIFICATION_WEBHOOK }}
SLACK_TITLE: 'bnb e2e test execution - NOOK'
SLACK_COLOR: "#ff0011"
SLACK_MESSAGE: 'Test failures [ ${{ env.E2EBRANCHNAME }} - ${{ env.PARACHAIN_DOCKER_IMAGE }} ] testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{needs.setup-report.outputs.testmo-run-id}}'
GITHUB_REF: 'https://mangata-finance.github.io/mangata-node/${{ github.run_number }}'