diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..646378b8 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,68 @@ +version: 2.0 +jobs: + install: + docker: + - image: circleci/node:10.2 + working_directory: ~/repo + steps: + - checkout + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + - run: npm install + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + test: + docker: + - image: circleci/node:10.2 + working_directory: ~/repo + steps: + - checkout + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + - run: + name: Tests with coverage + command: npm run test-ci + - run: + name: Install codecov + command: npm i codecov + - run: + name: Submit coverage + command: ./node_modules/.bin/codecov + + lint: + docker: + - image: circleci/node:10.2 + + working_directory: ~/repo + steps: + - checkout + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + - run: + name: Lint + command: npm run lint-ci + +workflows: + version: 2 + test_and_lint: + jobs: + - install + - lint: + requires: + - install + - test: + requires: + - install + + diff --git a/.gitignore b/.gitignore index f7ff5cd2..f875848a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ docker_data/ browser/bcoin* package-lock.json npm-debug.log +coverage/ diff --git a/README.md b/README.md index ccac739f..817f7148 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Bcoin +[![Build Status][circleci-status-img]][circleci-status-url] +[![Coverage Status][coverage-status-img]][coverage-status-url] + __NOTE__: The latest release of bcoin contains a non-backward compatible change to the rest API. Please read the [changelog]'s "migrating" section for more details. @@ -69,3 +72,8 @@ See LICENSE for more info. [freenode]: https://freenode.net/ [irc]: irc://irc.freenode.net/bcoin [changelog]: https://github.com/bcoin-org/bcoin/blob/master/CHANGELOG.md + +[coverage-status-img]: https://codecov.io/gh/bcoin-org/bcoin/badge.svg?branch=master +[coverage-status-url]: https://codecov.io/gh/bcoin-org/bcoin?branch=master +[circleci-status-img]: https://circleci.com/gh/bcoin-org/bcoin/tree/master.svg?style=shield +[circleci-status-url]: https://circleci.com/gh/bcoin-org/bcoin/tree/master diff --git a/package.json b/package.json index c074df96..cec871dd 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "babelify": "^8.0.0", "browserify": "^16.2.2", "eslint": "^4.19.1", + "istanbul": "^1.1.0-alpha.1", "jsdoc": "^3.5.5", "mocha": "^5.2.0", "uglify-es": "^3.3.9", @@ -77,11 +78,13 @@ "clean": "rm -f {browser/,}{bcoin.js,bcoin-worker.js,app.js,worker.js}", "docs": "jsdoc -c jsdoc.json", "lint": "eslint $(cat .eslintfiles) || exit 0", + "lint-ci": "eslint $(cat .eslintfiles)", "lint-file": "eslint", "test": "mocha --reporter spec test/*.js", "test-browser": "NODE_BACKEND=js mocha --reporter spec test/*.js", "test-file": "mocha --reporter spec", "test-file-browser": "NODE_BACKEND=js mocha --reporter spec", + "test-ci": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec test/*.js", "webpack": "webpack --config webpack.browser.js", "webpack-browser": "webpack --config webpack.browser.js", "webpack-compat": "webpack --config webpack.compat.js",