Skip to content

Commit 1a0901f

Browse files
committed
chore(config): add cobertura coverage
1 parent 0c57f92 commit 1a0901f

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

.github/workflows/code-coverage.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,65 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12-
coverage:
12+
coverage-comment-raw:
13+
name: 📝 PR Raw Coverage Table
14+
runs-on: ubuntu-latest
15+
permissions:
16+
pull-requests: write
17+
contents: read
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Run coverage and extract table
24+
run: |
25+
npm run test:coverage > full-coverage.txt || true
26+
sed -n '/^-------------------------|---------|----------|---------|---------|/,$p' full-coverage.txt | \
27+
sed '/^=============================== Coverage summary ===============================/,$d' | \
28+
# Remove first and last border lines:
29+
sed '1d;$d' > coverage-table.txt
30+
31+
- name: Comment test results
32+
uses: marocchino/sticky-pull-request-comment@v2
33+
with:
34+
header: "jest-coverage-raw"
35+
recreate: true
36+
path: coverage-table.txt
37+
38+
coverage-comment:
39+
name: 📝 PR Coverage Summary
40+
runs-on: ubuntu-latest
41+
permissions:
42+
pull-requests: write
43+
contents: read
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: actions/setup-node@v4
47+
with:
48+
node-version: 22
49+
cache: 'npm'
50+
- name: Install dependencies
51+
run: npm ci
52+
- name: Run coverage
53+
run: npm run test:coverage
54+
- name: Comment coverage summary
55+
uses: irongut/CodeCoverageSummary@v1.3.0
56+
with:
57+
filename: reports/coverage/cobertura-coverage.xml
58+
badge: true
59+
format: markdown
60+
output: both
61+
indicators: true
62+
- name: Post coverage comment
63+
uses: marocchino/sticky-pull-request-comment@v2
64+
with:
65+
header: "jest-coverage-summary"
66+
recreate: true
67+
path: code-coverage-results.md
68+
69+
coverage-upload-codecov:
70+
name: 📤 Upload Coverage to Codecov
1371
runs-on: ubuntu-latest
1472
steps:
1573
- name: ⬇️ Checkout repository

jest.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
resetModules: true,
88
collectCoverageFrom: ['src/**/*.ts'],
99
coverageDirectory: 'reports/coverage',
10-
coverageReporters: ['text', 'text-summary', 'lcov'],
10+
coverageReporters: ['text', 'text-summary', 'lcov', 'cobertura'],
1111
reporters: [
1212
'default',
1313
[

0 commit comments

Comments
 (0)