diff options
| author | Vojta Jina | 2013-12-03 09:58:30 -0800 | 
|---|---|---|
| committer | Vojta Jina | 2013-12-03 15:49:18 -0800 | 
| commit | 84187b6d94179edf04512038f68c14f34a8e6219 (patch) | |
| tree | 4cc7b660649c3421ab8df7ef9ae83298f4bf45cb /lib | |
| parent | 5d6482bb3b1e640a24fea7ffa5bd7667ce02f8ad (diff) | |
| download | angular.js-84187b6d94179edf04512038f68c14f34a8e6219.tar.bz2 | |
chore(travis): use different port numbers per build
We can't establish multiple SSH tunnels for the same port (for BrowserStack).
This makes it possible to run multiple parallel builds using BrowserStack.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/browser-stack/start-tunnel.js | 2 | ||||
| -rw-r--r-- | lib/grunt/utils.js | 22 | 
2 files changed, 21 insertions, 3 deletions
| diff --git a/lib/browser-stack/start-tunnel.js b/lib/browser-stack/start-tunnel.js index f2b475d8..87230b68 100644 --- a/lib/browser-stack/start-tunnel.js +++ b/lib/browser-stack/start-tunnel.js @@ -3,7 +3,7 @@ var http = require('http');  var BrowserStackTunnel = require('browserstacktunnel-wrapper');  var HOSTNAME = 'localhost'; -var PORTS = [9090, 9876]; +var PORTS = require('../grunt/utils').availablePorts;  var ACCESS_KEY = process.env.BROWSER_STACK_ACCESS_KEY;  var READY_FILE = process.env.SAUCE_CONNECT_READY_FILE; diff --git a/lib/grunt/utils.js b/lib/grunt/utils.js index 90613a29..49d346a0 100644 --- a/lib/grunt/utils.js +++ b/lib/grunt/utils.js @@ -5,6 +5,22 @@ var spawn = require('child_process').spawn;  var version;  var CSP_CSS_HEADER = '/* Include this file in your html if you are using the CSP mode. */\n\n'; +var PORT_MIN = 8000; +var PORT_MAX = 9999; +var TRAVIS_BUILD_NUMBER = parseInt(process.env.TRAVIS_BUILD_NUMBER, 10); +var getRandomPorts = function() { +  if (!process.env.TRAVIS) { +    return [9876, 9877]; +  } + +  // Generate two numbers between PORT_MIN and PORT_MAX, based on TRAVIS_BUILD_NUMBER. +  return [ +    PORT_MIN + (TRAVIS_BUILD_NUMBER % (PORT_MAX - PORT_MIN)), +    PORT_MIN + ((TRAVIS_BUILD_NUMBER + 100) % (PORT_MAX - PORT_MIN)) +  ]; +}; + +  module.exports = {    init: function() { @@ -279,7 +295,7 @@ module.exports = {        stream: options && options.stream      }; -    args.push('--port=' + this.sauceLabsAvailablePorts.pop()); +    args.push('--port=' + this.availablePorts.pop());      if (args.indexOf('test:e2e') !== -1 && grunt.option('e2e-browsers')) {        args.push('--browsers=' + grunt.option('e2e-browsers')); @@ -295,5 +311,7 @@ module.exports = {    },    // see http://saucelabs.com/docs/connect#localhost -  sauceLabsAvailablePorts: [9000, 9001, 9080, 9090, 9876] +  sauceLabsAvailablePorts: [9000, 9001, 9080, 9090, 9876], +  // pseudo-random port numbers for BrowserStack +  availablePorts: getRandomPorts()  }; | 
