X Tutup
Skip to content

Commit 391a9ed

Browse files
marclavalvsavkin
authored andcommitted
chore(build): use Chromium in Travis for JS tests
1 parent 28a7811 commit 391a9ed

File tree

7 files changed

+81
-6
lines changed

7 files changed

+81
-6
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ branches:
1010
cache:
1111
directories:
1212
- $HOME/.pub-cache
13+
- $HOME/.chrome/chromium
1314

1415
before_cache:
1516
# Undo the pollution of the typescript_next build
1617
- npm install typescript
1718

1819
env:
1920
global:
20-
- KARMA_BROWSERS=DartiumWithWebPlatform
21-
- E2E_BROWSERS=Dartium
21+
- KARMA_DART_BROWSERS=DartiumWithWebPlatform
22+
# No sandbox mode is needed for Chromium in Travis, it crashes otherwise: https://sites.google.com/a/chromium.org/chromedriver/help/chrome-doesn-t-start
23+
- KARMA_JS_BROWSERS=ChromeNoSandbox
24+
- E2E_BROWSERS=ChromeOnTravis
2225
- LOGS_DIR=/tmp/angular-build/logs
2326
- SAUCE_USERNAME=angular-ci
2427
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987
@@ -67,6 +70,8 @@ before_install:
6770
- node tools/analytics/build-analytics start ci job
6871
- node tools/analytics/build-analytics start ci before_install
6972
- echo ${TSDRC} > .tsdrc
73+
- ./scripts/ci/install_chromium.sh
74+
- export CHROME_BIN=$HOME/.chrome/chromium/chrome-linux/chrome
7075
- export DISPLAY=:99.0
7176
- export GIT_SHA=$(git rev-parse HEAD)
7277
- ./scripts/ci/init_android.sh

protractor-shared.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ var BROWSER_CAPS = {
7979
browser: 'ALL'
8080
}
8181
},
82+
ChromeOnTravis: {
83+
browserName: 'chrome',
84+
chromeOptions: mergeInto({
85+
'args': ['--no-sandbox', '--js-flags=--expose-gc'],
86+
'binary': process.env.CHROME_BIN
87+
}, CHROME_OPTIONS),
88+
loggingPrefs: {
89+
performance: 'ALL',
90+
browser: 'ALL'
91+
}
92+
},
8293
ChromeAndroid: {
8394
browserName: 'chrome',
8495
chromeOptions: mergeInto(CHROME_OPTIONS, {

scripts/ci/install_chromium.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
set -e -x
4+
5+
# This script basically follows the instructions to download an old version of Chromium: https://www.chromium.org/getting-involved/download-chromium
6+
# 1) It retrieves the current stable version number from https://www.chromium.org/developers/calendar (via the https://omahaproxy.appspot.com/all file), e.g. 359700 for Chromium 48.
7+
# 2) It checks the Travis cache for this specific version
8+
# 3) If not available, it downloads and caches it, using the "decrement commit number" trick.
9+
10+
#Build version read from the OmahaProxy CSV Viewer at https://www.chromium.org/developers/calendar
11+
#Let's use Chromium 47 as the default (352221 build number), and try to grab the latest stable from https://omahaproxy.appspot.com/all
12+
CHROMIUM_VERSION=352221
13+
TMP=$(curl -s "https://omahaproxy.appspot.com/all") || true
14+
oldIFS="$IFS"
15+
IFS='
16+
'
17+
IFS=${IFS:0:1}
18+
lines=( $TMP )
19+
IFS=','
20+
for line in "${lines[@]}"
21+
do
22+
lineArray=($line);
23+
if [ "${lineArray[0]}" = "linux" ] && [ "${lineArray[1]}" = "stable" ] ; then
24+
CHROMIUM_VERSION="${lineArray[7]}"
25+
fi
26+
done
27+
IFS="$oldIFS"
28+
29+
CHROMIUM_DIR=$HOME/.chrome/chromium
30+
CHROMIUM_BIN=$CHROMIUM_DIR/chrome-linux/chrome
31+
CHROMIUM_VERSION_FILE=$CHROMIUM_DIR/VERSION
32+
33+
EXISTING_VERSION=""
34+
if [[ -f $CHROMIUM_VERSION_FILE && -x $CHROMIUM_BIN ]]; then
35+
EXISTING_VERSION=`cat $CHROMIUM_VERSION_FILE`
36+
echo Found cached Chromium version: ${EXISTING_VERSION}
37+
fi
38+
39+
if [[ "$EXISTING_VERSION" != "$CHROMIUM_VERSION" ]]; then
40+
echo Downloading Chromium version: ${CHROMIUM_VERSION}
41+
rm -fR $CHROMIUM_DIR
42+
mkdir -p $CHROMIUM_DIR
43+
44+
NEXT=$CHROMIUM_VERSION
45+
FILE="chrome-linux.zip"
46+
STATUS=404
47+
while [[ $STATUS == 404 && $NEXT -ge 0 ]]
48+
do
49+
echo Fetch Chromium version: ${NEXT}
50+
STATUS=$(curl "https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/${NEXT}/chrome-linux.zip" -s -w %{http_code} --create-dirs -o $FILE) || true
51+
NEXT=$[$NEXT-1]
52+
done
53+
54+
unzip $FILE -d $CHROMIUM_DIR
55+
rm $FILE
56+
echo $CHROMIUM_VERSION > $CHROMIUM_VERSION_FILE
57+
fi
58+
59+

scripts/ci/test_dart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ SCRIPT_DIR=$(dirname $0)
77
source $SCRIPT_DIR/env_dart.sh
88
cd $SCRIPT_DIR/../..
99

10-
./node_modules/.bin/gulp test.dart --browsers=$KARMA_BROWSERS
10+
./node_modules/.bin/gulp test.dart --browsers=$KARMA_DART_BROWSERS
1111
${SCRIPT_DIR}/test_server_dart.sh
1212
${SCRIPT_DIR}/test_e2e_dart.sh

scripts/ci/test_js.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ if ${SCRIPT_DIR}/env_dart.sh 2>&1 > /dev/null ; then
1313
fi
1414

1515
./node_modules/.bin/gulp pre-test-checks
16-
./node_modules/.bin/gulp test.js --browsers=${KARMA_BROWSERS:-Chrome}
16+
./node_modules/.bin/gulp test.js --browsers=${KARMA_JS_BROWSERS:-Chrome}
1717
${SCRIPT_DIR}/test_e2e_js.sh

scripts/ci/test_router.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ SCRIPT_DIR=$(dirname $0)
77
source $SCRIPT_DIR/env_dart.sh
88
cd $SCRIPT_DIR/../..
99

10-
./node_modules/.bin/gulp test.unit.router/ci --browsers=${KARMA_BROWSERS:-Chrome}
10+
./node_modules/.bin/gulp test.unit.router/ci --browsers=${KARMA_JS_BROWSERS:-Chrome}

scripts/ci/test_server_dart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ trap killAllServers EXIT
3535
sleep 3
3636

3737
./node_modules/.bin/gulp test.transpiler.unittest
38-
./node_modules/.bin/gulp test.server.dart --browsers=$KARMA_BROWSERS
38+
./node_modules/.bin/gulp test.server.dart --browsers=$KARMA_DART_BROWSERS

0 commit comments

Comments
 (0)
X Tutup