Repository navigation
109 lines (100 loc) · 4.17 KB
/
Copy pathcreate_test_report.yml
File metadata and controls
109 lines (100 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Publish Test Results
on:
workflow_run:
workflows: ["tests 1", "tests 2", "tests others", "MCP"]
types:
- completed
permissions: {}
jobs:
merge-reports:
permissions:
pull-requests: write
checks: write
contents: read # This is required for actions/checkout to succeed
if: ${{ github.event.workflow_run.event == 'pull_request' }}
runs-on: ubuntu-latest
outputs:
pr_number: ${{ steps.pr.outputs.number }}
has_failures: ${{ steps.failures.outputs.has_failures }}
triage_allowed: ${{ steps.pr.outputs.triage_allowed }}
env:
MARKDOWN_OUTPUT_FILE: ${{ github.workspace }}/report.md
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: lts/*
- 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: Detect failures
id: failures
run: |
if [ -f "$MARKDOWN_OUTPUT_FILE" ] && grep -qE '\*\*[0-9]+ failed\*\*' "$MARKDOWN_OUTPUT_FILE"; then
echo "has_failures=true" >> "$GITHUB_OUTPUT"
else
echo "has_failures=false" >> "$GITHUB_OUTPUT"
fi
# 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 and triage allow-list
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"
AUTHOR=$(gh pr view --repo "${{ github.repository }}" "$HEAD_REF" --json author --jq '.author.login' 2>/dev/null || true)
TRIAGE_ALLOWED=false
case "$AUTHOR" in
app/github-actions|app/microsoft-playwright-automation)
TRIAGE_ALLOWED=true
;;
*)
if [ -n "$AUTHOR" ]; then
PERM=$(gh api "repos/${{ github.repository }}/collaborators/$AUTHOR/permission" --jq .permission 2>/dev/null || echo none)
case "$PERM" in write|admin) TRIAGE_ALLOWED=true ;; esac
fi
;;
esac
echo "triage_allowed=$TRIAGE_ALLOWED" >> "$GITHUB_OUTPUT"
- name: Post report comment to PR
if: ${{ steps.pr.outputs.number }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
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,
});
triage:
needs: merge-reports
if: ${{ needs.merge-reports.outputs.has_failures == 'true' && needs.merge-reports.outputs.pr_number && needs.merge-reports.outputs.triage_allowed == 'true' }}
permissions:
contents: read
actions: read
pull-requests: write
copilot-requests: write
uses: ./.github/workflows/pr-ci-triage.yml
with:
pr_number: ${{ needs.merge-reports.outputs.pr_number }}