Integration Test [Playwright] #842
This file contains hidden or 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: Integration Test [Playwright] | |
| permissions: | |
| contents: read | |
| checks: write | |
| statuses: write | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| deployment: | |
| required: true | |
| type: choice | |
| default: "p80-z6b8d2f7a-ze34e4cb2-gtw.z937eb260.rustrocks.fr" | |
| options: | |
| - "sanchogov.tools" | |
| - "staging.govtool.byron.network" | |
| - "govtool.cardanoapi.io" | |
| - "p80-z6b8d2f7a-ze34e4cb2-gtw.z937eb260.rustrocks.fr" | |
| - "preview.gov.tools" | |
| - "gov.tools" | |
| - "p80-z78acf3c2-zded6a792-gtw.z937eb260.rustrocks.fr" | |
| network: | |
| required: true | |
| type: choice | |
| default: "preview" | |
| options: | |
| - "sanchonet" | |
| - "preview" | |
| - "mainnet" | |
| - "preprod" | |
| workflow_run: | |
| workflows: ["Check and Build QA"] | |
| types: [completed] | |
| branches: | |
| - test | |
| - infra/test-chores | |
| schedule: | |
| - cron: "0 0 * * *" # 12AM UTC | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| integration-tests: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' || github.event.schedule }} | |
| outputs: | |
| start_time: ${{ steps.set-pending-status.outputs.timestamp }} | |
| status: ${{ steps.run-test.outcome }} | |
| defaults: | |
| run: | |
| working-directory: tests/govtool-frontend/playwright | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ env.COMMIT_SHA }} | |
| - name: Set pending commit status | |
| if: ${{ !github.event.schedule }} | |
| id: set-pending-status | |
| run: | | |
| echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT | |
| curl -X POST -H "Authorization: Bearer ${{ github.token }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }} \ | |
| -d "{\"state\": \"pending\", \"context\": \"Playwright Tests : ${{env.HOST_URL}}\", \"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" | |
| - 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@v4 | |
| 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: Initial delay 5 mins | |
| run: sleep 300 | |
| - name: Run tests | |
| id: run-test | |
| run: | | |
| mkdir -p ./lib/_mock | |
| chmod +w ./lib/_mock | |
| npm run generate-wallets | |
| # Set API keys based on the network | |
| if [[ "${{ env.NETWORK }}" == "preprod" ]]; then | |
| export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREPROD }}" | |
| elif [[ "${{ env.NETWORK }}" == "sanchonet" ]]; then | |
| export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_SANCHONET }}" | |
| elif [[ "${{ env.NETWORK }}" == "preview" ]]; then | |
| export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_PREVIEW }}" | |
| else | |
| export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_MAINNET }}" | |
| fi | |
| # Set schedule workflow variable | |
| if [[ "$GITHUB_EVENT_NAME" == "schedule" ]]; then | |
| export SCHEDULED_WORKFLOW="true" | |
| fi | |
| npm run test:headless | |
| - name: Upload report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: allure-results | |
| path: tests/govtool-frontend/playwright/allure-results | |
| - name: Upload lock logs | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: lock-logs | |
| path: tests/govtool-frontend/playwright/lock_logs.txt | |
| env: | |
| DOCS_URL: ${{ vars.DOCS_URL }} | |
| KUBER_API_KEY: ${{secrets.KUBER_API_KEY}} | |
| NETWORK: ${{ inputs.network || vars.NETWORK }} | |
| TEST_WORKERS: ${{vars.TEST_WORKERS}} | |
| CI: ${{vars.CI}} | |
| FAUCET_ADDRESS: ${{vars.FAUCET_ADDRESS}} | |
| CARDANOAPI_METADATA_URL: ${{vars.CARDANOAPI_METADATA_URL}} | |
| FAUCET_PAYMENT_PRIVATE: ${{secrets.FAUCET_PAYMENT_PRIVATE}} | |
| FAUCET_STAKE_PRIVATE: ${{secrets.FAUCET_STAKE_PRIVATE}} | |
| publish-report: | |
| runs-on: ubuntu-latest | |
| if: always() && needs.integration-tests.result != 'skipped' | |
| needs: integration-tests | |
| outputs: | |
| report_number: ${{ steps.report-details.outputs.report_number }} | |
| group_name: ${{ steps.set-deployment-url.outputs.group_name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download report | |
| uses: actions/download-artifact@v4 | |
| 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: Set Deployment Environment | |
| id: set-deployment-url | |
| run: | | |
| chmod +x .github/scripts/set_deployment_environment.sh | |
| .github/scripts/set_deployment_environment.sh | |
| - name: Remove oldest report to save space | |
| if: ${{success()}} | |
| run: | | |
| chmod +x .github/scripts/remove_oldest_report.sh | |
| .github/scripts/remove_oldest_report.sh | |
| - 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/${{steps.set-deployment-url.outputs.group_name}}/${{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: ${{steps.set-deployment-url.outputs.group_name}}/${{ env.REPORT_NAME }} | |
| publish-status: | |
| runs-on: ubuntu-latest | |
| if: always() && needs.integration-tests.result != 'skipped' | |
| needs: [integration-tests, publish-report] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: allure-results | |
| path: allure-results | |
| - name: Set Commit Status | |
| if: always() && !github.event.schedule | |
| run: | | |
| chmod +x .github/scripts/set_commit_status.sh | |
| .github/scripts/set_commit_status.sh | |
| env: | |
| START_TIME: ${{ needs.integration-tests.outputs.start_time }} | |
| TEST_STATUS: ${{ needs.integration-tests.outputs.status }} | |
| REPORT_NUMBER: ${{ needs.publish-report.outputs.report_number }} | |
| GITHUB_TOKEN: ${{ github.token }} | |
| GROUP_NAME: ${{ needs.publish-report.outputs.group_name }} | |
| env: | |
| HOST_URL: https://${{ github.event.schedule && 'preview.gov.tools' || (inputs.deployment || 'p80-z6b8d2f7a-ze34e4cb2-gtw.z937eb260.rustrocks.fr') }} | |
| DEPLOYMENT: ${{ github.event.schedule && 'preview.gov.tools' || inputs.deployment || 'p80-z6b8d2f7a-ze34e4cb2-gtw.z937eb260.rustrocks.fr'}} | |
| REPORT_NAME: ${{ github.event.schedule && 'nightly-'}}govtool-frontend | |
| GH_PAGES: ${{vars.GH_PAGES}} | |
| COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }} |