Skip to content

Commit e91b695

Browse files
committed
chore(config): add cobertura coverage
1 parent c33ffb6 commit e91b695

File tree

5 files changed

+74
-13
lines changed

5 files changed

+74
-13
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: 🧪 PR Coverage Comments
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, edited]
6+
branches: [main]
7+
jobs:
8+
coverage-comment-raw:
9+
name: 📊 Jest PR Coverage Table (Raw)
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: write
13+
contents: read
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Install dependencies
17+
run: npm ci
18+
19+
- name: Run coverage and extract table
20+
run: |
21+
npm run test:coverage > full-coverage.txt || true
22+
sed -n '/^-------------------------|---------|----------|---------|---------|/,$p' full-coverage.txt | \
23+
sed '/^=============================== Coverage summary ===============================/,$d' | \
24+
# Remove first and last border lines:
25+
sed '1d;$d' > coverage-table.txt
26+
27+
- name: Comment test results
28+
uses: marocchino/sticky-pull-request-comment@v2
29+
with:
30+
header: "jest-coverage-raw"
31+
recreate: true
32+
path: coverage-table.txt
33+
34+
coverage-comment:
35+
name: 📝 PR Coverage Summary
36+
runs-on: ubuntu-latest
37+
permissions:
38+
pull-requests: write
39+
contents: read
40+
steps:
41+
- uses: actions/checkout@v4
42+
- uses: actions/setup-node@v4
43+
with:
44+
node-version: 22
45+
cache: 'npm'
46+
- name: Install dependencies
47+
run: npm ci
48+
- name: Run coverage
49+
run: npm run test:coverage
50+
- name: Comment coverage summary
51+
uses: irongut/CodeCoverageSummary@v1.3.0
52+
with:
53+
filename: reports/coverage/cobertura-coverage.xml
54+
badge: true
55+
format: markdown
56+
output: both
57+
indicators: true
58+
- name: Post coverage comment
59+
uses: marocchino/sticky-pull-request-comment@v2
60+
with:
61+
header: "jest-coverage-summary"
62+
recreate: true
63+
path: code-coverage-results.md
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 🧪 Test Coverage
1+
name: 📤 Upload Coverage to Codecov
22

33
on:
44
push:
@@ -9,18 +9,16 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12-
coverage:
12+
coverage-upload-codecov:
13+
if: >
14+
github.event_name != 'pull_request' ||
15+
(!contains(github.event.pull_request.title, 'WIP') && !contains(github.event.pull_request.title, '!COV'))
1316
runs-on: ubuntu-latest
17+
name: 📤 Upload Coverage to Codecov
1418
steps:
1519
- name: ⬇️ Checkout repository
1620
uses: actions/checkout@v4
1721

18-
- name: ⏭ Skip tests & coverage
19-
if: github.event_name == 'pull_request' && (contains(github.event.pull_request.title, 'WIP') || contains(github.event.pull_request.title, '!COV'))
20-
run: |
21-
echo "Skipping tests and coverage upload due to PR title containing 'WIP' or '!COV'."
22-
exit 0
23-
2422
- name: 🟢 Setup Node.js
2523
uses: actions/setup-node@v4
2624
with:

.github/workflows/node-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 🚧 Build and Lint
1+
name: 🚧 Build, Lint & Test
22

33
on:
44
push:
@@ -9,8 +9,8 @@ on:
99

1010
jobs:
1111
build:
12+
name: 🚧 Build, Lint & Test
1213
runs-on: ubuntu-latest
13-
1414
steps:
1515
- name: 📥 Checkout repository
1616
uses: actions/checkout@v4

.github/workflows/npm-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 📦 Publish to npm when pushing to main or tagging a release
22

3-
name: 📦 Publish to npm
3+
name: 📦 Auto Publish to npm
44

55
on:
66
push:
@@ -10,8 +10,8 @@ on:
1010

1111
jobs:
1212
build:
13+
name: 📦 Build & Publish Package
1314
runs-on: ubuntu-latest
14-
1515
steps:
1616
- name: ⬇️ Checkout code
1717
uses: actions/checkout@v4

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)