build: run chrome and firefox headless tests in circleci (#13603)

This commit is contained in:
Paul Gschwendtner
2018-10-16 18:35:37 +02:00
committed by Joey Perrott
parent 3f98306429
commit 8e324c8e21
5 changed files with 78 additions and 50 deletions
+41 -44
View File
@@ -2,67 +2,64 @@
/*
* Browser Configuration for the different jobs in the CI.
* Target can be either: BS (Browserstack) | SL (Saucelabs) | TC (Travis CI) | null (To not run)
*
* - local: Launches the browser locally on the current operating system.
* - BS: Launches the browser within BrowserStack
* - SL: Launches the browser within Saucelabs
*
* TODO(devversion): rename this to "browserstack" and "saucelabs".
*/
const browserConfig = {
'ChromeHeadlessCI': { unitTest: {target: 'TC', required: true }},
'FirefoxHeadless': { unitTest: {target: 'TC', required: true }},
'ChromeBeta': { unitTest: {target: null, required: false }},
'FirefoxBeta': { unitTest: {target: null, required: false }},
'ChromeDev': { unitTest: {target: null, required: false }},
'FirefoxDev': { unitTest: {target: null, required: false }},
'IE9': { unitTest: {target: null, required: false }},
'IE10': { unitTest: {target: null, required: false }},
'IE11': { unitTest: {target: null, required: false }},
'Edge': { unitTest: {target: 'BS', required: true }},
'Android4.1': { unitTest: {target: null, required: false }},
'Android4.2': { unitTest: {target: null, required: false }},
'Android4.3': { unitTest: {target: null, required: false }},
'Android4.4': { unitTest: {target: null, required: false }},
'Android5': { unitTest: {target: null, required: false }},
'Safari7': { unitTest: {target: null, required: false }},
'Safari8': { unitTest: {target: null, required: false }},
'Safari9': { unitTest: {target: null, required: false }},
'Safari10': { unitTest: {target: 'BS', required: true }},
'iOS7': { unitTest: {target: null, required: false }},
'iOS8': { unitTest: {target: null, required: false }},
'iOS9': { unitTest: {target: null, required: false }},
'iOS10': { unitTest: {target: null, required: false }},
'ChromeHeadlessCI': { unitTest: {target: 'local', }},
'FirefoxHeadless': { unitTest: {target: 'local', }},
'ChromeBeta': { unitTest: {target: null, }},
'FirefoxBeta': { unitTest: {target: null, }},
'ChromeDev': { unitTest: {target: null, }},
'FirefoxDev': { unitTest: {target: null, }},
'IE9': { unitTest: {target: null, }},
'IE10': { unitTest: {target: null, }},
'IE11': { unitTest: {target: null, }},
'Edge': { unitTest: {target: 'BS', }},
'Android4.1': { unitTest: {target: null, }},
'Android4.2': { unitTest: {target: null, }},
'Android4.3': { unitTest: {target: null, }},
'Android4.4': { unitTest: {target: null, }},
'Android5': { unitTest: {target: null, }},
'Safari7': { unitTest: {target: null, }},
'Safari8': { unitTest: {target: null, }},
'Safari9': { unitTest: {target: null, }},
'Safari10': { unitTest: {target: 'BS', }},
'iOS7': { unitTest: {target: null, }},
'iOS8': { unitTest: {target: null, }},
'iOS9': { unitTest: {target: null, }},
'iOS10': { unitTest: {target: null, }},
// Don't use Browserstack until our open-source license includes automate testing on
// mobile devices. For now, we need to use Saucelabs to keep our coverage.
'iOS11': { unitTest: {target: 'SL', required: true }},
'WindowsPhone': { unitTest: {target: null, required: false }}
'iOS11': { unitTest: {target: 'SL', }},
'WindowsPhone': { unitTest: {target: null, }}
};
/** Exports all available remote browsers. */
exports.customLaunchers = require('./remote_browsers.json');
/** Exports a map of configured browsers, which should run on the CI. */
/** Exports a map of configured browsers, which should run in the given platform. */
exports.platformMap = {
'saucelabs': {
required: buildConfiguration('unitTest', 'SL', true),
optional: buildConfiguration('unitTest', 'SL', false)
},
'browserstack': {
required: buildConfiguration('unitTest', 'BS', true),
optional: buildConfiguration('unitTest', 'BS', false)
},
'travis': {
required: buildConfiguration('unitTest', 'TC', true),
optional: buildConfiguration('unitTest', 'TC', false)
}
'saucelabs': buildConfiguration('unitTest', 'SL'),
'browserstack': buildConfiguration('unitTest', 'BS'),
'local': buildConfiguration('unitTest', 'local'),
};
/** Build a list of configuration (custom launcher names). */
function buildConfiguration(type, target, required) {
function buildConfiguration(type, target) {
const targetBrowsers = Object.keys(browserConfig)
.map(browserName => [browserName, browserConfig[browserName][type]])
.filter(([, config]) => config.required === required && config.target === target)
.filter(([, config]) => config.target === target)
.map(([browserName]) => browserName);
// For browsers that run on Travis CI the browser name shouldn't be prefixed with the shortcut
// of Travis. The different Karma launchers only work with the plain browser name (e.g Firefox)
if (target === 'TC') {
// For browsers that run locally, the browser name shouldn't be prefixed with the target
// platform. We only prefix the external platforms in order to distinguish between
// local and remote browsers in our "customLaunchers" for Karma.
if (target === 'local') {
return targetBrowsers;
}
+7 -2
View File
@@ -100,6 +100,10 @@ module.exports = (config) => {
},
});
if (process.env['CIRCLECI']) {
config.browsers = platformMap[process.env['TEST_PLATFORM']];
}
if (process.env['TRAVIS']) {
const buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`;
@@ -114,7 +118,8 @@ module.exports = (config) => {
// It will look like <platform>_<target>, where platform is one of 'saucelabs', 'browserstack'
// or 'travis'. The target is a reference to different collections of browsers that can run
// in the previously specified platform.
const [platform, target] = process.env.MODE.split('_');
// TODO(devversion): when moving Saucelabs and Browserstack to Circle, remove the target part.
const [platform] = process.env.MODE.split('_');
if (platform === 'saucelabs') {
config.sauceLabs.build = buildId;
@@ -132,6 +137,6 @@ module.exports = (config) => {
config.concurrency = 1;
}
config.browsers = platformMap[platform][target.toLowerCase()];
config.browsers = platformMap[platform];
}
};