From 5bb3277edd902023d57366bac115676fbad96948 Mon Sep 17 00:00:00 2001 From: Markus Tacker Date: Tue, 17 Jan 2017 16:10:59 +0200 Subject: [PATCH] chore(Saucelabs): test on IE9, IE10 and IE11. Fixes #2344. This moves the selection of the browsers to test to the travis build script. The number of concurrent travis jobs should be limited to 5 (Saucelabs limit). This also removes the S3 env variable which does nothing This uses a fork of karma-sauce-launcher, which contains upated dependencies, in order to support retries: https://github.com/karma-runner/karma-sauce-launcher/pull/114 --- .travis.yml | 34 ++++++++++++++++++- karma.conf.js | 93 ++++++++++++++++++++++----------------------------- package.json | 2 +- 3 files changed, 74 insertions(+), 55 deletions(-) diff --git a/.travis.yml b/.travis.yml index 553966a6fb..3f03be785a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,11 +33,43 @@ matrix: env: TARGET=test-node - node_js: '7' env: TARGET=lint + # phantomjs - node_js: '7' - env: TARGET=test-browser S3=1 + env: TARGET=test-browser + # chrome + - node_js: '7' + env: TARGET=test-browser BROWSER="chrome@latest" PLATFORM="Windows 8" + # edge + - node_js: '7' + env: TARGET=test-browser BROWSER="MicrosoftEdge@latest" PLATFORM="Windows 10" + # ie11 + - node_js: '7' + env: TARGET=test-browser BROWSER="internet explorer@11.0" PLATFORM="Windows 8.1" + # ie10 + - node_js: '7' + env: TARGET=test-browser BROWSER="internet explorer@10.0" PLATFORM="Windows 8" + # ie9 + - node_js: '7' + env: TARGET=test-browser BROWSER="internet explorer@9.0" PLATFORM="Windows 7" + # ie8 + - node_js: '7' + env: TARGET=test-browser BROWSER="internet explorer@8.0" PLATFORM="Windows 7" + # ie7 + - node_js: '7' + env: TARGET=test-browser BROWSER="internet explorer@7.0" PLATFORM="Windows XP" + # firefox + - node_js: '7' + env: TARGET=test-browser BROWSER="firefox@latest" PLATFORM="Windows 8.1" + # safari + - node_js: '7' + env: TARGET=test-browser BROWSER="safari@latest" PLATFORM="OS X 10.11" before_install: scripts/travis-before-install.sh +install: + - npm install + - cd node_modules && ln -nsf @coderbyheart/karma-sauce-launcher karma-sauce-launcher && cd ../ + before_script: scripts/travis-before-script.sh script: make $TARGET diff --git a/karma.conf.js b/karma.conf.js index 429cd2dfe7..fa4996317a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -48,7 +48,7 @@ module.exports = function (config) { }, reporters: ['spec'], colors: true, - browsers: [osName() === 'macOS Sierra' ? 'Chrome' : 'PhantomJS'], + browsers: [osName() === 'macOS Sierra' ? 'Chrome' : 'PhantomJS'], // This is the default browser to run, locally logLevel: config.LOG_INFO, client: { mocha: { @@ -58,8 +58,17 @@ module.exports = function (config) { }; // see https://github.com/saucelabs/karma-sauce-example + + // We define the browser to run on the Saucelabs Infrastructure + // via the environment variables BROWSER and PLATFORM. + // PLATFORM is e.g. "Windows" + // BROWSER is expected to be in the format "@", + // e.g. "MicrosoftEdge@latest" + // See https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/ + // for available browsers. + // TO RUN LOCALLY, execute: - // `CI=1 SAUCE_USERNAME= SAUCE_ACCESS_KEY= make test-browser` + // `CI=1 SAUCE_USERNAME= SAUCE_ACCESS_KEY= BROWSER= PLATFORM= make test-browser` var env = process.env; var sauceConfig; @@ -68,16 +77,18 @@ module.exports = function (config) { if (env.TRAVIS) { console.error('Travis-CI detected'); bundleDirpath = path.join(baseBundleDirpath, process.env.TRAVIS_BUILD_ID); - if (env.SAUCE_USERNAME && env.SAUCE_ACCESS_KEY) { - // correlate build/tunnel with Travis - sauceConfig = { - build: 'TRAVIS #' + env.TRAVIS_BUILD_NUMBER + - ' (' + env.TRAVIS_BUILD_ID + ')', - tunnelIdentifier: env.TRAVIS_JOB_NUMBER - }; - console.error('Configured SauceLabs'); - } else { - console.error('No SauceLabs credentials present'); + if (env.BROWSER && env.PLATFORM) { + if (env.SAUCE_USERNAME && env.SAUCE_ACCESS_KEY) { + // correlate build/tunnel with Travis + sauceConfig = { + build: 'TRAVIS #' + env.TRAVIS_BUILD_NUMBER + + ' (' + env.TRAVIS_BUILD_ID + ')', + tunnelIdentifier: env.TRAVIS_JOB_NUMBER + }; + console.error('Configured SauceLabs'); + } else { + console.error('No SauceLabs credentials present'); + } } } else if (env.APPVEYOR) { console.error('AppVeyor detected'); @@ -126,56 +137,32 @@ module.exports = function (config) { }; function addSauceTests (cfg) { + var env = process.env; cfg.reporters.push('saucelabs'); - - cfg.customLaunchers = { - ie8: { - base: 'SauceLabs', - browserName: 'internet explorer', - platform: 'Windows 7', - version: '8.0' - }, - ie7: { - base: 'SauceLabs', - browserName: 'internet explorer', - platform: 'Windows XP', - version: '7.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.customLaunchers = {}; + cfg.customLaunchers[env.BROWSER] = { + base: 'SauceLabs', + browserName: env.BROWSER.split('@')[0], + version: env.BROWSER.split('@')[1], + platform: env.PLATFORM }; + cfg.browsers = [env.BROWSER]; - cfg.browsers = cfg.browsers.concat(Object.keys(cfg.customLaunchers)); - + // See https://github.com/karma-runner/karma-sauce-launcher + // See https://github.com/bermi/sauce-connect-launcher#advanced-usage cfg.sauceLabs = { public: 'public', - startConnect: true + startConnect: true, + connectOptions: { + connectRetries: 10, + connectRetryTimeout: 60000 + } }; cfg.concurrency = 5; + cfg.retryLimit = 5; + // for slow browser booting, ostensibly cfg.captureTimeout = 120000; cfg.browserNoActivityTimeout = 20000; diff --git a/package.json b/package.json index 0ca52f8b7c..6919173a8d 100644 --- a/package.json +++ b/package.json @@ -336,7 +336,7 @@ "karma-expect": "^1.1.2", "karma-mocha": "^1.3.0", "karma-phantomjs-launcher": "^1.0.2", - "karma-sauce-launcher": "^1.0.0", + "karma-sauce-launcher": "coderbyheart/karma-sauce-launcher", "karma-spec-reporter": "0.0.26", "nyc": "^10.0.0", "os-name": "^2.0.1",