Skip to content

Commit 9d953c5

Browse files
authored
Re-enable coveralls (#1064)
This patch re-enables `coveralls` by leveraging: - `nyc`: https://github.com/istanbuljs/nyc/blob/main/README.md#selecting-files-for-coverage - `Coveralls Action`: https://github.com/marketplace/actions/coveralls-github-action Fix: #1063
1 parent af19b4c commit 9d953c5

File tree

6 files changed

+41
-5
lines changed

6 files changed

+41
-5
lines changed

.github/workflows/linux-build-and-test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,20 @@ jobs:
5252
npm i
5353
npm run lint
5454
npm test
55+
56+
- name: Coveralls Parallel
57+
uses: coverallsapp/github-action@v2
58+
with:
59+
github-token: ${{ secrets.GITHUB_TOKEN }}
60+
flag-name: run-${{ matrix.node-version}}
61+
parallel: true
62+
63+
finish:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Coveralls Finished
68+
uses: coverallsapp/github-action@v2
69+
with:
70+
github-token: ${{ secrets.GITHUB_TOKEN }}
71+
parallel-finished: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ build
2020
log
2121
.vscode
2222
.project
23+
.nyc_output/
24+
coverage/
2325

2426
# test build artifacts
2527
/test/cpp/add_two_ints_client

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ suppr.txt
1111
types/interfaces.d.ts
1212
generated/
1313
build/
14+
coverage/
1415
dist/
1516
electron_demo/
1617
log/
@@ -21,5 +22,6 @@ example/
2122
benchmark/
2223
tutorials/
2324
.github/
25+
.nyc_output/
2426
.vscode/
2527
.husky/

.nycrc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extension:
2+
- .js
3+
include:
4+
- lib/**/*
5+
report-dir: './coverage'
6+
reporter:
7+
- lcov

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
"install": "npm run rebuild",
2424
"postinstall": "npm run generate-messages",
2525
"docs": "cd docs && make",
26-
"test": "node --expose-gc ./scripts/run_test.js && npx tsd",
26+
"test": "nyc node --expose-gc ./scripts/run_test.js && npx tsd",
2727
"lint": "eslint && node ./scripts/cpplint.js",
2828
"format": "clang-format -i -style=file ./src/*.cpp ./src/*.hpp && prettier --write \"{lib,rosidl_gen,rostsd_gen,rosidl_parser,types,example,test,scripts,benchmark}/**/*.{js,md,ts}\" ./*.{js,md,ts}",
29-
"prepare": "husky"
29+
"prepare": "husky",
30+
"coverage": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
3031
},
3132
"bin": {
3233
"generate-ros-messages": "./scripts/generate_messages.js"
@@ -49,6 +50,7 @@
4950
"@typescript-eslint/parser": "^8.18.0",
5051
"clang-format": "^1.8.0",
5152
"commander": "^13.1.0",
53+
"coveralls": "^3.1.1",
5254
"deep-equal": "^2.2.3",
5355
"eslint": "^9.16.0",
5456
"eslint-config-prettier": "^10.0.2",
@@ -58,6 +60,7 @@
5860
"jsdoc": "^4.0.4",
5961
"lint-staged": "^15.2.10",
6062
"mocha": "^11.0.2",
63+
"nyc": "^17.1.0",
6164
"rimraf": "^6.0.1",
6265
"sinon": "^19.0.2",
6366
"tree-kill": "^1.2.2",

test/test-signals.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,21 @@ function forkOnlyRemoveRclnodejsHandlers() {
2121
const myHandler = () => {};
2222
process.on('SIGINT', myHandler);
2323
rclnodejs.removeSignalHandlers();
24-
if (myHandler in process.listeners('SIGINT')) {
24+
if (process.listeners('SIGINT').includes(myHandler)) {
2525
process.exitCode = 0;
2626
} else {
2727
process.exitCode = 1;
2828
}
2929
}
3030

3131
function forkRemoveSignalHandlers() {
32+
const listenerCount = process.listenerCount('SIGINT');
3233
rclnodejs.removeSignalHandlers();
33-
process.exitCode = process.listenerCount('SIGINT');
34+
if (listenerCount - 1 === process.listenerCount('SIGINT')) {
35+
process.exitCode = 0;
36+
} else {
37+
process.exitCode = 1;
38+
}
3439
}
3540

3641
function forkDoPublish(context) {
@@ -146,7 +151,7 @@ if (process.env['RCLNODEJS_TEST_FORK']) {
146151
);
147152
await new Promise((res) => {
148153
child.on('close', (exitCode) => {
149-
assert.strictEqual(exitCode, 1);
154+
assert.strictEqual(exitCode, 0);
150155
res();
151156
});
152157
});

0 commit comments

Comments
 (0)