Microapps UI tests #629
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: Microapps UI tests | |
on: | |
workflow_dispatch: | |
inputs: | |
scriptName: | |
description: 'Name of the script to run' | |
required: false | |
default: 'test-gasp-ui' | |
environment: | |
description: 'Environment to run the tests:[develop,testnet]' | |
required: false | |
default: '' | |
uiUrl: | |
description: 'http address of app ui' | |
required: false | |
default: '' | |
# For manual triggering | |
jobs: | |
test: | |
name: Run UI tests | |
runs-on: ubuntu-latest | |
env: | |
API_URL: 'wss://collator-01-ws-rollup-frontend.gasp.xyz' | |
TEST_SUDO_NAME: ${{ secrets.TEST_SUDO_NAME }} | |
TEST_SCRIPT: 'test-gasp-ui' | |
TEST_ENV_TAG: 'develop' | |
NODE_ENV: test | |
UI_URL : 'https://gasp-testnet-dot-direct-pixel-353917.oa.r.appspot.com/' | |
SELENIUM_REMOTE_URL: http://localhost:4444/wd/hub | |
MNEMONIC_META: 'twelve insect obvious hurdle control nature search response march version cake buffalo' | |
PRIVKEY_META: ${{ secrets.PRIVKEY_META }} | |
outputs: | |
testmo-run-id: ${{ steps.setTestRun.outputs.testmo-run-id }} | |
steps: | |
- name: Set Script to run | |
run: | | |
echo ${{ github.event.inputs.scriptName }} | |
if [ "$FROM_INPUT" != "" ]; then | |
echo "Input" | |
echo "TEST_SCRIPT=${{ github.event.inputs.scriptName }}" >> $GITHUB_ENV | |
echo "TEST_ENV_TAG=${{ github.event.inputs.environment }}" >> $GITHUB_ENV | |
echo "UI_URL=${{ github.event.inputs.uiUrl }}" >> $GITHUB_ENV | |
fi | |
if [ "$FROM_PAYLOAD" != "" ]; then | |
echo "Payload" | |
echo "TEST_SCRIPT=${{ github.event.client_payload.scriptName }}" >> $GITHUB_ENV | |
echo "TEST_ENV_TAG=${{ github.event.client_payload.environment }}" >> $GITHUB_ENV | |
echo "UI_URL=${{ github.event.client_payload.uiUrl }}" >> $GITHUB_ENV | |
fi | |
echo 'WEBHOOK_URL=${{ secrets.STG_SLACK_WEBHOOK }}' >> $GITHUB_ENV | |
env: | |
FROM_INPUT: ${{ github.event.inputs.scriptName }} | |
FROM_PAYLOAD: ${{ github.event.client_payload.scriptName }} | |
- name: Start Selenoid Server | |
uses: Xotabu4/selenoid-github-action@v2 | |
with: | |
selenoid-start-arguments: | | |
--args "-timeout 300s" --browsers 'chrome:110.0;chrome:112.0;chrome:114.0' | |
- name: Set Configuration - testnet | |
if: contains(github.event.client_payload.environment, 'testnet') || contains(github.event.inputs.environment, 'testnet') | |
run: | | |
echo 'API_URL=wss://collator-01-ws-rollup-holesky.gasp.xyz' >> $GITHUB_ENV | |
- name: Set Configuration - Develop | |
if: contains(github.event.client_payload.environment, 'develop') || contains(github.event.inputs.environment, 'develop') | |
run: | | |
echo 'API_URL=wss://collator-01-ws-rollup-frontend.gasp.xyz' >> $GITHUB_ENV | |
echo 'TEST_SUDO_NAME=${{ secrets.DEV_SUDO_NAME }}' >> $GITHUB_ENV | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: yarn | |
- name: Install testmo | |
run: yarn global add @testmo/testmo-cli | |
- name: Install dependencies with Yarn | |
run: yarn | |
- name: Tsc code quality check | |
run: yarn tsc-lint | |
- name: ESLint code quality check | |
run: yarn eslint | |
- name: installed packages | |
run: yarn list | |
- name: is selenoid started? | |
run: curl http://localhost:4444/status | |
- name: Add extra params | |
run: | | |
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" | |
testmo automation:resources:add-link --name build \ | |
--url $RUN_URL --resources resources.json | |
- name: Create test run | |
run: | | |
testmo automation:run:create \ | |
--instance https://mangata-finance.testmo.net \ | |
--project-id 2 \ | |
--name "FE microapps e2e test run" \ | |
--resources resources.json \ | |
--source "fe-microapps-e2e-job" > testmo-run-id.txt \ | |
--tags ${{ env.TEST_ENV_TAG }} | |
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 | |
- name: Run tests | |
run: yarn ${{ env.TEST_SCRIPT }} | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: JEST Tests # Name of the check run which will be created | |
path: reports/*.xml # Path to test results | |
reporter: jest-junit # Format of test results | |
- name: Submit results to the testmo-run | |
if: always() | |
run: | | |
testmo automation:run:submit-thread \ | |
--instance https://mangata-finance.testmo.net \ | |
--run-id $(cat testmo-run-id.txt) \ | |
--results reports/*.xml | |
env: | |
TESTMO_URL: ${{ secrets.TESTMO_URL }} | |
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }} | |
- name: Sleep for 5 seconds | |
run: sleep 10s #close buffers of videos. | |
- name: Copy video files to reports folder | |
if: success() || failure() | |
run: "cp ~/.aerokube/selenoid/* -r reports/artifacts/" | |
- name: Create reports zip | |
uses: vimtor/action-zip@v1 | |
if: success() || failure() | |
with: | |
files: reports/ | |
dest: reports.zip | |
- name: Archive report files | |
uses: actions/upload-artifact@v4 | |
if: success() || failure() | |
with: | |
name: ReportData | |
path: reports.zip | |
- name: Archive report files | |
uses: actions/upload-artifact@v4 | |
if: success() || failure() | |
with: | |
name: TestReport | |
path: reports/html-report/report.html | |
- name: Slack Notification - OK | |
if: success() | |
uses: bryannice/[email protected] | |
env: | |
SLACK_INCOMING_WEBHOOK: ${{ env.WEBHOOK_URL }} | |
SLACK_TITLE: 'Slack Notification - results - OK' | |
SLACK_COLOR: "#00ff11" | |
SLACK_MESSAGE: 'Test succeed in [ ${{ env.TEST_SCRIPT }} ]- ${{ env.UI_URL }} - ${{ env.API_URL }} - ${{ github.ref }} | |
testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{ env.ID }}' | |
GITHUB_REF: 'https://mangata-finance.github.io/mangata-e2e/${{ github.run_number }}' | |
- name: Slack Notification - Error | |
if: failure() | |
uses: bryannice/[email protected] | |
env: | |
SLACK_INCOMING_WEBHOOK: ${{ env.WEBHOOK_URL }} | |
SLACK_TITLE: 'Slack Notification - results - NOOK' | |
SLACK_COLOR: "#ff0011" | |
SLACK_MESSAGE: 'Test failures [ ${{ env.TEST_SCRIPT }} ]- ${{ env.UI_URL }} - ${{ env.API_URL }} - ${{ github.ref }} | |
testmo report: https://mangata-finance.testmo.net/automation/runs/view/${{ env.ID }}' | |
GITHUB_REF: 'https://mangata-finance.github.io/mangata-e2e/${{ github.run_number }}' | |
test-complete: | |
needs: [test] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
cache: yarn | |
- name: Install testmo | |
run: yarn global add @testmo/testmo-cli | |
- name: Complete test run | |
run: | | |
testmo automation:run:complete \ | |
--instance https://mangata-finance.testmo.net \ | |
--run-id ${{needs.test.outputs.testmo-run-id}} | |
env: | |
TESTMO_URL: ${{ secrets.TESTMO_URL }} | |
TESTMO_TOKEN: ${{ secrets.TESTMO_TOKEN }} |