Reusable e2e tests workflow #249
Workflow file for this run
This file contains 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: Reusable e2e tests workflow | |
on: | |
workflow_dispatch: | |
inputs: | |
e2eBranch: | |
description: "Name of the e2e target branch" | |
type: string | |
required: false | |
default: "main" | |
nodeDockerImage: | |
description: "Name of the parachain docker reference" | |
type: string | |
required: false | |
default: "mangatasolutions/rollup-node:eth-rollup-develop" | |
skipBuild: | |
description: "Skip build phase" | |
type: string | |
required: false | |
default: 'false' | |
globalVersion: | |
description: "Set Mangata node version." | |
type: string | |
required: true | |
mangataTypesVersion: | |
description: "Set @mangata-finance/types version" | |
type: string | |
default: "" | |
required: false | |
workflow_call: | |
inputs: | |
e2eBranch: | |
description: "Name of the e2e target branch" | |
type: string | |
required: false | |
default: "main" | |
nodeDockerImage: | |
description: "Name of the parachain docker reference" | |
type: string | |
required: false | |
default: "mangatasolutions/rollup-node:eth-rollup-develop" | |
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-rollupUpdate" | |
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 | |
- command: "yarn test-sdk" | |
fast: true | |
- command: "yarn test-parallel-3rdPartyRewards" | |
fast: true | |
- command: "yarn test-sequencerStaking" | |
fast: true | |
- command: "yarn test-sequencerCancellation" | |
fast: true | |
- command: "yarn test-rolldown" | |
fast: true | |
- command: "yarn test-rolldownWithdrawal" | |
fast: true | |
runs-on: [e2e-gke] | |
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" | |
NODE_DOCKER_IMAGE: ${{ inputs.nodeDockerImage || format('mangatasolutions/rollup-node:{0}', inputs.globalVersion) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Adapt if fast runtime | |
if: ${{ !contains(env.NODE_DOCKER_IMAGE, 'fast') && matrix.fast == true }} | |
run: echo "NODE_DOCKER_IMAGE=${{ env.NODE_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.NODE_DOCKER_IMAGE }} | |
- name: E2E- Get branch name | |
id: branch-name | |
uses: tj-actions/[email protected] | |
- name: Current branch name for generating types | |
run: | | |
echo "MANGATA_TYPES_VERSION=${{ steps.branch-name.outputs.current_branch }}" | sed -E 's@[/\.]@-@g; s@_@-@g' >> $GITHUB_ENV | |
- 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: Checkout tests | |
uses: actions/checkout@v4 | |
with: | |
repository: mangata-finance/mangata-e2e | |
ref: "${{ env.E2EBRANCHNAME }}" | |
path: e2eTests | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18.19.0' | |
- name: Install e2e tests dependencies | |
working-directory: e2eTests | |
run: yarn install | |
- name: Install @mangata-finance/types deps | |
run: | | |
if [[ -n "${{ github.event.inputs.mangataTypesVersion }}" ]]; then | |
yarn add @mangata-finance/types@${{ github.event.inputs.mangataTypesVersion }} | |
else | |
yarn add @mangata-finance/types@${{ env.MANGATA_TYPES_VERSION }} | |
fi | |
- name: Run the Node | |
env: | |
NODE_IMAGE: ${{ env.NODE_DOCKER_IMAGE }} | |
run: | | |
echo "Starting nodes with image: ${NODE_IMAGE}" | |
docker-compose up -d | |
docker ps | |
- name: Sleep for 2 minutes | |
run: sleep 120s | |
- name: Get docker status | |
run: docker ps | |
- name: Run tests | |
working-directory: e2eTests | |
run: ${{ matrix.command }} | |
env: | |
NODE_OPTIONS: --max_old_space_size=12288 | |
- 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/*.xml # Path to test results | |
reporter: jest-junit # Format of test results | |
- name: Submit results to the testmo-run | |
continue-on-error: true | |
if: always() | |
env: | |
TESTMO_URL: ${{ secrets.TESTMO_URL }} | |
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }} | |
run: | | |
npm install --no-save @testmo/testmo-cli | |
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 | |
- name: collect_docker_logs | |
if: failure() | |
uses: jwalton/[email protected] | |
with: | |
dest: "./logs" | |
- name: Prepare backup snapshots on workflow failure | |
if: failure() | |
env: | |
OUTPUT_DIR: ./ | |
run: | | |
# Set MATRIX_COMMAND_PATH to be used as a directory name to store specifc test run snapshots | |
echo "MATRIX_COMMAND_PATH=$(echo ${{ matrix.command }} | sed 's/[^a-zA-Z0-9]/-/g')" >> $GITHUB_ENV | |
# Archive logs | |
tar cvzf ${OUTPUT_DIR}/logs.tgz ./logs | |
# Generate image snapshots | |
docker commit $(docker ps | grep mangata-node-node-alice-1 | awk '{print $1}') mangata_test_run/mangata_alice_1 | |
docker save --output=${OUTPUT_DIR}/mangata_alice_1.tar mangata_test_run/mangata_alice_1 | |
docker commit $(docker ps | grep mangata-node-node-bob-1 | awk '{print $1}') mangata_test_run/mangata_bob_1 | |
docker save --output=${OUTPUT_DIR}/mangata_bob_1.tar mangata_test_run/mangata_bob_1 | |
# Generate volume snapshots | |
docker run -v data-alith:/volume --rm --log-driver none loomchild/volume-backup backup > ${OUTPUT_DIR}/mangata_alice_1_volume.tar.bz2 | |
docker run -v data-baltathar:/volume --rm --log-driver none loomchild/volume-backup backup > ${OUTPUT_DIR}/mangata_bob_1_volume.tar.bz2 | |
- uses: google-github-actions/auth@v1 | |
if: failure() | |
with: | |
workload_identity_provider: '${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}' | |
service_account: '${{ secrets.GCP_SERVICE_ACCOUNT }}' | |
- name: Upload node storage data to GCP bucket | |
if: failure() | |
uses: google-github-actions/[email protected] | |
with: | |
process_gcloudignore: false | |
destination: mangata-node-ci-cache/${{ github.sha }}/${{ env.MATRIX_COMMAND_PATH }} | |
- name: Add GCP bucket URL link for stored node data on job failure | |
if: failure() | |
run: echo '[GCP Bucket link](https://console.cloud.google.com/storage/browser/mangata-node-ci-cache/${{ github.sha }}/${{ env.MATRIX_COMMAND_PATH }})' >> $GITHUB_STEP_SUMMARY | |
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.NODE_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 }}' |