diff --git a/.travis.yml b/.travis.yml index 70418375f9..ee3b92a980 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ branches: cache: directories: - $HOME/.pub-cache + - $HOME/.chrome/chromium before_cache: # Undo the pollution of the typescript_next build @@ -17,8 +18,10 @@ before_cache: env: global: - - KARMA_BROWSERS=DartiumWithWebPlatform - - E2E_BROWSERS=Dartium + - KARMA_DART_BROWSERS=DartiumWithWebPlatform + # 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 + - KARMA_JS_BROWSERS=ChromeNoSandbox + - E2E_BROWSERS=ChromeOnTravis - LOGS_DIR=/tmp/angular-build/logs - SAUCE_USERNAME=angular-ci - SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987 @@ -67,6 +70,8 @@ before_install: - node tools/analytics/build-analytics start ci job - node tools/analytics/build-analytics start ci before_install - echo ${TSDRC} > .tsdrc +- ./scripts/ci/install_chromium.sh +- export CHROME_BIN=$HOME/.chrome/chromium/chrome-linux/chrome - export DISPLAY=:99.0 - export GIT_SHA=$(git rev-parse HEAD) - ./scripts/ci/init_android.sh diff --git a/protractor-shared.js b/protractor-shared.js index 37e5598751..0aaee37561 100644 --- a/protractor-shared.js +++ b/protractor-shared.js @@ -79,6 +79,17 @@ var BROWSER_CAPS = { browser: 'ALL' } }, + ChromeOnTravis: { + browserName: 'chrome', + chromeOptions: mergeInto({ + 'args': ['--no-sandbox', '--js-flags=--expose-gc'], + 'binary': process.env.CHROME_BIN + }, CHROME_OPTIONS), + loggingPrefs: { + performance: 'ALL', + browser: 'ALL' + } + }, ChromeAndroid: { browserName: 'chrome', chromeOptions: mergeInto(CHROME_OPTIONS, { diff --git a/scripts/ci/install_chromium.sh b/scripts/ci/install_chromium.sh new file mode 100755 index 0000000000..d59f3df5ed --- /dev/null +++ b/scripts/ci/install_chromium.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +set -e -x + +# This script basically follows the instructions to download an old version of Chromium: https://www.chromium.org/getting-involved/download-chromium +# 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. +# 2) It checks the Travis cache for this specific version +# 3) If not available, it downloads and caches it, using the "decrement commit number" trick. + +#Build version read from the OmahaProxy CSV Viewer at https://www.chromium.org/developers/calendar +#Let's use Chromium 47 as the default (352221 build number), and try to grab the latest stable from https://omahaproxy.appspot.com/all +CHROMIUM_VERSION=352221 +TMP=$(curl -s "https://omahaproxy.appspot.com/all") || true +oldIFS="$IFS" +IFS=' +' +IFS=${IFS:0:1} +lines=( $TMP ) +IFS=',' +for line in "${lines[@]}" + do + lineArray=($line); + if [ "${lineArray[0]}" = "linux" ] && [ "${lineArray[1]}" = "stable" ] ; then + CHROMIUM_VERSION="${lineArray[7]}" + fi +done +IFS="$oldIFS" + +CHROMIUM_DIR=$HOME/.chrome/chromium +CHROMIUM_BIN=$CHROMIUM_DIR/chrome-linux/chrome +CHROMIUM_VERSION_FILE=$CHROMIUM_DIR/VERSION + +EXISTING_VERSION="" +if [[ -f $CHROMIUM_VERSION_FILE && -x $CHROMIUM_BIN ]]; then + EXISTING_VERSION=`cat $CHROMIUM_VERSION_FILE` + echo Found cached Chromium version: ${EXISTING_VERSION} +fi + +if [[ "$EXISTING_VERSION" != "$CHROMIUM_VERSION" ]]; then + echo Downloading Chromium version: ${CHROMIUM_VERSION} + rm -fR $CHROMIUM_DIR + mkdir -p $CHROMIUM_DIR + + NEXT=$CHROMIUM_VERSION + FILE="chrome-linux.zip" + STATUS=404 + while [[ $STATUS == 404 && $NEXT -ge 0 ]] + do + echo Fetch Chromium version: ${NEXT} + STATUS=$(curl "https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/${NEXT}/chrome-linux.zip" -s -w %{http_code} --create-dirs -o $FILE) || true + NEXT=$[$NEXT-1] + done + + unzip $FILE -d $CHROMIUM_DIR + rm $FILE + echo $CHROMIUM_VERSION > $CHROMIUM_VERSION_FILE +fi + + diff --git a/scripts/ci/test_dart.sh b/scripts/ci/test_dart.sh index 078b011918..bd26025811 100755 --- a/scripts/ci/test_dart.sh +++ b/scripts/ci/test_dart.sh @@ -7,6 +7,6 @@ SCRIPT_DIR=$(dirname $0) source $SCRIPT_DIR/env_dart.sh cd $SCRIPT_DIR/../.. -./node_modules/.bin/gulp test.dart --browsers=$KARMA_BROWSERS +./node_modules/.bin/gulp test.dart --browsers=$KARMA_DART_BROWSERS ${SCRIPT_DIR}/test_server_dart.sh ${SCRIPT_DIR}/test_e2e_dart.sh diff --git a/scripts/ci/test_js.sh b/scripts/ci/test_js.sh index 5b4420d87f..87d142ed25 100755 --- a/scripts/ci/test_js.sh +++ b/scripts/ci/test_js.sh @@ -13,5 +13,5 @@ if ${SCRIPT_DIR}/env_dart.sh 2>&1 > /dev/null ; then fi ./node_modules/.bin/gulp pre-test-checks -./node_modules/.bin/gulp test.js --browsers=${KARMA_BROWSERS:-Chrome} +./node_modules/.bin/gulp test.js --browsers=${KARMA_JS_BROWSERS:-Chrome} ${SCRIPT_DIR}/test_e2e_js.sh diff --git a/scripts/ci/test_router.sh b/scripts/ci/test_router.sh index efe4e2a50b..440043d97b 100755 --- a/scripts/ci/test_router.sh +++ b/scripts/ci/test_router.sh @@ -7,4 +7,4 @@ SCRIPT_DIR=$(dirname $0) source $SCRIPT_DIR/env_dart.sh cd $SCRIPT_DIR/../.. -./node_modules/.bin/gulp test.unit.router/ci --browsers=${KARMA_BROWSERS:-Chrome} +./node_modules/.bin/gulp test.unit.router/ci --browsers=${KARMA_JS_BROWSERS:-Chrome} diff --git a/scripts/ci/test_server_dart.sh b/scripts/ci/test_server_dart.sh index f7ead2a38d..f32789c4fc 100755 --- a/scripts/ci/test_server_dart.sh +++ b/scripts/ci/test_server_dart.sh @@ -35,4 +35,4 @@ trap killAllServers EXIT sleep 3 ./node_modules/.bin/gulp test.transpiler.unittest -./node_modules/.bin/gulp test.server.dart --browsers=$KARMA_BROWSERS +./node_modules/.bin/gulp test.server.dart --browsers=$KARMA_DART_BROWSERS