From bfa06b26c3ce327bf5a6b77f73be1a8aeec09641 Mon Sep 17 00:00:00 2001 From: Pixelastic Date: Tue, 22 Dec 2015 12:27:54 +0100 Subject: [PATCH] docs(readme): Add badges This adds badges to the readme, including the coverage one (through coveralls). --- .coveralls.yml | 1 + .eslintignore | 1 + .gitignore | 1 + .travis.yml | 1 + README.md | 18 +++++++++++++++--- package.json | 4 ++++ scripts/test-ci | 4 ++-- scripts/test-coverage | 19 +++++++++++++++++++ scripts/travis-after-script | 5 +++++ 9 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 .coveralls.yml create mode 100755 scripts/test-coverage create mode 100755 scripts/travis-after-script diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 00000000..91600595 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +service_name: travis-ci diff --git a/.eslintignore b/.eslintignore index 5c53e32e..a3c063fc 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ +coverage/ dist/ docs/ diff --git a/.gitignore b/.gitignore index e3f8c0c4..8bad676a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +coverage/ node_modules/ dist/ npm-debug.log* diff --git a/.travis.yml b/.travis.yml index c7790e9d..3af04174 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ before_install: before_cache: npm prune install: npm install script: ./scripts/test-ci +after_script: ./scripts/travis-after-script branches: only: - master diff --git a/README.md b/README.md index 3c5ce3a4..0117308d 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,23 @@ The easiest way to add search to your documentation. For free. -[![build status][1]](http://travis-ci.org/algolia/docsearch) -[![NPM version][2]](http://badge.fury.io/js/docsearch.js) - Check out our [website][3] to add an outstanding search to your documentation. +[![Version][version-svg]][package-url] [![Build Status][travis-svg]][travis-url] [![Coverage Status][coveralls-svg]][coveralls-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] + +[version-svg]: https://img.shields.io/npm/v/docsearch.js.svg?style=flat-square +[package-url]: https://npmjs.org/package/docsearch.js +[travis-svg]: https://img.shields.io/travis/algolia/docsearch/master.svg?style=flat-square +[travis-url]: https://travis-ci.org/algolia/docsearch +[coveralls-svg]: https://img.shields.io/coveralls/algolia/docsearch/master.svg?style=flat-square +[coveralls-url]: https://coveralls.io/github/algolia/docsearch?branch=docs%2Fbadges +[license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square +[license-url]: LICENSE +[downloads-image]: https://img.shields.io/npm/dm/docsearch.js.svg?style=flat-square +[downloads-url]: http://npm-stat.com/charts.html?package=docsearch.js +[docsearch-website]: https://community.algolia.com/docsearch/?utm_medium=social-owned&utm_source=GitHub&utm_campaign=docsearch%20repository +[docsearch-website-docs]: https://community.algolia.com/docsearch/documentation/?utm_medium=social-owned&utm_source=GitHub&utm_campaign=docsearch%20repository + ![Eslint][4] diff --git a/package.json b/package.json index 5c9d7cca..c59bf327 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "lint": "eslint .", "test": "BABEL_ENV=test mocha --reporter dot ./test/helpers.js ./test/*-test.js", "test:watch": "BABEL_ENV=test mocha --reporter min --watch ./test/helpers.js ./test/*-test.js", + "test:coverage": "./scripts/test-coverage", "gh-pages": "./scripts/gh-pages" }, "author": "Algolia (https://github.com/algolia/)", @@ -27,9 +28,11 @@ "babel": "^5.8.29", "babel-core": "^5.8.29", "babel-eslint": "^4.1.3", + "babel-istanbul": "^0.5.9", "babel-loader": "^5.3.2", "babel-plugin-rewire": "^0.1.22", "conventional-changelog": "^0.5.1", + "coveralls": "^2.11.6", "cssnano": "^3.4.0", "doctoc": "^0.15.0", "eslint": "^1.6.0", @@ -43,6 +46,7 @@ "json": "^9.0.3", "mocha": "^2.3.4", "mocha-jsdom": "^1.0.0", + "mocha-lcov-reporter": "^1.0.0", "mversion": "^1.10.1", "nd": "^1.2.0", "node-sass": "^3.4.2", diff --git a/scripts/test-ci b/scripts/test-ci index 40003aab..8cd42e53 100755 --- a/scripts/test-ci +++ b/scripts/test-ci @@ -3,12 +3,12 @@ set -ev # exit when error ./scripts/validate-pr-done-on-develop -npm test +npm run test:coverage npm prune npm run shrinkwrap --dev NODE_ENV=production npm run build ./scripts/validate-commit-msgs -if [ $TRAVIS_PULL_REQUEST == 'false' ] && [ $TRAVIS_BRANCH == 'master' ]; then +if [ "$TRAVIS_PULL_REQUEST" == 'false' ] && [ "$TRAVIS_BRANCH" == 'master' ]; then ./scripts/finish-release fi diff --git a/scripts/test-coverage b/scripts/test-coverage new file mode 100755 index 00000000..f80edff1 --- /dev/null +++ b/scripts/test-coverage @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Will run the test and export the coverage information in ./coverage +# This file will then be read by Travis to push it to Coveralls +# +# The command is long and was quite hard to write correctly. +# We need babel-istanbul and not instanbul +# We need the _mocha and not mocha +# We need to use full path for each binaries +# We need to run everything through babel-node + +npm_bin="$(npm bin)" +babel_istanbul_bin="${npm_bin}/babel-istanbul" +mocha_bin="${npm_bin}/_mocha" + +BABEL_ENV=test \ + babel-node "$babel_istanbul_bin" cover "$mocha_bin" \ + --report lcov -- \ + -R spec --reporter dot \ + ./test/helpers.js ./test/*-test.js diff --git a/scripts/travis-after-script b/scripts/travis-after-script new file mode 100755 index 00000000..0de1d0f5 --- /dev/null +++ b/scripts/travis-after-script @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Will push coverage info to coveralls. Should be ran from Travis, in the +# `after_script` section + +$(npm bin)/coveralls < ./coverage/lcov.info