From 9e8cbaa348dfc0812e19d247dfb364e51a4f7867 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Sun, 22 May 2016 23:28:25 -0700 Subject: [PATCH] try different strategy for avoiding insecure sauce connect --- .travis.yml | 6 --- karma.conf.js | 105 ++++++++++++++++++++++++++------------------------ 2 files changed, 55 insertions(+), 56 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9101c6ea02..2aee750bb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,12 +34,6 @@ before_install: script: travis_retry make $TARGET -addons: - sauce_connect: - username: mochajs - access_key: - secure: R0HXKtR6F2iDEnItv57BTRyL64XfyIlyyluPLK8G33O/InaQjT3KxGuxevz3nVYIqqnI1MPjYodXcQaqrBOLUVmA2vhBeMHB2OwGc9GAL+HBtB1fh+bQJelkl/XMcTTbC5LIZ6nZjmFnkmjqT3AmUhdDRISgieIFeVY4x48LfiU= - notifications: urls: # for gitter diff --git a/karma.conf.js b/karma.conf.js index 406c5b7ca2..3a001e3e97 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,5 +1,50 @@ 'use strict'; +function addSauceTests(cfg) { + cfg.reporters.push('saucelabs'); + cfg.customLaunchers = { + ie8: { + base: 'SauceLabs', + browserName: 'internet explorer', + platform: 'Windows 7', + version: '8.0' + }, + chrome: { + base: 'SauceLabs', + browserName: 'chrome', + platform: 'Windows 8', + version: 'latest' + }, + edge: { + base: 'SauceLabs', + browserName: 'MicrosoftEdge', + platform: 'Windows 10', + version: 'latest' + }, + firefox: { + base: 'SauceLabs', + browserName: 'firefox', + platform: 'Windows 8.1', + version: 'latest' + }, + safari: { + base: 'SauceLabs', + browserName: 'safari', + platform: 'OS X 10.11', + version: 'latest' + } + }; + + cfg.browsers = cfg.browsers.concat(Object.keys(cfg.customLaunchers)); + + cfg.sauceLabs = { + public: 'public' + }; + + // for slow browser booting, ostensibly + cfg.captureTimeout = 120000; +} + module.exports = function(config) { var cfg = { frameworks: [ @@ -41,68 +86,28 @@ module.exports = function(config) { // TO RUN LOCALLY: // Execute `CI=1 make test-browser`, once you've set the SAUCE_USERNAME and // SAUCE_ACCESS_KEY env vars. - // also, we can't run SauceLabs tests on PRs from forks. if (process.env.CI) { - if (!(process.env.SAUCE_USERNAME || process.env.SAUCE_ACCESS_KEY)) { - throw new Error('Must set SAUCE_USERNAME and SAUCE_ACCESS_KEY ' - + 'environment variables!'); - } - cfg.reporters.push('saucelabs'); - cfg.customLaunchers = { - ie8: { - base: 'SauceLabs', - browserName: 'internet explorer', - platform: 'Windows 7', - version: '8.0' - }, - chrome: { - base: 'SauceLabs', - browserName: 'chrome', - platform: 'Windows 8', - version: 'latest' - }, - edge: { - base: 'SauceLabs', - browserName: 'MicrosoftEdge', - platform: 'Windows 10', - version: 'latest' - }, - firefox: { - base: 'SauceLabs', - browserName: 'firefox', - platform: 'Windows 8.1', - version: 'latest' - }, - safari: { - base: 'SauceLabs', - browserName: 'safari', - platform: 'OS X 10.11', - version: 'latest' - } - }; - - cfg.browsers = cfg.browsers.concat(Object.keys(cfg.customLaunchers)); - - cfg.sauceLabs = { - public: 'public' - }; - + // we can't run SauceLabs tests on PRs from forks on Travis cuz security. if (process.env.TRAVIS) { if (process.env.TRAVIS_REPO_SLUG === 'mochajs/mocha' && process.env.TRAVIS_PULL_REQUEST === 'false') { + addSauceTests(cfg); // correlate build/tunnel with Travis cfg.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; cfg.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; - cfg.sauceLabs.startConnect = false; + cfg.sauceLabs.startConnect = true; } } else { - // otherwise just make something up + if (!(process.env.SAUCE_USERNAME || process.env.SAUCE_ACCESS_KEY)) { + throw new Error('Must set SAUCE_USERNAME and SAUCE_ACCESS_KEY ' + + 'environment variables!'); + } + + // remember, this is for a local run. + addSauceTests(cfg); cfg.sauceLabs.build = require('os').hostname() + ' (' + Date.now() + ')'; } - - // for slow browser booting, ostensibly - cfg.captureTimeout = 120000; } // the MOCHA_UI env var will determine if we're running interface-specific