Functional Test Suite (cron) #162
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: Functional Test Suite (cron) | |
| permissions: {} | |
| on: | |
| schedule: | |
| - cron: '0 8 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| test_env: | |
| description: 'Environment to run the functional test suite against' | |
| required: false | |
| default: '' | |
| type: choice | |
| options: | |
| - '' | |
| - stage | |
| - production | |
| jobs: | |
| functional-tests: | |
| name: Functional tests (${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }}) [${{ github.event_name }}] | |
| timeout-minutes: 60 | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| test_env: ${{ github.event_name == 'schedule' && fromJson('["stage","production"]') || fromJson('["unset"]') }} | |
| steps: | |
| - name: Fail manual run if environment is missing | |
| if: github.event_name == 'workflow_dispatch' && inputs.test_env == '' | |
| run: | | |
| echo "Please select an environment for manual runs" | |
| exit 1 | |
| - uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20.19.x | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Store Playwright’s Version | |
| run: | | |
| # Get the current Playwright version listed in package.json | |
| PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //') | |
| echo "Playwright Version: $PLAYWRIGHT_VERSION" | |
| echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV | |
| - name: Cache Playwright Browsers for Playwright's Version | |
| id: cache-playwright-browsers | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }} | |
| - name: Setup Playwright Browser | |
| if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' | |
| run: npx playwright install --with-deps | |
| - name: Run Playwright tests - ${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }} | |
| if: github.event.pull_request.user.login != 'dependabot[bot]' | |
| run: npm run functional-tests | |
| timeout-minutes: 40 | |
| env: | |
| E2E_TEST_ENV: ${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }} | |
| E2E_TEST_SECRET: ${{ secrets.E2E_TEST_SECRET }} | |
| E2E_TEST_ACCOUNT_BASE_EMAIL: ${{ secrets.E2E_TEST_ACCOUNT_BASE_EMAIL }} | |
| E2E_TEST_ACCOUNT_BASE_PASSWORD: ${{ secrets.E2E_TEST_ACCOUNT_BASE_PASSWORD }} | |
| - uses: actions/upload-artifact@v5 | |
| if: always() | |
| with: | |
| name: playwright-report-${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }} | |
| path: playwright-report/ | |
| retention-days: 30 | |
| - uses: actions/upload-artifact@v5 | |
| if: always() | |
| with: | |
| name: test-results-${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }} | |
| path: src/functional-tests/test-results/ | |
| retention-days: 30 | |
| - name: Send GitHub Action trigger data to Slack workflow | |
| id: slack | |
| uses: slackapi/[email protected] | |
| if: failure() && github.ref == 'refs/heads/main' | |
| with: | |
| webhook: ${{ secrets.SLACK_GHA_FAILURES_WEBHOOK }} | |
| webhook-type: webhook-trigger | |
| # For posting a message using Block Kit | |
| payload: | | |
| { | |
| "blocks": [ | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": "*Link to job:* *<https://github.com/mozilla/blurts-server/actions/runs/${{ github.run_id }}|Functional tests>*" | |
| } | |
| }, | |
| { | |
| "type": "divider" | |
| }, | |
| { | |
| "type": "section", | |
| "fields": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Workflow:* \n ${{ github.workflow }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Environment:* \n ${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }}" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Status:* \n ${{ job.status }}" | |
| } | |
| ] | |
| }, | |
| { | |
| "type": "section", | |
| "fields": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Ref:*\n ${{ github.ref }} " | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Triggered by:*\n ${{ github.triggering_actor }}" | |
| } | |
| ] | |
| } | |
| ] | |
| } |