Skip to content

Commit 2452a06

Browse files
committed
Add manual workflow for coverage
1 parent 63ff72e commit 2452a06

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
cache: npm
6767
- name: Install dependencies
6868
run: npm ci
69-
- name: run unit tests
69+
- name: Run unit tests
7070
run: npm run test
7171

7272
build:

.github/workflows/coverage.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Coverage
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
artifact:
7+
type: boolean
8+
name:
9+
type: string
10+
default: coverage
11+
12+
jobs:
13+
coverage:
14+
name: Collect unit test coverage
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version-file: .nvmrc
24+
cache: npm
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run unit tests
30+
run: npm run test:coverage
31+
32+
- name: Compress coverage results into ZIP
33+
if: ${{ inputs.artifact }}
34+
run: cd coverage && zip -r ../coverage.zip *
35+
36+
- name: Upload coverage artifact
37+
if: ${{ inputs.artifact }}
38+
uses: actions/upload−artifact@v4
39+
with:
40+
name: ${{ inputs.name }}
41+
path: coverage.zip

jest.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
module.exports = {
33
preset: "ts-jest",
44
testEnvironment: "node",
5-
collectCoverage: true,
65
};

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"build": "tsc",
66
"start": "node ./dist/index.js",
77
"test": "jest",
8+
"test:coverage": "jest --collectCoverage --coverageDirectory=coverage --coverageReporters=html --coverageReporters=text",
89
"lint": "eslint src/**/* --max-warnings=0",
910
"format": "prettier . --check"
1011
},

0 commit comments

Comments
 (0)