Skip to content

chore(deps)(deps): bump the production-dependencies group across 1 directory with 3 updates #401

chore(deps)(deps): bump the production-dependencies group across 1 directory with 3 updates

chore(deps)(deps): bump the production-dependencies group across 1 directory with 3 updates #401

name: Playwright E2E Tests
permissions:
contents: read
pull-requests: write
deployments: read
on:
pull_request:
push:
branches:
- master
schedule:
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual trigger
jobs:
e2e:
name: E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 20
env:
IS_PR: ${{ github.event_name == 'pull_request' && 'true' || 'false' }}
IS_NIGHTLY: ${{ github.event_name == 'schedule' && 'true' || 'false' }}
PROD_URL: 'https://vinto-game.vercel.app/'
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps
# Installs chromium, firefox, and webkit for cross-browser testing
- name: Wait for Vercel Preview Deployment
if: github.event_name == 'pull_request'
uses: patrickedqvist/wait-for-vercel-preview@v1.3.3
id: vercel-preview
continue-on-error: true
with:
token: ${{ secrets.GITHUB_TOKEN }}
max_timeout: 300
check_interval: 10
- name: Set PLAYWRIGHT_TEST_BASE_URL for entire job (PR)
if: github.event_name == 'pull_request' && steps.vercel-preview.outputs.url != ''
run: echo "PLAYWRIGHT_TEST_BASE_URL=${{ steps.vercel-preview.outputs.url }}" >> $GITHUB_ENV
- name: Run Playwright tests against Vercel Preview
if: github.event_name == 'pull_request' && steps.vercel-preview.outputs.url != ''
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ steps.vercel-preview.outputs.url }}
run: npm run test:e2e
- name: Run Playwright tests against manual URL
if: github.event_name == 'workflow_dispatch' && inputs.preview_url != ''
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ inputs.preview_url }}
run: npm run test:e2e
- name: Run Playwright tests against production (nightly/master)
if: github.event_name == 'schedule' || github.event_name == 'push'
env:
PLAYWRIGHT_TEST_BASE_URL: ${{ env.PROD_URL }}
run: npm run test:e2e
- name: Run Playwright tests locally (fallback)
if: |
(github.event_name == 'pull_request' && steps.vercel-preview.outcome != 'success') ||
(github.event_name == 'workflow_dispatch' && inputs.preview_url == '')
run: npm run test:e2e
- name: Upload Playwright report
uses: actions/upload-artifact@v6
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
if-no-files-found: warn
- name: Upload accessibility reports
uses: actions/upload-artifact@v6
if: always()
with:
name: accessibility-reports
path: accessibility-reports/
retention-days: 30
if-no-files-found: ignore
comment:
name: Post Test Results Comment
needs: e2e
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
pull-requests: write
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Download Playwright report
uses: actions/download-artifact@v7
with:
name: playwright-report
path: playwright-report/
continue-on-error: true
- name: Download accessibility reports
uses: actions/download-artifact@v7
with:
name: accessibility-reports
path: accessibility-reports/
continue-on-error: true
- name: Generate test report summary
id: report-summary
run: node tools/generate-e2e-report.js
- name: Get artifact URLs
id: artifact-urls
uses: actions/github-script@v8
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
});
const playwrightArtifact = artifacts.data.artifacts.find(a => a.name === 'playwright-report');
const accessibilityArtifact = artifacts.data.artifacts.find(a => a.name === 'accessibility-reports');
const baseUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/artifacts`;
return {
playwright: playwrightArtifact ? `${baseUrl}/${playwrightArtifact.id}` : '',
accessibility: accessibilityArtifact ? `${baseUrl}/${accessibilityArtifact.id}` : ''
};
- name: Comment PR with test results
uses: actions/github-script@v8
with:
script: |
const reportBase64 = '${{ steps.report-summary.outputs.report }}';
const e2eJobStatus = '${{ needs.e2e.result }}';
const artifactUrls = ${{ steps.artifact-urls.outputs.result }};
if (!reportBase64) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 🎭 Playwright E2E Test Results\n\n` +
`❌ **E2E Job**: ${e2eJobStatus}\n\n` +
`⚠️ Test report generation failed. [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`
});
return;
}
const reportJson = Buffer.from(reportBase64, 'base64').toString('utf-8');
const report = JSON.parse(reportJson);
// Build status line based on e2e job and test results
let statusLine = '';
if (e2eJobStatus !== 'success') {
statusLine = `❌ **E2E Job**: ${e2eJobStatus}\n\n`;
} else if (report.testResults?.stats.total === 0) {
statusLine = `⚠️ **E2E Job**: Tests did not run\n\n`;
} else if (report.testResults?.stats.failed > 0 || report.accessibility?.totalViolations > 0) {
statusLine = `❌ **E2E Job**: Tests failed\n\n`;
} else {
statusLine = `✅ **E2E Job**: All passed\n\n`;
}
let message = '## 🎭 Playwright E2E Test Results\n\n';
message += statusLine;
// Add test results and accessibility summary
if (report.summary && report.summary.length > 0) {
message += report.summary;
} else if (!report.hasReport) {
message += '⚠️ No report data found\n';
} else {
message += '✅ Tests completed\n';
}
message += `\n---\n\n`;
message += `📊 [View full test run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})\n`;
// Add artifact download links
if (artifactUrls?.playwright) {
message += `📦 [Download Playwright report](${artifactUrls.playwright})\n`;
}
if (artifactUrls?.accessibility) {
message += `♿ [Download accessibility reports](${artifactUrls.accessibility})\n`;
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});