Precommit E2E Tests #1415
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: Precommit E2E Tests | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| reason: | |
| description: Why this test run was started | |
| required: false | |
| type: string | |
| grep: | |
| type: string | |
| description: Define which tests to run, the given value will be passed to the `--grep` flag of playwright | |
| pull_request: | |
| types: [labeled, opened, synchronize, reopened] | |
| schedule: | |
| - cron: '17 8,20 * * *' | |
| timezone: Europe/Berlin | |
| # Concurrency is limited per event per branch as each event uses a different environment and we want to cancel runs if the same branch receives new commits. | |
| # The reused workflow precommit-slot-run.yml already enforces concurrency limits per environment so e.g. two PRs can't run on the same env at the same time. | |
| concurrency: | |
| group: precommit-crit-flows-${{ github.event_name }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| if: ${{ github.repository == 'wireapp/wire-webapp' && (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-e2e')) }} | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 20 | |
| outputs: | |
| build_artifact: ${{ env.BUILD_ARTIFACT }} | |
| env_name: ${{ steps.slot.outputs.env_name }} | |
| env: | |
| BUILD_DIR: apps/server/dist/s3/ | |
| BUILD_ARTIFACT: ebs.zip | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 0 | |
| - name: Add repository Yarn wrapper to PATH | |
| run: echo "$GITHUB_WORKSPACE/bin" >> "$GITHUB_PATH" | |
| - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'yarn' | |
| - run: ./bin/yarn --immutable | |
| - run: ./bin/yarn nx run webapp:configure | |
| - env: | |
| WIRE_WEBAPP_BUILD_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }} | |
| run: | | |
| short_commit_sha="${WIRE_WEBAPP_BUILD_COMMIT::7}" | |
| WIRE_WEBAPP_BUILD_VERSION="dev-${short_commit_sha}" \ | |
| ./bin/yarn build:prod | |
| - name: Compute target EB environment | |
| id: slot | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| # If the PR was labelled with "run-e2e" execute the workflow against a third environment | |
| echo "env_name=wire-webapp-precommit-3" >> "$GITHUB_OUTPUT" | |
| elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| # Keep manual runs away from the scheduled critical-flow slot. | |
| echo "env_name=wire-webapp-precommit-2" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "env_name=wire-webapp-precommit-1" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Log target EB environment | |
| env: | |
| ENV_NAME: ${{ steps.slot.outputs.env_name }} | |
| run: | | |
| echo "Selected precommit environment: $ENV_NAME" | |
| echo "Selected precommit URL: https://$ENV_NAME.zinfra.io/" | |
| - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: build-artifact | |
| path: ${{ env.BUILD_DIR }}${{ env.BUILD_ARTIFACT }} | |
| deploy_and_run_e2e: | |
| name: Deploy to precommit and run E2E | |
| if: ${{ success() && github.repository == 'wireapp/wire-webapp' }} | |
| needs: [build] | |
| uses: ./.github/workflows/precommit-slot-run.yml | |
| with: | |
| env_name: ${{ needs.build.outputs.env_name }} | |
| grep: '' | |
| notify_deployoholics_on_failure: ${{ github.event_name == 'schedule' }} | |
| secrets: | |
| OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
| WEBTEAM_AWS_ACCESS_KEY_ID: ${{ secrets.WEBTEAM_AWS_ACCESS_KEY_ID }} | |
| WEBTEAM_AWS_SECRET_ACCESS_KEY: ${{ secrets.WEBTEAM_AWS_SECRET_ACCESS_KEY }} | |
| WIRE_DEPLOYOHOLICS_WEBHOOK_URL: ${{ secrets.WIRE_DEPLOYOHOLICS_WEBHOOK_URL }} | |
| run_e2e_tests: | |
| name: Playwright Critical Flow | |
| if: ${{ always() && github.repository == 'wireapp/wire-webapp' && (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-e2e')) }} | |
| needs: [deploy_and_run_e2e] | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Report Status | |
| env: | |
| DEPLOY_AND_RUN_E2E_RESULT: ${{ needs.deploy_and_run_e2e.result }} | |
| run: | | |
| echo "E2E tests completed with status - $DEPLOY_AND_RUN_E2E_RESULT" | |
| if [ "$DEPLOY_AND_RUN_E2E_RESULT" != "success" ]; then | |
| echo "Playwright Critical Flow failed because the upstream E2E workflow did not succeed." | |
| exit 1 | |
| fi | |
| e2e-report: | |
| name: Generate test summary | |
| needs: [build, deploy_and_run_e2e] | |
| if: ${{ always() && github.repository == 'wireapp/wire-webapp' && (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') }} | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Download report | |
| if: ${{ needs.deploy_and_run_e2e.outputs.reportArtifactId != '' }} | |
| continue-on-error: true | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c | |
| with: | |
| artifact-ids: ${{ needs.deploy_and_run_e2e.outputs.reportArtifactId }} | |
| path: apps/webapp/playwright-report | |
| - name: Write step summary | |
| env: | |
| BACKEND_URL: https://staging-nginz-https.zinfra.io/ | |
| DEPLOY_AND_RUN_E2E_RESULT: ${{ needs.deploy_and_run_e2e.result }} | |
| ENV_NAME: ${{ needs.build.outputs.env_name }} | |
| PRECOMMIT_URL: ${{ needs.deploy_and_run_e2e.outputs.precommit_url }} | |
| REPORT_URL: ${{ needs.deploy_and_run_e2e.outputs.reportUrl }} | |
| WORKFLOW_DISPATCH_REASON: ${{ inputs.reason }} | |
| run: | | |
| { | |
| echo "## Playwright E2E Test Summary" | |
| echo "" | |
| echo "- Environment: \`$ENV_NAME\`" | |
| echo "- Webapp URL: $PRECOMMIT_URL" | |
| echo "- Backend URL: $BACKEND_URL" | |
| echo "- Result: \`$DEPLOY_AND_RUN_E2E_RESULT\`" | |
| } >> "$GITHUB_STEP_SUMMARY" | |
| if [[ -n "$WORKFLOW_DISPATCH_REASON" ]]; then | |
| echo "- Manual run reason: $WORKFLOW_DISPATCH_REASON" >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| if [[ -n "$REPORT_URL" ]]; then | |
| echo "- Report artifact: $REPORT_URL" >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| echo "- Report artifact: unavailable" >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| REPORT_FILE="apps/webapp/playwright-report/report.json" | |
| if [[ ! -f "$REPORT_FILE" ]]; then | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "No Playwright report summary is available." >> "$GITHUB_STEP_SUMMARY" | |
| exit 0 | |
| fi | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "### Failure Summary" >> "$GITHUB_STEP_SUMMARY" | |
| FAILED_TESTS="$(jq -r '[.. | objects | select(has("specs") and (.specs | length > 0)) | .title as $suite | .specs[] | .title as $title | .tests[] | select(.status == "unexpected") | "- " + $suite + " > " + $title] | unique | .[]?' "$REPORT_FILE" || true)" | |
| if [[ -n "$FAILED_TESTS" ]]; then | |
| echo "$FAILED_TESTS" >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| echo "No failed tests found in the report." >> "$GITHUB_STEP_SUMMARY" | |
| fi |