Skip to content

Commit e1c50ee

Browse files
committed
build: run all unit tests on browserstack
* No longer runs tests on Saucelabs, because those jobs mostly time out, or are just flaky.
1 parent 4c3e385 commit e1c50ee

File tree

6 files changed

+80
-84
lines changed

6 files changed

+80
-84
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
# the tool is released with https://github.com/google/closure-compiler/pull/2600
3131
# - env: "MODE=closure-compiler"
3232
- env: "MODE=e2e"
33-
- env: "MODE=saucelabs_required"
34-
- env: "MODE=browserstack_required"
35-
- env: "MODE=travis_required"
33+
- env: "MODE=test-browserstack-1"
34+
- env: "MODE=test-browserstack-2"
35+
- env: "MODE=test-travis-1"
3636
- env: "DEPLOY_MODE=build-artifacts"
3737
- env: "DEPLOY_MODE=docs-content"
3838
- env: "DEPLOY_MODE=screenshot-tool"

scripts/ci/sources/mode.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ is_payload() {
2222
}
2323

2424
is_unit() {
25-
[[ "${MODE}" =~ ^.*_(optional|required)$ ]]
25+
[[ "${MODE}" =~ ^test-.* ]]
2626
}
2727

2828
is_prerender() {

scripts/ci/sources/tunnel.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,38 @@ source ./scripts/retry-call.sh
66
# Variable the specifies how often the wait script should be invoked if it fails.
77
WAIT_RETRIES=2
88

9-
start_tunnel() {
9+
start_tunnel_if_necessary() {
1010
case "$MODE" in
11-
e2e*|saucelabs*)
11+
e2e*)
1212
./scripts/saucelabs/start-tunnel.sh
1313
;;
14-
browserstack*)
14+
test-browserstack-*)
1515
./scripts/browserstack/start-tunnel.sh
1616
;;
1717
*)
1818
;;
1919
esac
2020
}
2121

22-
wait_for_tunnel() {
22+
wait_for_tunnel_if_present() {
2323
case "$MODE" in
24-
e2e*|saucelabs*)
24+
e2e*)
2525
retryCall ${WAIT_RETRIES} ./scripts/saucelabs/wait-tunnel.sh
2626
;;
27-
browserstack*)
27+
test-browserstack-*)
2828
retryCall ${WAIT_RETRIES} ./scripts/browserstack/wait-tunnel.sh
2929
;;
3030
*)
3131
;;
3232
esac
3333
}
3434

35-
teardown_tunnel() {
35+
teardown_tunnel_if_present() {
3636
case "$MODE" in
37-
e2e*|saucelabs*)
37+
e2e*)
3838
./scripts/saucelabs/stop-tunnel.sh
3939
;;
40-
browserstack*)
40+
test-browserstack-*)
4141
./scripts/browserstack/stop-tunnel.sh
4242
;;
4343
*)

scripts/ci/travis-testing.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
2828
fi
2929
fi
3030

31-
start_tunnel
32-
wait_for_tunnel
31+
start_tunnel_if_necessary
32+
wait_for_tunnel_if_present
3333

3434
if is_lint; then
3535
$(npm bin)/gulp ci:lint
@@ -52,4 +52,4 @@ if [ -f dist/coverage/coverage-summary.json ]; then
5252
$(npm bin)/gulp ci:coverage
5353
fi
5454

55-
teardown_tunnel
55+
teardown_tunnel_if_present

test/browser-providers.js

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,75 +5,74 @@
55
* Target can be either: BS (Browserstack) | SL (Saucelabs) | TC (Travis CI) | null (To not run)
66
*/
77
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: true }},
13-
'FirefoxDev': { unitTest: {target: null, required: true }},
14-
'IE9': { unitTest: {target: null, required: false }},
15-
'IE10': { unitTest: {target: null, required: true }},
16-
'IE11': { unitTest: {target: 'SL', required: true }},
17-
'Edge': { unitTest: {target: 'SL', 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: 'SL', required: true }},
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: 'BS', required: true }},
31-
'WindowsPhone': { unitTest: {target: null, required: false }}
8+
'ChromeHeadlessCI': { target: 'TC', poolId: 1 },
9+
'FirefoxHeadless': { target: 'TC', poolId: 1 },
10+
'ChromeBeta': { target: null },
11+
'FirefoxBeta': { target: null },
12+
'ChromeDev': { target: null },
13+
'FirefoxDev': { target: null },
14+
'IE9': { target: null },
15+
'IE10': { target: null },
16+
'IE11': { target: 'BS', poolId: 2 },
17+
'Edge': { target: 'BS', poolId: 2 },
18+
'Android4.1': { target: null },
19+
'Android4.2': { target: null },
20+
'Android4.3': { target: null },
21+
'Android4.4': { target: null },
22+
'Android5': { target: null },
23+
'Safari7': { target: null },
24+
'Safari8': { target: null },
25+
'Safari9': { target: 'BS', poolId: 1 },
26+
'Safari10': { target: 'BS', poolId: 1 },
27+
'iOS7': { target: null },
28+
'iOS8': { target: null },
29+
'iOS9': { target: null },
30+
'iOS10': { target: 'BS', poolId: 1 },
31+
'WindowsPhone': { target: null }
3232
};
3333

