Skip to content

Commit 2077c2c

Browse files
fail ci if we fall short of 100% coverage, and rename some npm tasks.
1 parent 52ff300 commit 2077c2c

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,21 @@ jobs:
3131
- name: Install dependencies
3232
run: npm install
3333
- name: Run tests
34-
run: npm run test-move-before
34+
run: npm run test:move-before
35+
36+
coverage:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
- name: Use Node.js
42+
uses: actions/setup-node@v4
43+
with:
44+
cache: 'npm'
45+
- name: Install dependencies
46+
run: npm install
47+
- name: Check code coverage
48+
run: npm run test:coverage
3549

3650
typecheck:
3751
runs-on: ubuntu-latest

TESTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This will run the tests using Playwright’s headless browser setup across Chrom
2727

2828
To run all tests against Chrome with experimental `moveBefore` support added, execute:
2929
```bash
30-
npm run test-move-before
30+
npm run test:move-before
3131
```
3232
This will start headless Chrome in a new profile with the `atomic-move` experimental flag set. This runs in a separate job in CI.
3333

@@ -50,7 +50,7 @@ This runs all the tests in the browser using Mocha instead of web-test-runner fo
5050

5151
If you really want to open web-test-runner in headed mode, you can run:
5252
```bash
53-
npm run debug
53+
npm run test:debug
5454
```
5555
This will start the server, and open the test runner in a browser. From there you can choose a test file to run.
5656

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
"unpkg": "dist/idiomorph.min.js",
2121
"scripts": {
2222
"test": "web-test-runner",
23-
"debug": "web-test-runner --manual --open",
24-
"test-move-before": "USE_MOVE_BEFORE=1 web-test-runner",
23+
"test:coverage": "web-test-runner && node test/lib/ensure-full-coverage.js",
24+
"test:debug": "web-test-runner --manual --open",
25+
"test:move-before": "USE_MOVE_BEFORE=1 web-test-runner",
2526
"ci": "web-test-runner --fail-only --playwright --browsers chromium firefox webkit",
2627
"perf": "node perf/runner.js",
2728
"amd": "(echo \"define(() => {\n\" && cat src/idiomorph.js && echo \"\nreturn Idiomorph});\") > dist/idiomorph.amd.js",
@@ -46,6 +47,7 @@
4647
"chromedriver": "^131.0.5",
4748
"fs-extra": "^9.1.0",
4849
"htmx.org": "1.9.9",
50+
"lcov-parse": "^1.0.0",
4951
"mocha": "^11.0.1",
5052
"prettier": "^3.4.2",
5153
"sinon": "^9.2.4",

test/lib/ensure-full-coverage.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const lcovParse = require("lcov-parse");
2+
3+
lcovParse("coverage/lcov.info", (err, data) => {
4+
if (err) {
5+
console.error("Error parsing lcov file:", err);
6+
process.exit(1);
7+
}
8+
9+
data.forEach((record) => {
10+
["lines", "functions", "branches"].forEach((type) => {
11+
if(record[type].hit !== record[type].found) {
12+
process.exit(1);
13+
}
14+
});
15+
});
16+
});

0 commit comments

Comments
 (0)