From 1389f12daa6bcd32247b10a5c7bb226620c58ccc Mon Sep 17 00:00:00 2001 From: yasser khan Date: Mon, 26 May 2025 19:22:47 +0530 Subject: [PATCH] Add playwright HTML report to the status check (#30952) --- .github/workflows/e2e-fulltests-ci.yml | 12 +++- .github/workflows/e2e-tests-ci-template.yml | 66 ++++++++++++++++++++- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-fulltests-ci.yml b/.github/workflows/e2e-fulltests-ci.yml index 4a800565b4..6cfeabb838 100644 --- a/.github/workflows/e2e-fulltests-ci.yml +++ b/.github/workflows/e2e-fulltests-ci.yml @@ -252,6 +252,7 @@ jobs: SERVER: "${{ needs.generate-test-variables.outputs.SERVER }}" SERVER_IMAGE: "${{ needs.generate-test-variables.outputs.SERVER_IMAGE }}" ENABLED_DOCKER_SERVICES: "${{ needs.generate-test-variables.outputs.ENABLED_DOCKER_SERVICES }}" + TEST: "cypress" TEST_FILTER: "${{ needs.generate-test-variables.outputs.TEST_FILTER_CYPRESS }}" MM_ENV: "${{ inputs.MM_ENV || '' }}" BRANCH: "${{ needs.generate-test-variables.outputs.BRANCH }}" @@ -259,6 +260,7 @@ jobs: REPORT_TYPE: "${{ needs.generate-test-variables.outputs.REPORT_TYPE }}" ROLLING_RELEASE_commit_sha: "${{ needs.generate-test-variables.outputs.ROLLING_RELEASE_commit_sha }}" ROLLING_RELEASE_SERVER_IMAGE: "${{ needs.generate-test-variables.outputs.ROLLING_RELEASE_SERVER_IMAGE }}" + PR_NUMBER: "${{ inputs.PR_NUMBER }}" secrets: MM_LICENSE: "${{ secrets[format('MM_E2E_TEST_LICENSE_{0}_ENT', needs.generate-test-variables.outputs.server_uppercase)] }}" AUTOMATION_DASHBOARD_URL: "${{ secrets.MM_E2E_AUTOMATION_DASHBOARD_URL }}" @@ -269,6 +271,8 @@ jobs: REPORT_TM4J_TEST_CYCLE_LINK_PREFIX: "${{ secrets.MM_E2E_TEST_CYCLE_LINK_PREFIX }}" CWS_URL: "${{ needs.generate-test-variables.outputs.SERVER == 'cloud' && secrets.MM_E2E_CWS_URL || '' }}" CWS_EXTRA_HTTP_HEADERS: "${{ needs.generate-test-variables.outputs.SERVER == 'cloud' && secrets.MM_E2E_CWS_EXTRA_HTTP_HEADERS || '' }}" + AWS_ACCESS_KEY_ID: "${{ secrets.CYPRESS_AWS_ACCESS_KEY_ID }}" + AWS_SECRET_ACCESS_KEY: "${{ secrets.CYPRESS_AWS_SECRET_ACCESS_KEY }}" e2e-fulltest-playwright: needs: @@ -284,7 +288,7 @@ jobs: enable_reporting: true SERVER: "${{ needs.generate-test-variables.outputs.SERVER }}" SERVER_IMAGE: "${{ needs.generate-test-variables.outputs.SERVER_IMAGE }}" - TEST: playwright + TEST: "playwright" TEST_FILTER: "${{ needs.generate-test-variables.outputs.TEST_FILTER_PLAYWRIGHT }}" MM_ENV: "${{ inputs.MM_ENV || '' }}" BRANCH: "${{ needs.generate-test-variables.outputs.BRANCH }}" @@ -292,12 +296,15 @@ jobs: REPORT_TYPE: "${{ needs.generate-test-variables.outputs.REPORT_TYPE }}" ROLLING_RELEASE_commit_sha: "${{ needs.generate-test-variables.outputs.ROLLING_RELEASE_commit_sha }}" ROLLING_RELEASE_SERVER_IMAGE: "${{ needs.generate-test-variables.outputs.ROLLING_RELEASE_SERVER_IMAGE }}" + PR_NUMBER: "${{ inputs.PR_NUMBER }}" secrets: MM_LICENSE: "${{ secrets[format('MM_E2E_TEST_LICENSE_{0}_ENT', needs.generate-test-variables.outputs.server_uppercase)] }}" PUSH_NOTIFICATION_SERVER: "${{ secrets.MM_E2E_PUSH_NOTIFICATION_SERVER }}" REPORT_WEBHOOK_URL: "${{ secrets.MM_E2E_REPORT_WEBHOOK_URL }}" CWS_URL: "${{ needs.generate-test-variables.outputs.SERVER == 'cloud' && secrets.MM_E2E_CWS_URL || '' }}" CWS_EXTRA_HTTP_HEADERS: "${{ needs.generate-test-variables.outputs.SERVER == 'cloud' && secrets.MM_E2E_CWS_EXTRA_HTTP_HEADERS || '' }}" + AWS_ACCESS_KEY_ID: "${{ secrets.CYPRESS_AWS_ACCESS_KEY_ID }}" + AWS_SECRET_ACCESS_KEY: "${{ secrets.CYPRESS_AWS_SECRET_ACCESS_KEY }}" notify-user: runs-on: ubuntu-latest @@ -322,6 +329,7 @@ jobs: CYCLE_URL: "${{ needs.generate-test-variables.outputs.CYCLE_URL }}" RUN_CYPRESS: "${{inputs.RUN_CYPRESS == 'true' || ''}}" RUN_PLAYWRIGHT: "${{inputs.RUN_PLAYWRIGHT == 'true' || ''}}" + PLAYWRIGHT_REPORT_URL: "${{ needs.e2e-fulltest-playwright.outputs.playwright_report_url }}" steps: - name: ci/notify-user-test-completion run: | @@ -330,7 +338,7 @@ jobs: E2E test has completed for commit \`${COMMIT_SHA}\`${MM_ENV:+, with \`MM_ENV=$MM_ENV\`}. Results summary: - Cypress: ${RUN_CYPRESS:+pass rate is \`${{ needs.e2e-fulltest-cypress.outputs.pass_rate || 'unknown' }}\` (see [Automation Dashboard]($CYCLE_URL) and commit status check \`$STATUS_CHECK_CONTEXT\`)}$([ -n "${RUN_CYPRESS:-}" ] || echo -n "did not run"). - - Playwright: ${RUN_PLAYWRIGHT:+pass rate is \`${{ needs.e2e-fulltest-playwright.outputs.pass_rate || 'unknown' }}\` (see commit status check \`$STATUS_CHECK_CONTEXT-playwright\`)}$([ -n "${RUN_PLAYWRIGHT:-}" ] || echo -n "did not run"). + - Playwright: ${RUN_PLAYWRIGHT:+pass rate is \`${{ needs.e2e-fulltest-playwright.outputs.pass_rate || 'unknown' }}\` (see [Playwright Report URL]($PLAYWRIGHT_REPORT_URL) and commit status check \`$STATUS_CHECK_CONTEXT-playwright\`)}$([ -n "${RUN_PLAYWRIGHT:-}" ] || echo -n "did not run"). The run summary artifacts are available in the corresponding [Workflow Run]($WORKFLOW_RUN_URL). EOF diff --git a/.github/workflows/e2e-tests-ci-template.yml b/.github/workflows/e2e-tests-ci-template.yml index 5f1ed8547f..e75841f4b6 100644 --- a/.github/workflows/e2e-tests-ci-template.yml +++ b/.github/workflows/e2e-tests-ci-template.yml @@ -65,6 +65,9 @@ on: ROLLING_RELEASE_SERVER_IMAGE: type: string required: false + PR_NUMBER: + type: string + required: false secrets: MM_LICENSE: required: false @@ -84,6 +87,10 @@ on: required: false CWS_EXTRA_HTTP_HEADERS: required: false + AWS_ACCESS_KEY_ID: + required: false + AWS_SECRET_ACCESS_KEY: + required: false outputs: passed: value: "${{ jobs.report.outputs.passed }}" @@ -93,6 +100,8 @@ on: value: "${{ jobs.report.outputs.failed_expected }}" pass_rate: value: "${{ jobs.report.outputs.pass_rate }}" + playwright_report_url: + value: ${{ jobs.report.outputs.playwright_report_url }} jobs: update-initial-status: @@ -381,6 +390,7 @@ jobs: failed_expected: "${{ steps.calculate-results.outputs.failed_expected }}" pass_rate: "${{ steps.calculate-results.outputs.pass_rate }}" commit_status_message: "${{ steps.calculate-results.outputs.commit_status_message }}" + playwright_report_url: "${{ steps.upload-to-s3.outputs.report_url }}" steps: - name: ci/checkout-repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -434,6 +444,51 @@ jobs: e2e-tests/${{ inputs.TEST }}/logs/ e2e-tests/${{ inputs.TEST }}/results/ overwrite: true + + # Configure AWS credentials + - name: ci/aws-configure + if: (inputs.TEST == 'playwright') + uses: aws-actions/configure-aws-credentials@v4.2.0 + with: + aws-region: us-east-1 + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + # Upload the playwright reports to S3 + - name: ci/upload-results-to-s3 + if: (inputs.TEST == 'playwright') + id: upload-to-s3 + run: | + echo "🔍 Checking if results directory exists..." + + PR_NUMBER="${{ inputs.PR_NUMBER }}" + LOCAL_RESULTS_PATH="${{ inputs.TEST }}/results/" + LOCAL_LOGS_PATH="${{ inputs.TEST }}/logs/" + RUN_ID="${{ github.run_id }}" + S3_PATH="server-pr-${PR_NUMBER}/e2e-reports/${{ inputs.TEST }}/${RUN_ID}" + + echo "📤 Uploading to s3://${AWS_S3_BUCKET}/${S3_PATH}/" + + if [[ -d "$LOCAL_LOGS_PATH" ]]; then + aws s3 sync "$LOCAL_LOGS_PATH" "s3://${AWS_S3_BUCKET}/${S3_PATH}/logs/" \ + --acl public-read \ + --cache-control "no-cache" + fi + + if [[ -d "$LOCAL_RESULTS_PATH" ]]; then + aws s3 sync "$LOCAL_RESULTS_PATH" "s3://${AWS_S3_BUCKET}/${S3_PATH}/results/" \ + --acl public-read \ + --cache-control "no-cache" + fi + + REPORT_URL="https://${AWS_S3_BUCKET}.s3.amazonaws.com/${S3_PATH}/results/reporter/index.html" + echo "✅ Report uploaded to: $REPORT_URL" + + echo "report_url=$REPORT_URL" >> "$GITHUB_OUTPUT" + env: + AWS_REGION: us-east-1 + AWS_S3_BUCKET: mattermost-cypress-report + - name: ci/report-calculate-results id: calculate-results env: @@ -488,7 +543,11 @@ jobs: context: ${{ inputs.status_check_context }} description: ${{ needs.report.outputs.commit_status_message || 'Error during test execution' }} status: failure - target_url: "${{ needs.generate-test-cycle.outputs.status_check_url }}" + target_url: >- + ${{ inputs.TEST == 'playwright' + && needs.report.outputs.playwright_report_url + || needs.generate-test-cycle.outputs.status_check_url }} + update-success-final-status: runs-on: ubuntu-latest @@ -507,4 +566,7 @@ jobs: context: ${{ inputs.status_check_context }} description: ${{ needs.report.outputs.commit_status_message || 'Error during test execution' }} status: success - target_url: "${{ needs.generate-test-cycle.outputs.status_check_url }}" + target_url: >- + ${{ inputs.TEST == 'playwright' + && needs.report.outputs.playwright_report_url + || needs.generate-test-cycle.outputs.status_check_url }}