3434
/** Exports all available remote browsers. */
3535
exports.customLaunchers = require('./remote_browsers.json');
3636

3737
/** Exports a map of configured browsers, which should run on the CI. */
3838
exports.platformMap = {
39-
'saucelabs': {
40-
required: buildConfiguration('unitTest', 'SL', true),
41-
optional: buildConfiguration('unitTest', 'SL', false)
42-
},
43-
'browserstack': {
44-
required: buildConfiguration('unitTest', 'BS', true),
45-
optional: buildConfiguration('unitTest', 'BS', false)
46-
},
47-
'travis': {
48-
required: buildConfiguration('unitTest', 'TC', true),
49-
optional: buildConfiguration('unitTest', 'TC', false)
50-
}
39+
'browserstack': buildConfiguration('BS'),
40+
'travis': buildConfiguration('TC'),
5141
};
5242

53-
/** Build a list of configuration (custom launcher names). */
54-
function buildConfiguration(type, target, required) {
55-
const targetBrowsers = Object.keys(browserConfig)
56-
.map(browserName => [browserName, browserConfig[browserName][type]])
57-
.filter(([, config]) => config.required === required && config.target === target)
58-
.map(([browserName]) => browserName);
43+
/** Ensures that the Travis access keys work properly. */
44+
if (process.env.TRAVIS) {
45+
process.env.BROWSER_STACK_ACCESS_KEY = decodeToken(process.env.BROWSER_STACK_ACCESS_KEY);
46+
}
47+
48+
/** Build a list of configuration for the specified platform. */
49+
function buildConfiguration(platform) {
50+
const platformConfig = {};
51+
52+
Object.keys(browserConfig).forEach(browserName => {
53+
const config = browserConfig[browserName];
54+
55+
if (config.target !== platform && !config.poolId) {
56+
return;
57+
}
58+
59+
if (!platformConfig[config.poolId]) {
60+
platformConfig[config.poolId] = [];
61+
}
5962

60-
// For browsers that run on Travis CI the browser name shouldn't be prefixed with the shortcut
61-
// of Travis. The different Karma launchers only work with the plain browser name (e.g Firefox)
62-
if (target === 'TC') {
63-
return targetBrowsers;
64-
}
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 (platform !== 'TC') {
66+
browserName = `${platform}_${browserName.toUpperCase()}`;
67+
}
6568

66-
return targetBrowsers.map(browserName => `${target}_${browserName.toUpperCase()}`);
69+
platformConfig[config.poolId].push(browserName);
70+
});
71+
72+
return platformConfig;
6773
}
6874

6975
/** Decode the token for Travis to use. */
7076
function decodeToken(token) {
7177
return (token || '').split('').reverse().join('');
7278
}
73-
74-
75-
/** Ensures that the Travis access keys work properly. */
76-
if (process.env.TRAVIS) {
77-
process.env.SAUCE_ACCESS_KEY = decodeToken(process.env.SAUCE_ACCESS_KEY);
78-
process.env.BROWSER_STACK_ACCESS_KEY = decodeToken(process.env.BROWSER_STACK_ACCESS_KEY);
79-
}

test/karma.conf.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,26 @@ module.exports = (config) => {
100100
if (process.env['TRAVIS']) {
101101
const buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`;
102102

103-
if (process.env['TRAVIS_PULL_REQUEST'] === 'false' &&
104-
process.env['MODE'] === "travis_required") {
103+
if (process.env['TRAVIS_PULL_REQUEST'] === 'false'
104+
&& process.env['MODE'] === "test-travis-1") {
105105

106106
config.preprocessors['dist/packages/**/!(*+(.|-)spec).js'] = ['coverage'];
107107
config.reporters.push('coverage');
108108
}
109109

110110
// The MODE variable is the indicator of what row in the test matrix we're running.
111-
// It will look like <platform>_<target>, where platform is one of 'saucelabs', 'browserstack'
112-
// or 'travis'. The target is a reference to different collections of browsers that can run
113-
// in the previously specified platform.
114-
const [platform, target] = process.env.MODE.split('_');
115-
116-
if (platform === 'saucelabs') {
117-
config.sauceLabs.build = buildId;
118-
config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_ID;
119-
} else if (platform === 'browserstack') {
111+
// It will look like "test-<platform>[-poolId], where platform is one of 'browserstack' or
112+
// 'travis'. Pool ids allow running different browsers on the same
113+
// platform, but in different CI jobs.
114+
const [, platform, poolId] = process.env.MODE.split('-');
115+
116+
if (platform === 'browserstack') {
120117
config.browserStack.build = buildId;
121118
config.browserStack.tunnelIdentifier = process.env.TRAVIS_JOB_ID;
122119
} else if (platform !== 'travis') {
123-
throw new Error(`Platform "${platform}" unknown, but Travis specified. Exiting.`);
120+
throw new Error(`Platform "${platform}" is unknown. Exiting..`);
124121
}
125122

126-
config.browsers = platformMap[platform][target.toLowerCase()];
123+
config.browsers = platformMap[platform][parseInt(poolId)];
127124
}
128125
};

0 commit comments

Comments
 (0)