mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
build: run chrome headless in travis (#5126)
This commit is contained in:
+40
-28
@@ -2,32 +2,32 @@
|
||||
|
||||
/*
|
||||
* Browser Configuration for the different jobs in the CI.
|
||||
* Target can be either: BS (Browserstack) | SL (Saucelabs) | null (To not run at all)
|
||||
* Target can be either: BS (Browserstack) | SL (Saucelabs) | TC (Travis CI) | null (To not run)
|
||||
*/
|
||||
const browserConfig = {
|
||||
'Chrome': { unitTest: {target: 'BS', required: true }},
|
||||
'Firefox': { unitTest: {target: 'BS', required: true }},
|
||||
'ChromeBeta': { unitTest: {target: null, required: false }},
|
||||
'FirefoxBeta': { unitTest: {target: null, required: false }},
|
||||
'ChromeDev': { unitTest: {target: null, required: true }},
|
||||
'FirefoxDev': { unitTest: {target: null, required: true }},
|
||||
'IE9': { unitTest: {target: null, required: false }},
|
||||
'IE10': { unitTest: {target: null, required: true }},
|
||||
'IE11': { unitTest: {target: 'SL', required: true }},
|
||||
'Edge': { unitTest: {target: 'SL', 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: 'SL', required: true }},
|
||||
'Safari10': { unitTest: {target: 'BS', required: true }},
|
||||
'iOS7': { unitTest: {target: null, required: false }},
|
||||
'iOS8': { unitTest: {target: null, required: false }},
|
||||
'iOS9': { unitTest: {target: 'BS', required: true }},
|
||||
'WindowsPhone': { unitTest: {target: null, required: false }}
|
||||
'ChromeHeadless_CI': { unitTest: {target: 'TC', required: true }},
|
||||
'Firefox': { unitTest: {target: 'BS', required: true }},
|
||||
'ChromeBeta': { unitTest: {target: null, required: false }},
|
||||
'FirefoxBeta': { unitTest: {target: null, required: false }},
|
||||
'ChromeDev': { unitTest: {target: null, required: true }},
|
||||
'FirefoxDev': { unitTest: {target: null, required: true }},
|
||||
'IE9': { unitTest: {target: null, required: false }},
|
||||
'IE10': { unitTest: {target: null, required: true }},
|
||||
'IE11': { unitTest: {target: 'SL', required: true }},
|
||||
'Edge': { unitTest: {target: 'SL', 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: 'SL', required: true }},
|
||||
'Safari10': { unitTest: {target: 'BS', required: true }},
|
||||
'iOS7': { unitTest: {target: null, required: false }},
|
||||
'iOS8': { unitTest: {target: null, required: false }},
|
||||
'iOS9': { unitTest: {target: 'BS', required: true }},
|
||||
'WindowsPhone': { unitTest: {target: null, required: false }}
|
||||
};
|
||||
|
||||
/** Exports all available remote browsers. */
|
||||
@@ -43,14 +43,26 @@ exports.platformMap = {
|
||||
required: buildConfiguration('unitTest', 'BS', true),
|
||||
optional: buildConfiguration('unitTest', 'BS', false)
|
||||
},
|
||||
'travis': {
|
||||
required: buildConfiguration('unitTest', 'TC', true),
|
||||
optional: buildConfiguration('unitTest', 'TC', false)
|
||||
}
|
||||
};
|
||||
|
||||
/** Build a list of configuration (custom launcher names). */
|
||||
function buildConfiguration(type, target, required) {
|
||||
return Object.keys(browserConfig)
|
||||
.map(item => [item, browserConfig[item][type]])
|
||||
.filter(([, conf]) => conf.required === required && conf.target === target)
|
||||
.map(([item]) => `${target}_${item.toUpperCase()}`);
|
||||
const targetBrowsers = Object.keys(browserConfig)
|
||||
.map(browserName => [browserName, browserConfig[browserName][type]])
|
||||
.filter(([, config]) => config.required === required && 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') {
|
||||
return targetBrowsers;
|
||||
}
|
||||
|
||||
return targetBrowsers.map(browserName => `${target}_${browserName.toUpperCase()}`);
|
||||
}
|
||||
|
||||
/** Decode the token for Travis to use. */
|
||||
|
||||
+7
-7
@@ -92,7 +92,7 @@ module.exports = (config) => {
|
||||
});
|
||||
|
||||
if (process.env['TRAVIS']) {
|
||||
let buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`;
|
||||
const buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`;
|
||||
|
||||
if (process.env['TRAVIS_PULL_REQUEST'] === 'false' &&
|
||||
process.env['MODE'] === "browserstack_required") {
|
||||
@@ -102,10 +102,10 @@ module.exports = (config) => {
|
||||
}
|
||||
|
||||
// The MODE variable is the indicator of what row in the test matrix we're running.
|
||||
// It will look like <platform>_<alias>, where platform is one of 'saucelabs' or 'browserstack',
|
||||
// and alias is one of the keys in the CI configuration variable declared in
|
||||
// browser-providers.ts.
|
||||
let [platform, alias] = process.env.MODE.split('_');
|
||||
// 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('_');
|
||||
|
||||
if (platform === 'saucelabs') {
|
||||
config.sauceLabs.build = buildId;
|
||||
@@ -113,10 +113,10 @@ module.exports = (config) => {
|
||||
} else if (platform === 'browserstack') {
|
||||
config.browserStack.build = buildId;
|
||||
config.browserStack.tunnelIdentifier = process.env.TRAVIS_JOB_ID;
|
||||
} else {
|
||||
} else if (platform !== 'travis') {
|
||||
throw new Error(`Platform "${platform}" unknown, but Travis specified. Exiting.`);
|
||||
}
|
||||
|
||||
config.browsers = platformMap[platform][alias.toLowerCase()];
|
||||
config.browsers = platformMap[platform][target.toLowerCase()];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"ChromeNoSandbox": {
|
||||
"base": "Chrome",
|
||||
"ChromeHeadless_CI": {
|
||||
"base": "ChromeHeadless",
|
||||
"flags": [
|
||||
"--no-sandbox"
|
||||
"--window-size=1024,768"
|
||||
]
|
||||
},
|
||||
"Chrome_1024x768": {
|
||||
|
||||
Reference in New Issue
Block a user