Skip to content

Commit 8e324c8

Browse files
devversionjosephperrott
authored andcommitted
build: run chrome and firefox headless tests in circleci (#13603)
1 parent 3f98306 commit 8e324c8

File tree

5 files changed

+78
-50
lines changed

5 files changed

+78
-50
lines changed

.circleci/config.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Configuration file for https://circleci.com/gh/angular/material2
22

3-
#
43
# Note: YAML anchors allow an object to be re-used, reducing duplication.
54
# The ampersand declares an alias for an object, then later the `<<: *name`
65
# syntax dereferences it.
@@ -81,6 +80,30 @@ jobs:
8180

8281
- *save_cache
8382

83+
# ------------------------------------------------------------------------------------------
84+
# Job that runs the unit tests on locally installed browsers (Chrome and Firefox headless).
85+
# The available browsers are installed through the angular/ngcontainer Docker image.
86+
# ------------------------------------------------------------------------------------------
87+
tests_local_browsers:
88+
docker:
89+
# TODO(devversion): Temporarily use a image that includes Firefox 62 because the
90+
# ngcontainer image does include an old Firefox version that does not support headless.
91+
# See the PR that fixes this: https://github.com/angular/angular/pull/26435
92+
- image: circleci/node:10.12-browsers
93+
resource_class: xlarge
94+
environment:
95+
TEST_PLATFORM: local
96+
steps:
97+
- *checkout_code
98+
- *restore_cache
99+
- *yarn_install
100+
101+
# Launches the unit tests. The platform is determined by the "TEST_PLATFORM" environment
102+
# variable which has been configured above
103+
- run: yarn gulp ci:test
104+
105+
- *save_cache
106+
84107
# ----------------------------------
85108
# Lint job. Runs the gulp lint task.
86109
# ----------------------------------
@@ -91,7 +114,7 @@ jobs:
91114
- *restore_cache
92115
- *yarn_install
93116

94-
- run: yarn ci:lint
117+
- run: yarn gulp ci:lint
95118

96119
- *save_cache
97120

@@ -108,6 +131,10 @@ workflows:
108131
jobs:
109132
- bazel_build_test
110133

134+
unit_tests:
135+
jobs:
136+
- tests_local_browsers
137+
111138
# Lint workflow. As we want to lint in one job, this is a workflow with just one job.
112139
lint:
113140
jobs:

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
- env: "MODE=e2e"
3232
- env: "MODE=saucelabs_required"
3333
- env: "MODE=browserstack_required"
34-
- env: "MODE=travis_required"
3534
- env: "DEPLOY_MODE=build-artifacts"
3635
if: type = push
3736
- env: "DEPLOY_MODE=docs-content"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"docs": "gulp docs",
2424
"api": "gulp api-docs",
2525
"breaking-changes": "gulp breaking-changes",
26-
"ci:lint": "gulp ci:lint"
26+
"gulp": "gulp"
2727
},
2828
"version": "7.0.0-rc.2",
2929
"requiredAngularVersion": ">=7.0.0-rc.0",

test/browser-providers.js

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,64 @@
22

33
/*
44
* Browser Configuration for the different jobs in the CI.
5-
* Target can be either: BS (Browserstack) | SL (Saucelabs) | TC (Travis CI) | null (To not run)
5+
*
6+
* - local: Launches the browser locally on the current operating system.
7+
* - BS: Launches the browser within BrowserStack
8+
* - SL: Launches the browser within Saucelabs
9+
*
10+
* TODO(devversion): rename this to "browserstack" and "saucelabs".
611
*/
712
const browserConfig = {
8-
'ChromeHeadlessCI': { unitTest: {target: 'TC', required: true }},
9-
'FirefoxHeadless': { unitTest: {target: 'TC', required: true }},
10-
'ChromeBeta': { unitTest: {target: null, required: false }},
11-
'FirefoxBeta': { unitTest: {target: null, required: false }},
12-
'ChromeDev': { unitTest: {target: null, required: false }},
13-
'FirefoxDev': { unitTest: {target: null, required: false }},
14-
'IE9': { unitTest: {target: null, required: false }},
15-
'IE10': { unitTest: {target: null, required: false }},
16-
'IE11': { unitTest: {target: null, required: false }},
17-
'Edge': { unitTest: {target: 'BS', required: true }},
18-
'Android4.1': { unitTest: {target: null, required: false }},
19-
'Android4.2': { unitTest: {target: null, required: false }},
20-
'Android4.3': { unitTest: {target: null, required: false }},
21-
'Android4.4': { unitTest: {target: null, required: false }},
22-
'Android5': { unitTest: {target: null, required: false }},
23-
'Safari7': { unitTest: {target: null, required: false }},
24-
'Safari8': { unitTest: {target: null, required: false }},
25-
'Safari9': { unitTest: {target: null, required: false }},
26-
'Safari10': { unitTest: {target: 'BS', required: true }},
27-
'iOS7': { unitTest: {target: null, required: false }},
28-
'iOS8': { unitTest: {target: null, required: false }},
29-
'iOS9': { unitTest: {target: null, required: false }},
30-
'iOS10': { unitTest: {target: null, required: false }},
13+
'ChromeHeadlessCI': { unitTest: {target: 'local', }},
14+
'FirefoxHeadless': { unitTest: {target: 'local', }},
15+
'ChromeBeta': { unitTest: {target: null, }},
16+
'FirefoxBeta': { unitTest: {target: null, }},
17+
'ChromeDev': { unitTest: {target: null, }},
18+
'FirefoxDev': { unitTest: {target: null, }},
19+
'IE9': { unitTest: {target: null, }},
20+
'IE10': { unitTest: {target: null, }},
21+
'IE11': { unitTest: {target: null, }},
22+
'Edge': { unitTest: {target: 'BS', }},
23+
'Android4.1': { unitTest: {target: null, }},
24+
'Android4.2': { unitTest: {target: null, }},
25+
'Android4.3': { unitTest: {target: null, }},
26+
'Android4.4': { unitTest: {target: null, }},
27+
'Android5': { unitTest: {target: null, }},
28+
'Safari7': { unitTest: {target: null, }},
29+
'Safari8': { unitTest: {target: null, }},
30+
'Safari9': { unitTest: {target: null, }},
31+
'Safari10': { unitTest: {target: 'BS', }},
32+
'iOS7': { unitTest: {target: null, }},
33+
'iOS8': { unitTest: {target: null, }},
34+
'iOS9': { unitTest: {target: null, }},
35+
'iOS10': { unitTest: {target: null, }},
3136
// Don't use Browserstack until our open-source license includes automate testing on
3237
// mobile devices. For now, we need to use Saucelabs to keep our coverage.
33-
'iOS11': { unitTest: {target: 'SL', required: true }},
34-
'WindowsPhone': { unitTest: {target: null, required: false }}
38+
'iOS11': { unitTest: {target: 'SL', }},
39+
'WindowsPhone': { unitTest: {target: null, }}
3540
};
3641

