Skip to content

Commit

Permalink
build: add support to gcov and codecov
Browse files Browse the repository at this point in the history
Add support to gcov through a `npm install` flag
(`--llnode_coverage=true`), and update Travis settings to upload
coverage report to CodeCov on success.

PR-URL: #258
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
mmarchini committed Feb 8, 2019
1 parent 59b65c4 commit 43edf43
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ package-lock.json
# Generated by scripts/configure.js
config.gypi
llnode.js
*.gcov
*.info
39 changes: 28 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,42 @@ matrix:
dist: trusty
before_install:
- sudo apt-get -qq update
- sudo apt-get install lldb-3.9 liblldb-3.9-dev -y
install: npm install --llnode_build_addon=true
- sudo apt-get install lldb-3.9 liblldb-3.9-dev lcov -y
install:
- npm install --llnode_build_addon=true --llnode_coverage=true
script: TEST_LLDB_BINARY=`which lldb-3.9` npm run test-all
node_js: "6"
after_success:
- npm run coverage
- npm run codecov-upload

- name: "[Trusty] Node.js v8.x"
sudo: required
dist: trusty
before_install:
- sudo apt-get -qq update
- sudo apt-get install lldb-3.9 liblldb-3.9-dev -y
install: npm install --llnode_build_addon=true
- sudo apt-get install lldb-3.9 liblldb-3.9-dev lcov -y
install:
- npm install --llnode_build_addon=true
script: TEST_LLDB_BINARY=`which lldb-3.9` npm run test-all
node_js: "8"
after_success:
- npm run coverage
- npm run codecov-upload

- name: "[Trusty] Node.js v10.x"
sudo: required
dist: trusty
before_install:
- sudo apt-get -qq update
- sudo apt-get install lldb-3.9 liblldb-3.9-dev -y
install: npm install --llnode_build_addon=true
- sudo apt-get install lldb-3.9 liblldb-3.9-dev lcov -y
install:
- npm install --llnode_build_addon=true --llnode_coverage=true
script: TEST_LLDB_BINARY=`which lldb-3.9` npm run test-all
node_js: "10"

after_success:
- npm run coverage
- npm run codecov-upload

###########################
# Nightlies & V8 Canaries #
Expand All @@ -47,13 +58,16 @@ matrix:
dist: trusty
before_install:
- sudo apt-get -qq update
- sudo apt-get install lldb-3.9 liblldb-3.9-dev -y
- sudo apt-get install lldb-3.9 liblldb-3.9-dev lcov -y
install:
- npm install --nodedir=$(dirname $(dirname $(which node)))/include/node
script: TEST_LLDB_BINARY=`which lldb-3.9` npm run test-plugin
script: TEST_LLDB_BINARY=`which lldb-3.9` npm run test
env:
- NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly
- NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly
after_success:
- npm run coverage
- npm run codecov-upload

# Addon is not tested due to lack of node-addon-api
- name: "[Trusty] Node.js V8 Canary"
Expand All @@ -62,13 +76,16 @@ matrix:
dist: trusty
before_install:
- sudo apt-get -qq update
- sudo apt-get install lldb-3.9 liblldb-3.9-dev -y
- sudo apt-get install lldb-3.9 liblldb-3.9-dev lcov -y
install:
- npm install --nodedir=$(dirname $(dirname $(which node)))/include/node
script: TEST_LLDB_BINARY=`which lldb-3.9` npm run test-plugin
script: TEST_LLDB_BINARY=`which lldb-3.9` npm run test
env:
- NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/v8-canary
- NODEJS_ORG_MIRROR=https://nodejs.org/download/v8-canary
after_success:
- npm run coverage
- npm run codecov-upload

########
# OS X #
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ plugin: configure
addon: configure-with-addon
node-gyp rebuild

.PHONY: coverage
coverage:
lcov --capture --directory build/ --output-file coverage-cc.info
lcov --remove coverage-cc.info "/usr/*" "*/deps/*" "*/node_modules/*" --output-file coverage-cc.info # filter system-files
lcov --list coverage-cc.info

.PHONY: clean
clean:
$(RM) -r build
Expand Down
5 changes: 5 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"lldb_lib_dir%": "",
"lldb_lib_so%": "",
"build_addon": "false",
"coverage": "false",
},

"target_defaults": {
Expand Down Expand Up @@ -39,6 +40,10 @@
"<(lldb_lib_dir)/<(lldb_lib)",
],
}],
[ "coverage == 'true'", {
"cflags": [ "--coverage" ],
"ldflags" : [ "--coverage" ],
}],
]
},

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"test-plugin": "tape test/plugin/*-test.js",
"test-addon": "tape test/addon/*-test.js",
"test-all": "npm run test-addon && npm run test-plugin",
"test": "npm run test-plugin"
"test": "npm run test-plugin",
"coverage": "make coverage",
"codecov-upload": "codecov --disable=gcov --file=coverage-cc.info"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -44,6 +46,7 @@
},
"homepage": "https://github.com/nodejs/llnode#readme",
"devDependencies": {
"codecov": "^3.1.0",
"tape": "^4.4.0"
},
"dependencies": {
Expand Down
11 changes: 10 additions & 1 deletion scripts/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,24 @@ function main() {

main();

// Do not build addon by default until it's less experimental
function configureBuildOptions(config) {
// Do not build addon by default until it's less experimental
const build_addon = (process.env.npm_config_llnode_build_addon ||
process.env.LLNODE_BUILD_ADDON);
if (build_addon) {
config.variables.build_addon = build_addon;
} else {
config.variables.build_addon = 'false';
}

// Optionally build with support for gcov
const coverage = (process.env.npm_config_llnode_coverage ||
process.env.LLNODE_COVERAGE);
if (coverage) {
config.variables.coverage = coverage;
} else {
config.variables.coverage = 'false';
}
}

/**
Expand Down

0 comments on commit 43edf43

Please sign in to comment.