Skip to content

Commit 0b9d052

Browse files
committed
ci: add test coverage configuration and CI workflow
1 parent ad46677 commit 0b9d052

4 files changed

Lines changed: 56 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
verify:
14+
name: Lint, Typecheck, Test & Build
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: 22
23+
cache: npm
24+
25+
- run: npm ci
26+
27+
- run: npm run verify:ci
28+
29+
- name: Upload coverage report
30+
if: always()
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: coverage-report
34+
path: coverage/
35+
retention-days: 14

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ dist-ssr
77
.vite/
88
.env
99

10+
# Test coverage
11+
coverage/
12+
1013
# IDE
1114
.vscode
1215
.idea

jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,21 @@ export default {
3131
tsconfig: "tsconfig.test.json"
3232
}
3333
]
34+
},
35+
collectCoverageFrom: [
36+
"src/**/*.ts",
37+
"!src/**/*.d.ts",
38+
"!src/**/index.ts",
39+
"!src/styles/**"
40+
],
41+
coverageDirectory: "coverage",
42+
coverageReporters: ["text", "text-summary", "lcov"],
43+
coverageThreshold: {
44+
global: {
45+
branches: 20,
46+
functions: 25,
47+
lines: 25,
48+
statements: 25
49+
}
3450
}
3551
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@
5555
"build:main": "vite build",
5656
"build:internal": "node scripts/build-internal.mjs",
5757
"test": "jest",
58+
"test:coverage": "jest --coverage",
5859
"test:watch": "jest --watch",
5960
"test:package": "node test-package.js",
6061
"typecheck": "tsc --noEmit && tsc --project tsconfig.test.json --noEmit",
6162
"lint": "eslint --ignore-path .gitignore .",
6263
"lint:fix": "eslint --ignore-path .gitignore --fix .",
6364
"format": "prettier --ignore-path .gitignore --write .",
64-
"verify:ci": "npm run lint && npm run typecheck && npm run test && npm run build && npm run test:package",
65+
"verify:ci": "npm run lint && npm run typecheck && npm run test:coverage && npm run build && npm run test:package",
6566
"release:check": "npm run verify:ci && npm pack --dry-run --json",
6667
"prepublishOnly": "npm run release:check",
6768
"generate:fonts": "npx tsx scripts/fetch-google-fonts.ts"

0 commit comments

Comments
 (0)