Skip to content

Publish Test Results #5710

Publish Test Results

Publish Test Results #5710

name: Publish Test Results
on:
workflow_run:
workflows: ["tests 1", "tests 2", "tests others", "MCP"]
types:
- completed
jobs:
merge-reports:
permissions:
pull-requests: write
checks: write
statuses: write
contents: read # This is required for actions/checkout to succeed
if: ${{ github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'push' }}
runs-on: ubuntu-latest
env:
MARKDOWN_OUTPUT_FILE: ${{ github.workspace }}/report.md
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 20
- run: npm ci
- run: npm run build
- name: Download blob report artifact
uses: ./.github/actions/download-artifact
with:
namePrefix: 'blob-report'
path: 'all-blob-reports'
- name: Merge reports
run: |
npx playwright merge-reports --config .github/workflows/merge.config.ts ./all-blob-reports
env:
NODE_OPTIONS: --max-old-space-size=8192
WORKFLOW_RUN_CONCLUSION: ${{ github.event.workflow_run.conclusion }}
- name: Upload HTML report
id: upload-report
uses: actions/upload-artifact@v7
with:
path: playwright-report/index.html
archive: false # Upload as a single, browser-openable file (no zip)
retention-days: 30
# The triggering workflow ran on a pull_request event, but workflow_run.pull_requests is
# empty for PRs from forks, so resolve the number from the head ref instead. gh's head
# filter wants "owner:branch" for forks but a bare branch for same-repo PRs.
- name: Resolve PR number
if: ${{ github.event.workflow_run.event == 'pull_request' }}
id: pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_REF: ${{ github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch || format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) }}
run: |
NUMBER=$(gh pr view --repo "${{ github.repository }}" "$HEAD_REF" --json number --jq '.number' 2>/dev/null || true)
echo "number=$NUMBER" >> "$GITHUB_OUTPUT"
- name: Post report comment to PR
if: ${{ steps.pr.outputs.number }}
uses: actions/github-script@v8
env:
HTML_REPORT_URL: ${{ steps.upload-report.outputs.artifact-url }}
PR_NUMBER: ${{ steps.pr.outputs.number }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { postReportComment } = require('./tests/config/postReportComment');
await postReportComment({
github,
context,
core,
reportFile: process.env.MARKDOWN_OUTPUT_FILE,
prNumber: +process.env.PR_NUMBER,
reportUrl: process.env.HTML_REPORT_URL,
});
- name: Publish Report URL as Commit Status
uses: actions/github-script@v9
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: '${{ github.event.workflow_run.head_sha }}',
state: 'success',
target_url: '${{ steps.upload-report.outputs.artifact-url }}',
context: 'HTML Report (${{ github.event.workflow_run.name }})',
});