-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (50 loc) · 1.72 KB
/
Copy pathci.yml
File metadata and controls
60 lines (50 loc) · 1.72 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
name: CI
on:
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- run: npm ci
- run: npm run test:coverage
- name: Post coverage comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
node -e "
const s = require('./coverage/coverage-summary.json').total
const p = m => s[m].pct
const icon = v => v === 100 ? '✅' : '⚠️'
const body = [
'<!-- bucketline-coverage -->',
'### Test Coverage',
'| Statements | Branches | Functions | Lines |',
'|---|---|---|---|',
\`| \${icon(p('statements'))} \${p('statements')}% | \${icon(p('branches'))} \${p('branches')}% | \${icon(p('functions'))} \${p('functions')}% | \${icon(p('lines'))} \${p('lines')}% |\`,
].join('\n')
require('fs').writeFileSync('/tmp/cov.md', body)
"
PR="${{ github.event.pull_request.number }}"
REPO="${{ github.repository }}"
ID=$(gh api "repos/${REPO}/issues/${PR}/comments" \
--jq '[.[] | select(.body | contains("bucketline-coverage"))] | first | .id // empty')
if [ -n "$ID" ]; then
gh api "repos/${REPO}/issues/comments/${ID}" -X PATCH -f "body=$(cat /tmp/cov.md)"
else
gh pr comment "$PR" --body-file /tmp/cov.md
fi
- uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: coverage/
retention-days: 14