From b2a426eaa28b4668a07161d8ea801d8308575839 Mon Sep 17 00:00:00 2001 From: Hyzual Date: Mon, 17 Nov 2014 22:04:49 +0100 Subject: [PATCH 1/8] Adds karma-coverage to generate test coverage reports using Istanbul. Test coverage files are in the /coverage folder. They indicate us for each js file which lines we ran and which we didn't run during unit tests. This helps us know what to test next. Conflicts: package.json --- .gitignore | 1 + Gruntfile.js | 3 ++- karma.conf.js | 7 ++++++- package.json | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c4a7a0b..7d495b8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ bower_components node_modules /.tmp /.ssh +/coverage diff --git a/Gruntfile.js b/Gruntfile.js index 2f8da5a..96ae763 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -115,7 +115,8 @@ module.exports = function (grunt) { }, unit: { singleRun: true, - browsers: ['Chrome'] + browsers: ['Chrome'], + reporters: ['progress', 'coverage'] }, continuous: { singleRun: false, diff --git a/karma.conf.js b/karma.conf.js index 8ca8d80..55d36ac 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -42,6 +42,10 @@ module.exports = function(config) { // list of files / patterns to exclude exclude: ['app/vendor/**/*.js'], + preprocessors: { + 'app/**/!(*_test).js': ['coverage'] + }, + // web server port port: 8080, @@ -61,7 +65,8 @@ module.exports = function(config) { plugins: [ 'karma-chrome-launcher', 'karma-phantomjs-launcher', - 'karma-jasmine' + 'karma-jasmine', + 'karma-coverage' ], // Continuous Integration mode diff --git a/package.json b/package.json index 7becdee..e4b0e22 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "jshint-stylish": "^1.0.0", "karma": "^0.12.25", "karma-chrome-launcher": "^0.1.5", + "karma-coverage": "^0.2.6", "karma-jasmine": "^0.3.0", "karma-phantomjs-launcher": "^0.1.4", "load-grunt-tasks": "^1.0.0", From f1bda7eea8339a7d4f8c2d3618cb1811d0dc9746 Mon Sep 17 00:00:00 2001 From: Hyzual Date: Sat, 22 Nov 2014 19:17:06 +0100 Subject: [PATCH 2/8] Adds an editor config file It is used to keep contributors' editors config in sync, so we all use 4 spaces indent. --- .editorconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8a80734 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] + +# Change these settings to your own preference +indent_style = space +indent_size = 4 + +# We recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false From ce53362fbb81070390df1014f67e0bf5a6c9ef06 Mon Sep 17 00:00:00 2001 From: Hyzual Date: Tue, 25 Nov 2014 16:42:48 +0100 Subject: [PATCH 3/8] Adds the Growl reporter for karma. Removes the sellout package, it can always be installed globally and is not needed. --- Gruntfile.js | 5 +++-- karma.conf.js | 5 +++-- package.json | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 96ae763..da07187 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -116,12 +116,13 @@ module.exports = function (grunt) { unit: { singleRun: true, browsers: ['Chrome'], - reporters: ['progress', 'coverage'] + reporters: ['growl', 'coverage'] }, continuous: { singleRun: false, background: true, - browsers: ['PhantomJS'] + browsers: ['PhantomJS'], + reporters: ['progress', 'growl'] } }, diff --git a/karma.conf.js b/karma.conf.js index 55d36ac..4e058f4 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -58,7 +58,7 @@ module.exports = function(config) { // - PhantomJS // - IE (only Windows) browsers: [ - 'Chrome' + 'PhantomJS' ], // Which plugins to enable @@ -66,7 +66,8 @@ module.exports = function(config) { 'karma-chrome-launcher', 'karma-phantomjs-launcher', 'karma-jasmine', - 'karma-coverage' + 'karma-coverage', + 'karma-growl-reporter' ], // Continuous Integration mode diff --git a/package.json b/package.json index e4b0e22..4cd3ade 100644 --- a/package.json +++ b/package.json @@ -49,10 +49,10 @@ "karma": "^0.12.25", "karma-chrome-launcher": "^0.1.5", "karma-coverage": "^0.2.6", + "karma-growl-reporter": "^0.1.1", "karma-jasmine": "^0.3.0", "karma-phantomjs-launcher": "^0.1.4", "load-grunt-tasks": "^1.0.0", - "sellout": "0.0.1", "time-grunt": "^1.0.0" }, "engines": { From 4e8979c8e0718b5fdbd9048527247088720e29cc Mon Sep 17 00:00:00 2001 From: Hyzual Date: Sun, 30 Nov 2014 19:25:34 +0100 Subject: [PATCH 4/8] Adds grunt-notify. Adds 'coverage' task to open the coverage dir in the browser. --- Gruntfile.js | 50 ++++++++++++++++++++++++++++++++++++-------------- package.json | 1 + 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index da07187..a69a24b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -86,18 +86,26 @@ module.exports = function (grunt) { } }, test: { - options: { - port: 9001, - middleware: function (connect) { - return [ - connect().use( - '/bower_components', - connect.static('./bower_components') - ), - connect.static(appConfig.app) - ]; + options: { + port: 9001, + middleware: function (connect) { + return [ + connect().use( + '/bower_components', + connect.static('./bower_components') + ), + connect.static(appConfig.app) + ]; + } + } + }, + coverage: { + options: { + open: true, + port: 9003, + keepalive: true, + base: './coverage/' } - } }, dist: { options: { @@ -121,7 +129,7 @@ module.exports = function (grunt) { continuous: { singleRun: false, background: true, - browsers: ['PhantomJS'], + browsers: ['Chrome'], reporters: ['progress', 'growl'] } }, @@ -348,8 +356,16 @@ module.exports = function (grunt) { createDirectories: true } } - } + }, + // Display notfifications when builds complete using Growl + notify: { + deploy: { + options: { + message: 'Jamstash deployed to test server' + } + } + } }); grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { @@ -370,6 +386,11 @@ module.exports = function (grunt) { 'jshint' ]); + grunt.registerTask('coverage', [ + 'karma:unit', + 'connect:coverage' + ]); + grunt.registerTask('build', [ 'clean:dist', 'wiredep:app', @@ -389,7 +410,8 @@ module.exports = function (grunt) { return grunt.task.run([ 'build', 'sshexec:cleanTest', - 'sftp:test' + 'sftp:test', + 'notify:deploy' ]); }); diff --git a/package.json b/package.json index 4cd3ade..51bac84 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "grunt-filerev": "^2.1.1", "grunt-karma": "^0.9.0", "grunt-ng-annotate": "^0.5.0", + "grunt-notify": "^0.4.1", "grunt-ssh": "^0.12.0", "grunt-usemin": "^2.6.0", "grunt-wiredep": "^1.9.0", From a8053384e9271f6c2abec78b4ad7e0d51119d329 Mon Sep 17 00:00:00 2001 From: Hyzual Date: Tue, 2 Dec 2014 22:53:38 +0100 Subject: [PATCH 5/8] Shorten grunt builds by moving 'load-grunt-tasks' inside each grunt registered task. That way we avoid loading imagemin everytime on watch, which was the longest (almost 30sec). We only have to load 'grunt-karma' everytime, but now testing is lightning fast ! --- Gruntfile.js | 70 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a69a24b..34d3f3a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,8 +9,7 @@ module.exports = function (grunt) { - // Load grunt tasks automatically - require('load-grunt-tasks')(grunt); + grunt.loadNpmTasks('grunt-karma'); // Time how long tasks take. Can help when optimizing build times require('time-grunt')(grunt); @@ -368,7 +367,10 @@ module.exports = function (grunt) { } }); - grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { + grunt.registerTask('serve', 'Compile then start a connect web server', function(target) { + // Load grunt tasks automatically + require('load-grunt-tasks')(grunt); + if (target === 'dist') { return grunt.task.run(['build', 'connect:dist:keepalive']); } @@ -381,32 +383,50 @@ module.exports = function (grunt) { ]); }); - grunt.registerTask('test', [ - 'karma:unit', - 'jshint' - ]); + grunt.registerTask('test', 'Run unit tests and jshint', function() { + // Load grunt tasks automatically + require('load-grunt-tasks')(grunt); - grunt.registerTask('coverage', [ - 'karma:unit', - 'connect:coverage' - ]); + return grunt.task.run([ + 'karma:unit', + 'jshint' + ]); + }); - grunt.registerTask('build', [ - 'clean:dist', - 'wiredep:app', - 'useminPrepare', - 'concat:generated', - 'copy:dist', - 'imagemin', - //'ngAnnotate', - 'cssmin', - 'uglify:generated', - 'filerev', - 'usemin', - 'htmlmin' - ]); + grunt.registerTask('coverage', 'Run unit tests and display test coverage results on browser', function() { + // Load grunt tasks automatically + require('load-grunt-tasks')(grunt); + + return grunt.task.run([ + 'karma:unit', + 'connect:coverage' + ]); + }); + + grunt.registerTask('build', 'Concatenate all JS files, minify all JS, CSS, HTML and image files and version all static assets', function() { + // Load grunt tasks automatically + require('load-grunt-tasks')(grunt); + + return grunt.task.run([ + 'clean:dist', + 'wiredep:app', + 'useminPrepare', + 'concat:generated', + 'copy:dist', + 'imagemin', + //'ngAnnotate', + 'cssmin', + 'uglify:generated', + 'filerev', + 'usemin', + 'htmlmin' + ]); + }); grunt.registerTask('deploy', 'Build and deploy to test server', function() { + // Load grunt tasks automatically + require('load-grunt-tasks')(grunt); + return grunt.task.run([ 'build', 'sshexec:cleanTest', From 96cc13b8a925846da93ce8346a90aefbf88931b9 Mon Sep 17 00:00:00 2001 From: Hyzual Date: Tue, 2 Dec 2014 23:03:20 +0100 Subject: [PATCH 6/8] Replaces (load-grunt-task' by 'jit-grunt'. Only the needed tasks are loaded, so that watch is not slowed down by imagemin. --- Gruntfile.js | 18 ++---------------- package.json | 2 +- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 34d3f3a..cc20ff6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,7 +9,8 @@ module.exports = function (grunt) { - grunt.loadNpmTasks('grunt-karma'); + // Lazy-load grunt tasks automatically + require('jit-grunt')(grunt); // Time how long tasks take. Can help when optimizing build times require('time-grunt')(grunt); @@ -368,9 +369,6 @@ module.exports = function (grunt) { }); grunt.registerTask('serve', 'Compile then start a connect web server', function(target) { - // Load grunt tasks automatically - require('load-grunt-tasks')(grunt); - if (target === 'dist') { return grunt.task.run(['build', 'connect:dist:keepalive']); } @@ -384,9 +382,6 @@ module.exports = function (grunt) { }); grunt.registerTask('test', 'Run unit tests and jshint', function() { - // Load grunt tasks automatically - require('load-grunt-tasks')(grunt); - return grunt.task.run([ 'karma:unit', 'jshint' @@ -394,9 +389,6 @@ module.exports = function (grunt) { }); grunt.registerTask('coverage', 'Run unit tests and display test coverage results on browser', function() { - // Load grunt tasks automatically - require('load-grunt-tasks')(grunt); - return grunt.task.run([ 'karma:unit', 'connect:coverage' @@ -404,9 +396,6 @@ module.exports = function (grunt) { }); grunt.registerTask('build', 'Concatenate all JS files, minify all JS, CSS, HTML and image files and version all static assets', function() { - // Load grunt tasks automatically - require('load-grunt-tasks')(grunt); - return grunt.task.run([ 'clean:dist', 'wiredep:app', @@ -424,9 +413,6 @@ module.exports = function (grunt) { }); grunt.registerTask('deploy', 'Build and deploy to test server', function() { - // Load grunt tasks automatically - require('load-grunt-tasks')(grunt); - return grunt.task.run([ 'build', 'sshexec:cleanTest', diff --git a/package.json b/package.json index 51bac84..2bf97cb 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "grunt-ssh": "^0.12.0", "grunt-usemin": "^2.6.0", "grunt-wiredep": "^1.9.0", + "jit-grunt": "^0.9.0", "jshint-stylish": "^1.0.0", "karma": "^0.12.25", "karma-chrome-launcher": "^0.1.5", @@ -53,7 +54,6 @@ "karma-growl-reporter": "^0.1.1", "karma-jasmine": "^0.3.0", "karma-phantomjs-launcher": "^0.1.4", - "load-grunt-tasks": "^1.0.0", "time-grunt": "^1.0.0" }, "engines": { From e73d23bbaac7f36b40915d867f0437b9f4a47968 Mon Sep 17 00:00:00 2001 From: Hyzual Date: Sun, 11 Jan 2015 22:54:09 +0100 Subject: [PATCH 7/8] Fixes the build with jit-grunt Adds aliases to plugin that have different task names relative to the plugin name --- Gruntfile.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index cc20ff6..ddb309c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,7 +10,11 @@ module.exports = function (grunt) { // Lazy-load grunt tasks automatically - require('jit-grunt')(grunt); + require('jit-grunt')(grunt, { + useminPrepare: 'grunt-usemin', + sshexec: 'grunt-ssh', + sftp: 'grunt-ssh' + }); // Time how long tasks take. Can help when optimizing build times require('time-grunt')(grunt); From bf5f01d825bad206e803770464d35cf36e246318 Mon Sep 17 00:00:00 2001 From: Hyzual Date: Sat, 17 Jan 2015 10:49:00 +0100 Subject: [PATCH 8/8] Replaces karma-growl-reporter by karma-notify-reporter notify can use the native Windows 8, OS X and Linux notifications, and also supports Growl as a fallback. --- Gruntfile.js | 4 ++-- karma.conf.js | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index ddb309c..c2f8839 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -128,13 +128,13 @@ module.exports = function (grunt) { unit: { singleRun: true, browsers: ['Chrome'], - reporters: ['growl', 'coverage'] + reporters: ['notify', 'coverage'] }, continuous: { singleRun: false, background: true, browsers: ['Chrome'], - reporters: ['progress', 'growl'] + reporters: ['progress', 'notify'] } }, diff --git a/karma.conf.js b/karma.conf.js index 4e058f4..85c3f11 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -67,7 +67,7 @@ module.exports = function(config) { 'karma-phantomjs-launcher', 'karma-jasmine', 'karma-coverage', - 'karma-growl-reporter' + 'karma-notify-reporter' ], // Continuous Integration mode diff --git a/package.json b/package.json index 2bf97cb..98e7dd6 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "karma": "^0.12.25", "karma-chrome-launcher": "^0.1.5", "karma-coverage": "^0.2.6", - "karma-growl-reporter": "^0.1.1", "karma-jasmine": "^0.3.0", + "karma-notify-reporter": "^0.1.1", "karma-phantomjs-launcher": "^0.1.4", "time-grunt": "^1.0.0" },