Skip to content

Commit

Permalink
feat: add node storage voluems on failed e2e runs
Browse files Browse the repository at this point in the history
  • Loading branch information
tenequm committed Oct 11, 2023
1 parent 6308758 commit 83aeeb4
Showing 1 changed file with 43 additions and 63 deletions.
106 changes: 43 additions & 63 deletions .github/workflows/reusable-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
default: "mangatasolutions/mangata-node:latest"
skipBuild:
description: "Skip build phase"
type: string
type: boolean
required: false
default: false
globalVersion:
Expand All @@ -36,7 +36,7 @@ on:
default: "mangatasolutions/mangata-node:latest"
skipBuild:
description: "Skip build phase"
type: string
type: boolean
required: false
default: false
globalVersion:
Expand Down Expand Up @@ -118,7 +118,6 @@ jobs:
fast: false
- command: "yarn test-sdk"
fast: true

runs-on: [e2e-gke]
timeout-minutes: 180
env:
Expand All @@ -132,26 +131,20 @@ jobs:
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
- uses: actions/checkout@v3
- 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' }}
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/branch-names@v4.9

- 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: |
Expand All @@ -164,10 +157,6 @@ jobs:
# 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:
Expand All @@ -181,44 +170,27 @@ jobs:
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
# TODO: remove cache clean later
run: yarn cache clean; yarn
run: yarn
# run: yarn cache clean; 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
- run: docker ps --no-trunc
- 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
- run: docker ps --no-trunc

- name: Sleep for 2 minutes
run: sleep 120s #close buffers of videos.
run: sleep 120s

- name: Run tests
working-directory: e2eTests
Expand All @@ -232,49 +204,59 @@ jobs:
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
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
env:
TESTMO_URL: ${{ secrets.TESTMO_URL }}
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }}
continue-on-error: true
- name: Collect docker logs on failure
- name: collect_docker_logs
if: failure()
uses: jwalton/gh-docker-logs@v2.2.1
with:
dest: "./logs"

- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs

- name: Create images snapshots
- name: Prepare backup snapshots on workflow failure
if: failure()
env:
OUTPUT_DIR: devops/parachain-launch/output
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
# 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 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
docker save --output=${OUTPUT_DIR}/mangata_alice_1.tar mangata_test_run/mangata_alice_1
docker commit $(docker ps | grep parachain-2110-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
- name: Upload logs and docker images to GitHub
# Generate volume snapshots
docker run -v output_parachain-2110-0:/volume --rm --log-driver none loomchild/volume-backup backup > ${OUTPUT_DIR}/mangata_alice_1_volume.tar.bz2
docker run -v output_parachain-2110-1:/volume --rm --log-driver none loomchild/volume-backup backup > ${OUTPUT_DIR}/mangata_bob_1_volume.tar.bz2
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: '${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}'
service_account: '${{ secrets.GCP_SERVICE_ACCOUNT }}'

- name: Deploy to GCP
if: failure()
uses: actions/upload-artifact@v3.1.1
uses: google-github-actions/upload-cloud-storage@v1.0.3
with:
name: logsAndImages
path: |
./logs.tgz
/tmp/mangata_bob_1.tar
/tmp/mangata_alice_1.tar
path: devops/parachain-launch/output
destination: mangata-node-ci-cache/${{ github.sha }}/${{ env.MATRIX_COMMAND_PATH }}

- name: Stop previous parachain if running
working-directory: devops/parachain-launch/output
run: |
Expand All @@ -285,7 +267,6 @@ jobs:
needs: [setup-report, e2e-test-matrix]
if: always()
runs-on: ubuntu-latest

steps:
- name: Install testmo
run: npm install --no-save @testmo/testmo-cli
Expand All @@ -304,7 +285,6 @@ jobs:
needs: [e2e-test-matrix]
if: failure()
runs-on: ubuntu-latest

steps:
- name: Slack Notification - Error
uses: bryannice/gitactions-slack-notification@2.0.0
Expand Down

0 comments on commit 83aeeb4

Please sign in to comment.