Skip to content

Integration Test [Playwright] #316

Integration Test [Playwright]

Integration Test [Playwright] #316

name: Integration Test [Playwright]
on:
push:
branches:
- test
workflow_dispatch:
inputs:
deployment:
required: true
type: choice
default: "govtool.cardanoapi.io"
options:
- "sanchogov.tools"
- "staging.govtool.byron.network"
- "govtool.cardanoapi.io"
- "preview.gov.tools"
- "gov.tools"
workflow_run:
workflows: ["Build and deploy GovTool to TEST server"]
types: [completed]
jobs:
integration-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: tests/govtool-frontend/playwright
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
cache-dependency-path: "./tests/govtool-frontend/playwright/package-lock.json"
- name: Install dependencies
run: npm ci
- name: Cache Playwright browsers
id: cache-playwright-browsers
uses: actions/cache@v3
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-browsers
- name: Install Playwright browsers if not cached
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Run tests
run: |
mkdir -p ./lib/_mock
chmod +w ./lib/_mock
npm run generate-wallets
# Set network variables based on deployment input and environment
if [[ "${{inputs.deployment}}" == "gov.tools" ]]; then
export NETWORK='mainnet'
else
export NETWORK="${{ vars.NETWORK }}"
fi
# Set API keys based on the network
if [[ "${{ vars.NETWORK }}" == "preprod" ]]; then
export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREPROD }}"
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREPROD }}"
elif [[ "${{ vars.NETWORK }}" == "sanchonet" ]]; then
export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_SANCHONET }}"
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_SANCHONET }}"
else
export FAUCET_API_KEY="${{ secrets.FAUCET_API_KEY_PREVIEW }}"
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREVIEW }}"
fi
npm test
- name: Upload report
uses: actions/upload-artifact@v3
if: always()
with:
name: allure-results
path: tests/govtool-frontend/playwright/allure-results
- name: Upload lock logs
uses: actions/upload-artifact@v3
if: always()
with:
name: lock-logs
path: tests/govtool-frontend/playwright/lock_logs.txt
env:
HOST_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}
API_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}/api
DOCS_URL: ${{ vars.DOCS_URL }}
KUBER_API_KEY: ${{secrets.KUBER_API_KEY}}
TEST_WORKERS: ${{vars.TEST_WORKERS}}
CI: ${{vars.CI}}
FAUCET_ADDRESS: ${{vars.FAUCET_ADDRESS}}
CARDANOAPI_METADATA_URL: ${{vars.CARDANOAPI_METADATA_URL}}
PROPOSAL_FAUCET_PAYMENT_PRIVATE: ${{secrets.PROPOSAL_FAUCET_PAYMENT_PRIVATE}}
PROPOSAL_FAUCET_STAKE_PRIVATE: ${{secrets.PROPOSAL_FAUCET_STAKE_PRIVATE}}
publish-report:
runs-on: ubuntu-latest
if: always()
needs: integration-tests
steps:
- uses: actions/checkout@v4
- name: Download report
uses: actions/download-artifact@v3
with:
name: allure-results
path: allure-results
- name: Get Allure history
uses: actions/checkout@v4
continue-on-error: true
with:
ref: gh-pages
path: gh-pages
repository: ${{vars.GH_PAGES}}
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Register report
id: register-project
if: ${{success()}}
run: |
chmod +x .github/scripts/register_report.sh
.github/scripts/register_report.sh
- if: steps.register-project.outputs.project_exists != 'true'
uses: JamesIves/github-pages-deploy-action@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
repository-name: ${{vars.GH_PAGES}}
branch: gh-pages
folder: project
- name: Generate report details
id: report-details
run: |
chmod +x .github/scripts/generate_report_details.sh
.github/scripts/generate_report_details.sh
- name: Build report
uses: simple-elf/allure-report-action@master
if: always()
id: allure-report
with:
allure_results: allure-results
gh_pages: gh-pages/${{env.REPORT_NAME}}
allure_report: allure-report
allure_history: allure-history
keep_reports: 2000
report_url: ${{steps.report-details.outputs.report_url}}
github_run_num: ${{steps.report-details.outputs.report_number}}
- name: Generate Latest Report
run: |
chmod +x .github/scripts/generate_latest_report_redirect.sh
.github/scripts/generate_latest_report_redirect.sh ${{steps.report-details.outputs.report_number}}
- name: Deploy report to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
repository-name: ${{vars.GH_PAGES}}
branch: gh-pages
folder: build
target-folder: ${{ env.REPORT_NAME }}
env:
REPORT_NAME: govtool-frontend
GH_PAGES: ${{vars.GH_PAGES}}