From f09181e055dd5251054181ff9b9b08262759e558 Mon Sep 17 00:00:00 2001 From: rdlabo Date: Wed, 16 Sep 2026 11:53:40 +0900 Subject: [PATCH] ci(e2e): align PR e2e workflow with ionic-theme-ios27 - Trigger only for PRs to `main`. - Add `deploy-report` concurrency group to serialize gh-pages pushes. - Use `!cancelled()` for `comment-results` and `deploy-report` so cancellation does not try to publish a missing report. - Add `Verify published report URL` step and a marker-based PR comment. - Run `test:e2e:visual` for Ionic 8 to match ios27; add the script. - Raise `timeout-minutes` from 10 to 20 because the current visual diff plus 2 retries exceeds 10 minutes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .github/workflows/e2e-pull_request.yml | 57 ++++++++++++++++++++++---- demo/package.json | 1 + 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e-pull_request.yml b/.github/workflows/e2e-pull_request.yml index 40e0759..4899343 100644 --- a/.github/workflows/e2e-pull_request.yml +++ b/.github/workflows/e2e-pull_request.yml @@ -2,6 +2,8 @@ name: E2E Screenshot Tests Pull Request on: pull_request: + branches: + - main types: [opened, synchronize, closed] permissions: @@ -10,7 +12,8 @@ permissions: jobs: test: if: github.event.action != 'closed' - timeout-minutes: 10 + # ios27 uses 10, but this PR's large visual diff + 2 retries exceeds that. + timeout-minutes: 20 runs-on: ubuntu-latest permissions: contents: read @@ -48,7 +51,12 @@ jobs: working-directory: './demo' - name: Run Playwright tests - run: PLAYWRIGHT_JSON_OUTPUT_NAME=e2e/screenshot.spec.ts-ionic${{ matrix.ionic-major }}.json npm run test:e2e -- --reporter=json,html + run: | + if [ "${{ matrix.ionic-major }}" = "8" ]; then + PLAYWRIGHT_JSON_OUTPUT_NAME=e2e/screenshot.spec.ts-ionic8.json npm run test:e2e:visual -- --reporter=json,html + else + PLAYWRIGHT_JSON_OUTPUT_NAME=e2e/screenshot.spec.ts-ionic9.json npm run test:e2e -- --reporter=json,html + fi working-directory: ./demo env: IONIC_MAJOR: ${{ matrix.ionic-major }} @@ -89,6 +97,7 @@ jobs: needs: test if: >- always() && + !cancelled() && github.event.action != 'closed' && github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest @@ -110,8 +119,12 @@ jobs: deploy-report: needs: test + # Serialize gh-pages pushes for the same PR and avoid deploying on cancellations. + concurrency: + group: playwright-report-${{ github.event.pull_request.number }} + cancel-in-progress: false if: >- - always() && + !cancelled() && github.event.action != 'closed' && github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest @@ -154,6 +167,11 @@ jobs: user_email: 'github-actions[bot]@users.noreply.github.com' commit_message: 'Update test report for PR #${{ github.event.pull_request.number }}' + - name: Verify published report URL + env: + REPORT_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}/ + run: curl --fail --silent --show-error --location --retry 6 --retry-delay 10 --retry-all-errors --max-time 20 --output /dev/null "$REPORT_URL" + - name: Comment PR with report link uses: actions/github-script@v7 if: always() @@ -162,12 +180,35 @@ jobs: const prNumber = context.payload.pull_request.number; const reportUrl = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr-${prNumber}/`; - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - body: `📊 **Ionic 9 Playwright Test Report**\n\nView the detailed Ionic 9 report: ${reportUrl}\n\nIonic 8 runs against the same screenshots in a separate matrix job. View both results in the [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}).` + const marker = ''; + const body = `${marker}\n` + `📊 **Ionic 9 Playwright Test Report**\n\nView the detailed Ionic 9 report: ${reportUrl}\n\nIonic 8 runs against the same screenshots in a separate matrix job. View both results in the [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}).`; + const comments = await github.paginate(github.rest.issues.listComments, { + ...context.repo, + issue_number: prNumber }); + const reports = comments.filter(comment => + comment.user?.login === 'github-actions[bot]' && + (comment.body?.includes(marker) || comment.body?.startsWith('📊 **Ionic 9 Playwright Test Report**')) + ); + if (reports.length > 0) { + await github.rest.issues.updateComment({ + ...context.repo, + comment_id: reports[0].id, + body + }); + for (const duplicate of reports.slice(1)) { + await github.rest.issues.deleteComment({ + ...context.repo, + comment_id: duplicate.id + }); + } + } else { + await github.rest.issues.createComment({ + ...context.repo, + issue_number: prNumber, + body + }); + } cleanup-report: if: >- diff --git a/demo/package.json b/demo/package.json index 1131478..cb9f2eb 100644 --- a/demo/package.json +++ b/demo/package.json @@ -14,6 +14,7 @@ "pretest": "npm run docs:generate", "test": "ng test", "test:e2e": "playwright test", + "test:e2e:visual": "playwright test e2e/screenshot.spec.ts", "test:e2e:ui": "playwright test --ui", "test:e2e:debug": "playwright test --debug", "test:e2e:update": "playwright test --update-snapshots",