Skip to content

Commit 3a6578e

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 3a6578e

File tree

8 files changed

+93
-95
lines changed

8 files changed

+93
-95
lines changed

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ jobs:
2626
- env: "MODE=aot"
2727
- env: "MODE=payload"
2828
- env: "MODE=prerender"
29-
# Closure Compiler CI check is temporarily disabled until a new version of
30-
# the tool is released with https://github.com/google/closure-compiler/pull/2600
31-
# - env: "MODE=closure-compiler"
3229
- env: "MODE=e2e"
33-
- env: "MODE=saucelabs_required"
34-
- env: "MODE=browserstack_required"
35-
- env: "MODE=travis_required"
30+
- env: "MODE=test-browserstack-1"
31+
- env: "MODE=test-browserstack-2"
32+
- env: "MODE=test-travis-1"
3633
- env: "DEPLOY_MODE=build-artifacts"
3734
- env: "DEPLOY_MODE=docs-content"
3835
- env: "DEPLOY_MODE=screenshot-tool"
3936
- env: "DEPLOY_MODE=dashboard"
37+
# Closure Compiler CI check is temporarily disabled until a new version of
38+
# the tool is released with https://github.com/google/closure-compiler/pull/2600
39+
# - env: "MODE=closure-compiler"
4040
env:
4141
global:
4242
- LOGS_DIR=/tmp/angular-material2-build/logs
4343
- SAUCE_USERNAME=angular-ci
44-
- BROWSER_STACK_USERNAME=angularteam1
45-
- BROWSER_STACK_ACCESS_KEY=BWCd4SynLzdDcv8xtzsB
44+
- BROWSER_STACK_USERNAME=paulgschwendtner2
45+
- BROWSER_STACK_ACCESS_KEY=hsz2pirQRsDASY1aZKaz
4646
- BROWSER_PROVIDER_READY_FILE=/tmp/angular-material2-build/readyfile
4747
- BROWSER_PROVIDER_ERROR_FILE=/tmp/angular-material2-build/errorfile
4848

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
"karma-coverage": "^1.1.1",
101101
"karma-firefox-launcher": "^1.0.1",
102102
"karma-jasmine": "^1.1.0",
103-
"karma-sauce-launcher": "^1.2.0",
104103
"karma-sourcemap-loader": "^0.3.7",
105104
"madge": "^2.2.0",
106105
"magic-string": "^0.22.4",

scripts/browserstack/start-tunnel.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ unzip -q ${TUNNEL_FILE} -d browserstack-tunnel
3030
# Cleanup the download directory.
3131
rm ${TUNNEL_FILE}
3232

33-
ARGS=""
33+
if [ -z "${TRAVIS_JOB_ID}" ]; then
34+
echo "Error: Cannot set up a BrowserStack tunnel if there is no '\$TRAVIS_JOB_ID' set."
35+
exit 1
36+
fi;
3437

35-
# Set tunnel-id only on Travis, to make local testing easier.
36-
if [ ! -z "${TRAVIS_JOB_ID}" ]; then
37-
ARGS="${ARGS} --local-identifier ${TRAVIS_JOB_ID}"
38-
fi
38+
ARGS="--local-identifier ${TRAVIS_JOB_ID}"
3939

40-
echo "Starting Browserstack Local in the background, logging into: ${TUNNEL_LOG}"
40+
echo "Starting Browserstack Local in the background, logging into: ${TUNNEL_LOG}." \
41+
"Using the following tunnel identifier: ${TRAVIS_JOB_ID}"
4142

4243
# Extension to the BrowserStackLocal binaries, because those can't create a readyfile.
4344
function create_ready_file {

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: 49 additions & 50 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+
/** Build a list of configuration for the specified platform. */
44+
function buildConfiguration(platform) {
45+
const platformConfig = {};
5946

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-
}
47+
Object.keys(browserConfig).forEach(browserName => {
48+
const config = browserConfig[browserName];
6549

66-
return targetBrowsers.map(browserName => `${target}_${browserName.toUpperCase()}`);
50+
if (config.target !== platform || !config.poolId) {
51+
return;
52+
}
53+
54+
if (!platformConfig[config.poolId]) {
55+
platformConfig[config.poolId] = [];
56+
}
57+
58+
// For browsers that run on Travis CI the browser name shouldn't be prefixed with the shortcut
59+
// of Travis. The different Karma launchers only work with the plain browser name (e.g Firefox)
60+
if (platform !== 'TC') {
61+
browserName = `${platform}_${browserName.toUpperCase()}`;
62+
}
63+
64+
platformConfig[config.poolId].push(browserName);
65+
});
66+
67+
return platformConfig;
6768
}
6869

6970
/** Decode the token for Travis to use. */
7071
function decodeToken(token) {
7172
return (token || '').split('').reverse().join('');
7273
}
7374

74-
7575
/** Ensures that the Travis access keys work properly. */
7676
if (process.env.TRAVIS) {
77-
process.env.SAUCE_ACCESS_KEY = decodeToken(process.env.SAUCE_ACCESS_KEY);
7877
process.env.BROWSER_STACK_ACCESS_KEY = decodeToken(process.env.BROWSER_STACK_ACCESS_KEY);
7978
}

test/karma.conf.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module.exports = (config) => {
99
plugins: [
1010
require('karma-jasmine'),
1111
require('karma-browserstack-launcher'),
12-
require('karma-sauce-launcher'),
1312
require('karma-chrome-launcher'),
1413
require('karma-firefox-launcher'),
1514
require('karma-sourcemap-loader'),
@@ -79,9 +78,10 @@ module.exports = (config) => {
7978

8079
browserDisconnectTimeout: 20000,
8180
browserNoActivityTimeout: 240000,
81+
browserDisconnectTolerance: 1,
8282
captureTimeout: 120000,
83-
browsers: ['ChromeHeadlessLocal'],
8483

84+
browsers: ['ChromeHeadlessLocal'],
8585
singleRun: false,
8686

8787
browserConsoleLogOptions: {
@@ -98,31 +98,30 @@ module.exports = (config) => {
9898
});
9999

100100
if (process.env['TRAVIS']) {
101-
const buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`;
101+
const buildId = `TravisCI ${process.env.TRAVIS_BUILD_ID}`;
102+
const tunnelIdentifier = process.env.TRAVIS_JOB_ID;
102103

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

106107
config.preprocessors['dist/packages/**/!(*+(.|-)spec).js'] = ['coverage'];
107108
config.reporters.push('coverage');
108109
}
109110

110111
// 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') {
112+
// It will look like "test-<platform>[-poolId], where platform is one of 'browserstack' or
113+
// 'travis'. Pool ids allow running different browsers on the same
114+
// platform, but in different CI jobs.
115+
const [, platform, poolId] = process.env.MODE.split('-');
116+
117+
if (platform === 'browserstack') {
120118
config.browserStack.build = buildId;
121-
config.browserStack.tunnelIdentifier = process.env.TRAVIS_JOB_ID;
119+
config.browserStack.tunnelIdentifier = tunnelIdentifier;
120+
console.log(`Setting up Browserstack launcher. Connecting to tunnel: "${tunnelIdentifier}"`);
122121
} else if (platform !== 'travis') {
123-
throw new Error(`Platform "${platform}" unknown, but Travis specified. Exiting.`);
122+
throw new Error(`Platform "${platform}" is unknown. Exiting..`);
124123
}
125124

126-
config.browsers = platformMap[platform][target.toLowerCase()];
125+
config.browsers = platformMap[platform][parseInt(poolId)];
127126
}
128127
};

0 commit comments

Comments
 (0)