-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (80 loc) · 3.45 KB
/
coverage.yml
File metadata and controls
96 lines (80 loc) · 3.45 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
name: Coverage Report
on:
pull_request:
branches: [main, develop]
push:
branches: [main, develop]
permissions:
contents: read
pull-requests: write
jobs:
coverage:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-stackwright
with:
build: true
- name: Run tests with coverage
run: pnpm test:coverage
continue-on-error: true
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage/
packages/*/coverage/
retention-days: 30
- name: Display coverage summary
if: always()
run: |
if [ -f coverage/merged/coverage-summary.json ]; then
echo "📊 Coverage Report Generated!"
echo "View the HTML report in the uploaded artifacts."
cat coverage/merged/coverage-summary.json | head -50
else
echo "⚠️ No merged coverage report found"
fi
- name: Comment PR with coverage
if: github.event_name == 'pull_request'
uses: actions/github-script@v9
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = 'coverage/merged/coverage-summary.json';
if (!fs.existsSync(path)) {
console.log('No coverage summary found');
return;
}
const coverage = JSON.parse(fs.readFileSync(path, 'utf8'));
const { totals, byPackage } = coverage;
const formatPct = (pct) => pct.toFixed(2) + '%';
const getEmoji = (pct) => pct >= 80 ? '✅' : pct >= 60 ? '⚠️' : '❌';
let comment = '## 🧪 Coverage Report\\n\\n';
comment += '### Overall Coverage\\n\\n';
comment += `| Metric | Coverage |\\n`;
comment += `|--------|----------|\\n`;
comment += `| Lines | ${getEmoji(totals.lines.pct)} ${formatPct(totals.lines.pct)} |\\n`;
comment += `| Statements | ${getEmoji(totals.statements.pct)} ${formatPct(totals.statements.pct)} |\\n`;
comment += `| Functions | ${getEmoji(totals.functions.pct)} ${formatPct(totals.functions.pct)} |\\n`;
comment += `| Branches | ${getEmoji(totals.branches.pct)} ${formatPct(totals.branches.pct)} |\\n`;
comment += '\\n### Coverage by Package\\n\\n';
comment += `| Package | Lines | Statements | Functions | Branches |\\n`;
comment += `|---------|-------|-----------|-----------|----------|\\n`;
Object.entries(byPackage)
.sort(([a], [b]) => a.localeCompare(b))
.forEach(([pkg, data]) => {
comment += `| @stackwright/${pkg} | ${formatPct(data.lines.pct)} | ${formatPct(data.statements.pct)} | ${formatPct(data.functions.pct)} | ${formatPct(data.branches.pct)} |\\n`;
});
comment += '\\n---\\n';
comment += '📊 Full HTML report available in workflow artifacts\\n';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});