Skip to content

Commit 3c41413

Browse files
committed
ci: add coverage gate at 80% line threshold
Adds test:coverage script and replaces the plain test step in CI with a coverage run + inline Node assertion. Prevents silent regressions — coverage was only documented in CHANGELOG prose.
1 parent 5f029f8 commit 3c41413

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,18 @@ jobs:
2828
- name: Lint and format check
2929
run: bun run check
3030

31-
- name: Unit tests
32-
run: bun run test
31+
- name: Unit tests with coverage
32+
run: |
33+
bun run test:coverage 2>&1 | tee /tmp/coverage.txt
34+
node -e "
35+
const out = require('fs').readFileSync('/tmp/coverage.txt', 'utf8');
36+
const m = out.match(/all files[^\|]*\|\s*([\d.]+)/i);
37+
if (!m) { console.log('No coverage summary found — skipping threshold check.'); process.exit(0); }
38+
const pct = parseFloat(m[1]);
39+
const min = 80;
40+
if (pct < min) { process.stderr.write('Coverage ' + pct.toFixed(1) + '% is below minimum ' + min + '%\n'); process.exit(1); }
41+
console.log('Coverage OK: ' + pct.toFixed(1) + '%');
42+
"
3343
3444
- name: Assert Node.js version
3545
run: node -e "const v=+process.version.slice(1).split('.')[0]; if(v<22)process.exit(1)"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"check": "biome check .",
3333
"check:fix": "biome check --write .",
3434
"test": "bun test src/",
35+
"test:coverage": "bun test src/ --coverage",
3536
"prepublishOnly": "bun run build && bun run check && bun run test",
3637
"setup-hooks": "git config core.hooksPath .githooks"
3738
},

0 commit comments

Comments
 (0)