diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f960082 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +language: node_js +node_js: + - "stable" + +sudo: false + +notifications: + email: false + +cache: + directories: + - node_modules + - jspm_packages + +branches: + only: + - master + +install: + - npm install + - jspm config registries.github.auth $JSPM_GITHUB_AUTH_TOKEN + - node_modules/.bin/jspm install + +before_script: + - export CHROME_BIN=chromium-browser + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + +script: + - npm run ci diff --git a/README.md b/README.md index 31fdf2b..29ececb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # aurelia-history-browser +[![Build Status](https://travis-ci.org/aurelia/history-browser.svg?branch=master)](https://travis-ci.org/aurelia/history-browser) +[![Coverage Status](https://coveralls.io/repos/aurelia/history-browser/badge.svg?branch=master&service=github)](https://coveralls.io/github/aurelia/history-browser?branch=master) +[![npm Version](https://img.shields.io/npm/v/aurelia-history-browser.svg)](https://www.npmjs.com/package/aurelia-history-browser) [![ZenHub](https://raw.githubusercontent.com/ZenHubIO/support/master/zenhub-badge.png)](https://zenhub.io) [![Join the chat at https://gitter.im/aurelia/discuss](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/aurelia/discuss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/build/paths.js b/build/paths.js index 5f3730b..519ebe8 100644 --- a/build/paths.js +++ b/build/paths.js @@ -7,6 +7,7 @@ var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8')); module.exports = { root: appRoot, source: appRoot + '**/*.js', + tests: 'test/**/*.js', html: appRoot + '**/*.html', style: 'styles/**/*.css', output: 'dist/', diff --git a/build/tasks/ci.js b/build/tasks/ci.js new file mode 100644 index 0000000..fafcc93 --- /dev/null +++ b/build/tasks/ci.js @@ -0,0 +1,3 @@ +var gulp = require('gulp'); + +gulp.task('ci', ['default', 'coveralls']); diff --git a/build/tasks/default.js b/build/tasks/default.js new file mode 100644 index 0000000..b6d5e8d --- /dev/null +++ b/build/tasks/default.js @@ -0,0 +1,12 @@ +var gulp = require('gulp'); +var runSequence = require('run-sequence'); + +gulp.task('default', function(callback) { + return runSequence( + 'lint', + 'build', + 'doc', + 'test', + callback + ); +}); diff --git a/build/tasks/test.js b/build/tasks/test.js index c7af441..af251d4 100644 --- a/build/tasks/test.js +++ b/build/tasks/test.js @@ -1,40 +1,34 @@ var gulp = require('gulp'); -var Karma = require('karma').Server; +var karma = require('karma'); +var coveralls = require('gulp-coveralls'); /** * Run test once and exit */ gulp.task('test', function (done) { - new Karma({ - configFile: __dirname + '/../../karma.conf.js', - singleRun: true - }, done).start(); + new karma.Server({ + configFile: __dirname + '/../../karma.conf.js', + singleRun: true + }, function(e) { + done(e === 0 ? null : 'karma exited with status ' + e); + }).start(); }); /** * Watch for file changes and re-run tests on each change */ gulp.task('tdd', function (done) { - new Karma({ - configFile: __dirname + '/../../karma.conf.js' - }, done).start(); + new karma.Server({ + configFile: __dirname + '/../../karma.conf.js' + }, function(e) { + done(); + }).start(); }); /** - * Run test once with code coverage and exit + * Report coverage to coveralls */ -gulp.task('cover', function (done) { - new Karma({ - configFile: __dirname + '/../../karma.conf.js', - singleRun: true, - reporters: ['coverage'], - preprocessors: { - 'test/**/*.js': ['babel'], - 'src/**/*.js': ['babel', 'coverage'] - }, - coverageReporter: { - type: 'html', - dir: 'build/reports/coverage' - } - }, done).start(); +gulp.task('coveralls', ['test'], function (done) { + gulp.src('build/reports/coverage/lcov/report-lcovonly.txt') + .pipe(coveralls()); }); diff --git a/karma.conf.js b/karma.conf.js index 70fcbe5..da39d08 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,82 +1,81 @@ -// Karma configuration -// Generated on Fri Dec 05 2014 16:49:29 GMT-0500 (EST) +var isparta = require('isparta'); +var paths = require('./build/paths'); +var babelOptions = require('./build/babel-options'); module.exports = function(config) { - config.set({ - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + var configuration = { frameworks: ['jspm', 'jasmine'], jspm: { - // Edit this to your needs - loadFiles: ['src/**/*.js', 'test/**/*.js'] + config: 'config.js', + loadFiles: [paths.tests], + serveFiles: [paths.source] }, - - // list of files / patterns to load in the browser files: [], - - // list of files to exclude - exclude: [ - ], - - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - 'test/**/*.js': ['babel'], - 'src/**/*.js': ['babel'] + [paths.tests]: ['babel'], + [paths.source]: ['babel', 'sourcemap', 'coverage'] }, - 'babelPreprocessor': { + + babelPreprocessor: { options: { - sourceMap: 'inline', - modules: 'system', - moduleIds: false, - loose: "all", - optional: [ - "es7.decorators", - "es7.classProperties" - ] + loose: babelOptions.loose, + stage: babelOptions.stage, + optional: babelOptions.optional, + sourceMap: 'inline' } }, + reporters: ['coverage', 'progress'], + + coverageReporter: { + instrumenters: { + isparta: isparta + }, + + instrumenter: { + [paths.source]: 'isparta' + }, + + dir: 'build/reports/coverage/', + + reporters: [{ + type: 'text-summary' + }, { + type: 'html', + subdir: 'html' + }, { + type: 'lcovonly', + subdir: 'lcov', + file: 'report-lcovonly.txt' + }] + }, - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress'], - - - // web server port port: 9876, - - // enable / disable colors in the output (reporters and logs) colors: true, - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, - - // enable / disable watching file and executing tests whenever any file changes autoWatch: true, + customLaunchers: { + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ['Chrome'], - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits singleRun: false - }); + }; + + if (process.env.TRAVIS) { + configuration.browsers = ['Chrome_travis_ci', 'Firefox']; + } + + config.set(configuration); }; diff --git a/package.json b/package.json index 34e1b09..d13d659 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,10 @@ "type": "git", "url": "http://github.com/aurelia/history-browser" }, + "scripts": { + "test": "gulp test", + "ci": "gulp ci" + }, "jspmNodeConversion": false, "jspm": { "main": "aurelia-history-browser", @@ -42,7 +46,7 @@ "core-js": "^1.2.6" }, "devDependencies": { - "aurelia-tools": "^0.1.12", + "aurelia-tools": "0.1.16", "babel-dts-generator": "^0.2.17", "babel-eslint": "^4.1.1", "conventional-changelog": "0.0.11", @@ -51,18 +55,24 @@ "gulp-babel": "^5.2.1", "gulp-bump": "^0.3.1", "gulp-concat": "^2.6.0", + "gulp-coveralls": "0.1.4", "gulp-eslint": "^1.0.0", "gulp-insert": "^0.5.0", "gulp-rename": "^1.2.2", "gulp-typedoc": "^1.2.1", "gulp-typedoc-extractor": "^0.0.8", + "isparta": "4.0.0", + "istanbul": "github:gotwarlost/istanbul#source-map", "jasmine-core": "^2.1.3", - "karma": "^0.13.15", + "jspm": "0.16.18", + "karma": "0.13.15", "karma-babel-preprocessor": "^5.2.2", - "karma-chrome-launcher": "^0.1.7", - "karma-coverage": "^0.3.1", + "karma-chrome-launcher": "0.1.12", + "karma-coverage": "github:douglasduteil/karma-coverage#next", + "karma-firefox-launcher": "0.1.7", "karma-jasmine": "^0.3.5", "karma-jspm": "^2.0.1", + "karma-sourcemap-loader": "0.3.6", "object.assign": "^1.0.3", "require-dir": "^0.1.0", "run-sequence": "^1.0.2",