From 85d03f5e182865bc1eb255f7f3bec040b3ca14b7 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Wed, 31 Aug 2016 09:27:07 -0700 Subject: [PATCH] Set up istanbul with codeclimate and travis. (#1046) * Set up istanbul with codeclimate and travis. * Put the codeclimate tocken inside .travis.yml --- .travis.yml | 10 +++-- caravel/assets/.eslintignore | 1 + caravel/assets/.istanbul.yml | 54 ++++++++++++++++++++++++++ caravel/assets/js_build.sh | 3 ++ caravel/assets/package.json | 6 ++- caravel/assets/spec/helpers/browser.js | 2 - 6 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 caravel/assets/.istanbul.yml diff --git a/.travis.yml b/.travis.yml index 9e84a1c29..5f72d3eb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,20 @@ + language: python addons: + code_climate: + repo_token: 5f3a06c425eef7be4b43627d7d07a3e46c45bdc07155217825ff7c49cb6a470c apt: sources: - deadsnakes packages: - python3.5 - code_climate: - repo_token: 5f3a06c425eef7be4b43627d7d07a3e46c45bdc07155217825ff7c49cb6a470c cache: directories: - $HOME/.wheelhouse/ env: global: - TRAVIS_CACHE=$HOME/.travis_cache/ + - TRAVIS_NODE_VERSION="5.11" matrix: #- TOX_ENV=py27-mysql - TOX_ENV=py27-sqlite @@ -22,7 +24,7 @@ env: - TOX_ENV=py34-postgres - TOX_ENV=javascript before_install: - - npm install -g npm@'>=2.7.1' + - npm install -g npm@'>=3.9.5' before_script: - mysql -e 'drop database if exists caravel; create database caravel DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci' -u root - psql -c 'create database caravel;' -U postgres @@ -30,4 +32,6 @@ before_script: install: - pip install --upgrade pip - pip install tox tox-travis + - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION + - npm install script: tox -e $TOX_ENV diff --git a/caravel/assets/.eslintignore b/caravel/assets/.eslintignore index 56f591640..b34e2dc70 100644 --- a/caravel/assets/.eslintignore +++ b/caravel/assets/.eslintignore @@ -3,3 +3,4 @@ vendor/* dist/* stylesheets/* spec/* +coverage/** diff --git a/caravel/assets/.istanbul.yml b/caravel/assets/.istanbul.yml new file mode 100644 index 000000000..356247bc6 --- /dev/null +++ b/caravel/assets/.istanbul.yml @@ -0,0 +1,54 @@ +verbose: true +instrumentation: + root: './javascripts' + extensions: ['.js', '.jsx'] + excludes: [ + 'dist/**' + ] + embed-source: false + variable: __coverage__ + compact: true + preserve-comments: false + complete-copy: false + save-baseline: true + baseline-file: ./coverage/coverage-baseline.json + include-all-sources: true + include-pid: false + es-modules: true +reporting: + print: summary + reports: + - lcov + dir: ./coverage + watermarks: + statements: [50, 80] + lines: [50, 80] + functions: [50, 80] + branches: [50, 80] + report-config: + clover: {file: clover.xml} + cobertura: {file: cobertura-coverage.xml} + json: {file: coverage-final.json} + json-summary: {file: coverage-summary.json} + lcovonly: {file: lcov.info} + teamcity: {file: null, blockName: Code Coverage Summary} + text: {file: null, maxCols: 0} + text-lcov: {file: lcov.info} + text-summary: {file: null} +hooks: + hook-run-in-context: false + post-require-hook: null + handle-sigint: false +check: + global: + statements: 0 + lines: 0 + branches: 0 + functions: 0 + excludes: [] + each: + statements: 0 + lines: 0 + branches: 0 + functions: 0 + excludes: [] diff --git a/caravel/assets/js_build.sh b/caravel/assets/js_build.sh index 98f9696bf..ffe37e590 100755 --- a/caravel/assets/js_build.sh +++ b/caravel/assets/js_build.sh @@ -2,7 +2,10 @@ set -e cd "$(dirname "$0")" npm --version +node --version npm install npm run lint npm run test npm run prod +npm run cover +CODECLIMATE_REPO_TOKEN=5f3a06c425eef7be4b43627d7d07a3e46c45bdc07155217825ff7c49cb6a470c ./node_modules/.bin/codeclimate-test-reporter < ./coverage/lcov.info diff --git a/caravel/assets/package.json b/caravel/assets/package.json index e725a6043..321def764 100644 --- a/caravel/assets/package.json +++ b/caravel/assets/package.json @@ -7,7 +7,8 @@ "test": "spec" }, "scripts": { - "test": "npm run lint && mocha --compilers js:babel-core/register --required spec/helpers/browser.js spec/**/*_spec.*", + "test": "npm run lint && mocha --compilers js:babel-core/register --require spec/helpers/browser.js --recursive spec/**/*_spec.*", + "cover": "babel-node ./node_modules/.bin/istanbul cover _mocha -- --require spec/helpers/browser.js --recursive spec/**/*_spec.*", "dev": "NODE_ENV=dev webpack -d --watch --colors --progress", "prod": "NODE_ENV=production webpack -p --colors --progress", "lint": "npm run --silent lint:js", @@ -36,6 +37,7 @@ "homepage": "https://github.com/airbnb/caravel#readme", "dependencies": { "autobind-decorator": "^1.3.3", + "babel-cli": "^6.14.0", "bootstrap": "^3.3.6", "bootstrap-datepicker": "^1.6.0", "brace": "^0.7.0", @@ -90,6 +92,7 @@ "babel-preset-es2015": "^6.9.0", "babel-preset-react": "^6.11.1", "chai": "^3.5.0", + "codeclimate-test-reporter": "^0.3.3", "css-loader": "^0.23.1", "enzyme": "^2.0.0", "eslint": "^2.13.1", @@ -98,6 +101,7 @@ "eslint-plugin-jsx-a11y": "^2.0.1", "eslint-plugin-react": "^5.2.2", "exports-loader": "^0.6.3", + "istanbul": "^1.0.0-alpha", "file-loader": "^0.8.5", "imports-loader": "^0.6.5", "jsdom": "^8.0.1", diff --git a/caravel/assets/spec/helpers/browser.js b/caravel/assets/spec/helpers/browser.js index bccf9461a..a4f196607 100644 --- a/caravel/assets/spec/helpers/browser.js +++ b/caravel/assets/spec/helpers/browser.js @@ -18,5 +18,3 @@ Object.keys(document.defaultView).forEach((property) => { global.navigator = { userAgent: 'node.js', }; - -documentRef = document;