3742
/** Exports all available remote browsers. */
3843
exports.customLaunchers = require('./remote_browsers.json');
3944

40-
/** Exports a map of configured browsers, which should run on the CI. */
45+
/** Exports a map of configured browsers, which should run in the given platform. */
4146
exports.platformMap = {
42-
'saucelabs': {
43-
required: buildConfiguration('unitTest', 'SL', true),
44-
optional: buildConfiguration('unitTest', 'SL', false)
45-
},
46-
'browserstack': {
47-
required: buildConfiguration('unitTest', 'BS', true),
48-
optional: buildConfiguration('unitTest', 'BS', false)
49-
},
50-
'travis': {
51-
required: buildConfiguration('unitTest', 'TC', true),
52-
optional: buildConfiguration('unitTest', 'TC', false)
53-
}
47+
'saucelabs': buildConfiguration('unitTest', 'SL'),
48+
'browserstack': buildConfiguration('unitTest', 'BS'),
49+
'local': buildConfiguration('unitTest', 'local'),
5450
};
5551

5652
/** Build a list of configuration (custom launcher names). */
57-
function buildConfiguration(type, target, required) {
53+
function buildConfiguration(type, target) {
5854
const targetBrowsers = Object.keys(browserConfig)
5955
.map(browserName => [browserName, browserConfig[browserName][type]])
60-
.filter(([, config]) => config.required === required && config.target === target)
56+
.filter(([, config]) => config.target === target)
6157
.map(([browserName]) => browserName);
6258

63-
// For browsers that run on Travis CI the browser name shouldn't be prefixed with the shortcut
64-
// of Travis. The different Karma launchers only work with the plain browser name (e.g Firefox)
65-
if (target === 'TC') {
59+
// For browsers that run locally, the browser name shouldn't be prefixed with the target
60+
// platform. We only prefix the external platforms in order to distinguish between
61+
// local and remote browsers in our "customLaunchers" for Karma.
62+
if (target === 'local') {
6663
return targetBrowsers;
6764
}
6865

test/karma.conf.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ module.exports = (config) => {
100100
},
101101
});
102102

103+
if (process.env['CIRCLECI']) {
104+
config.browsers = platformMap[process.env['TEST_PLATFORM']];
105+
}
106+
103107
if (process.env['TRAVIS']) {
104108
const buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`;
105109

@@ -114,7 +118,8 @@ module.exports = (config) => {
114118
// It will look like <platform>_<target>, where platform is one of 'saucelabs', 'browserstack'
115119
// or 'travis'. The target is a reference to different collections of browsers that can run
116120
// in the previously specified platform.
117-
const [platform, target] = process.env.MODE.split('_');
121+
// TODO(devversion): when moving Saucelabs and Browserstack to Circle, remove the target part.
122+
const [platform] = process.env.MODE.split('_');
118123

119124
if (platform === 'saucelabs') {
120125
config.sauceLabs.build = buildId;
@@ -132,6 +137,6 @@ module.exports = (config) => {
132137
config.concurrency = 1;
133138
}
134139

135-
config.browsers = platformMap[platform][target.toLowerCase()];
140+
config.browsers = platformMap[platform];
136141
}
137142
};

0 commit comments

Comments
 (0)