diff options
| author | Vojta Jina | 2013-07-01 16:21:56 -0700 | 
|---|---|---|
| committer | Vojta Jina | 2013-07-02 15:12:03 -0700 | 
| commit | 52519d45b94d43c6dcd60d0845b1914edf5c743c (patch) | |
| tree | 38a8cc922407f2e51660867c4ad9d3d2ed10b489 | |
| parent | 78728df09907e7f63a50fe5ecbb2673a74556a5b (diff) | |
| download | angular.js-52519d45b94d43c6dcd60d0845b1914edf5c743c.tar.bz2 | |
chore(travis): speed up the build
- parallelize the tasks
- cache requests (e2e tests)
This reduces the time from ~18min to ~12min.
It makes the output little messy. We could buffer output of each task and display it once it's fully finished, nicely. I think giving instant feedback is better.
| -rw-r--r-- | .travis.yml | 3 | ||||
| -rw-r--r-- | Gruntfile.js | 34 | ||||
| -rw-r--r-- | karma-shared.conf.js | 1 | ||||
| -rw-r--r-- | lib/grunt/utils.js | 25 | ||||
| -rw-r--r-- | package.json | 1 | 
5 files changed, 59 insertions, 5 deletions
| diff --git a/.travis.yml b/.travis.yml index 92da3ed9..3b439f7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,7 @@ before_script:    - ./lib/sauce/sauce_connect_setup.sh    - npm install -g grunt-cli    - grunt package -  - grunt webserver > /dev/null &    - ./lib/sauce/sauce_connect_block.sh  script: -  - grunt test --reporters dots --browsers SL_Chrome +  - grunt parallel:travis --reporters dots --browsers SL_Chrome diff --git a/Gruntfile.js b/Gruntfile.js index 2cbfcda3..9a470d3d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,6 +7,7 @@ module.exports = function(grunt) {    grunt.loadNpmTasks('grunt-contrib-copy');    grunt.loadNpmTasks('grunt-contrib-connect');    grunt.loadNpmTasks('grunt-contrib-compress'); +  grunt.loadNpmTasks('grunt-parallel');    grunt.loadTasks('lib/grunt');    var NG_VERSION = util.getVersion(); @@ -21,6 +22,20 @@ module.exports = function(grunt) {    grunt.initConfig({      NG_VERSION: NG_VERSION, +    parallel: { +      travis: { +        options: { +          stream: true, +        }, +        tasks: [ +          util.parallelTask('test:modules'), +          util.parallelTask('test:jquery'), +          util.parallelTask('test:jqlite'), +          util.parallelTask('test:e2e') +        ] +      } +    }, +      connect: {        devserver: {          options: { @@ -40,7 +55,24 @@ module.exports = function(grunt) {            }          }        }, -      testserver: {} +      testserver: { +        options: { +          middleware: function(connect, options){ +            return [ +              function(req, resp, next) { +                // cache get requests to speed up tests on travis +                if (req.method === 'GET') { +                  resp.setHeader('Cache-control', 'public, max-age=3600'); +                } + +                next(); +              }, +              connect.favicon('images/favicon.ico'), +              connect.static(options.base) +            ]; +          } +        } +      }      }, diff --git a/karma-shared.conf.js b/karma-shared.conf.js index 3157d50f..81476708 100644 --- a/karma-shared.conf.js +++ b/karma-shared.conf.js @@ -5,6 +5,7 @@ module.exports = function(config) {      logLevel: config.LOG_INFO,      logColors: true,      browsers: ['Chrome'], +    runnerPort: 0,      // config for Travis CI      sauceLabs: { diff --git a/lib/grunt/utils.js b/lib/grunt/utils.js index 0ba03da2..f0fffb14 100644 --- a/lib/grunt/utils.js +++ b/lib/grunt/utils.js @@ -33,11 +33,13 @@ module.exports = {      var browsers = grunt.option('browsers');      var reporters = grunt.option('reporters');      var noColor = grunt.option('no-colors'); +    var port = grunt.option('port');      var p = spawn('node', ['node_modules/karma/bin/karma', 'start', config,        singleRun ? '--single-run=true' : '',        reporters ? '--reporters=' + reporters : '',        browsers ? '--browsers=' + browsers : '', -      noColor ? '--no-colors' : '' +      noColor ? '--no-colors' : '', +      port ? '--port=' + port : ''      ]);      p.stdout.pipe(process.stdout);      p.stderr.pipe(process.stderr); @@ -170,5 +172,24 @@ module.exports = {        }        next();      }; -  } +  }, + +  parallelTask: function(name) { +    var args = [name, '--port=' + this.lastParallelTaskPort]; + +    if (grunt.option('browsers')) { +      args.push('--browsers=' + grunt.option('browsers')); +    } + +    if (grunt.option('reporters')) { +      args.push('--reporters=' + grunt.option('reporters')); +    } + +    this.lastParallelTaskPort++; + + +    return {grunt: true, args: args}; +  }, + +  lastParallelTaskPort: 9876  }; diff --git a/package.json b/package.json index 01e00e93..4cc95603 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@      "grunt-contrib-compress": "0.4.1",      "grunt-contrib-connect": "0.1.2",      "grunt-contrib-copy": "0.4.1", +    "grunt-parallel": "~0.2.0",      "jasmine-node": "1.2.3",      "q": "~0.9.2",      "q-fs": "0.1.36", | 
