Skip to content

Commit be9259e

Browse files
committed
feat(ci): add coverage badge generation
Add automatic coverage badge SVG generation using jaywcjlove/coverage-badges-cli action. Changes: - Add json-summary reporter to vitest coverage config - Generate badges.svg from coverage-summary.json in CI - Badge will be available at GitHub Pages URL/badges.svg This enables adding a coverage badge to README that automatically updates when coverage changes.
1 parent 0c7bf74 commit be9259e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ jobs:
4545
if: github.ref == 'refs/heads/main'
4646
run: nix develop --command pnpm run coverage
4747

48+
- name: Create Coverage Badge
49+
if: github.ref == 'refs/heads/main'
50+
uses: jaywcjlove/coverage-badges-cli@e07f25709cd25486855c1ba1b26da53476dfb763 # v2.3.2
51+
with:
52+
source: coverage/coverage-summary.json
53+
output: coverage/badges.svg
54+
4855
- name: Upload coverage artifact
4956
if: github.ref == 'refs/heads/main'
5057
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0

vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default defineConfig({
77
testTimeout: 30000,
88
coverage: {
99
provider: 'v8',
10-
reporter: ['text', 'json', 'html'],
10+
reporter: ['text', 'json', 'json-summary', 'html'],
1111
include: ['src/**/*.ts', 'examples/**/*.ts'],
1212
exclude: ['**/*.spec.ts', '**/*.test.ts', '**/*.test-d.ts', '**/tests/**'],
1313
},

0 commit comments

Comments
 (0)