From 4f8a33d71febba74030823b756d0ef770c552f1e Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Mon, 20 Jun 2016 17:10:09 -0700 Subject: [PATCH] test(e2e): run e2e tests on Travis Fixes #229 --- .travis.yml | 18 ++++---- protractor.conf.js | 5 ++- scripts/install_chromium.sh | 86 +++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 9 deletions(-) create mode 100755 scripts/install_chromium.sh diff --git a/.travis.yml b/.travis.yml index 099665c29..73e3323d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,35 +4,37 @@ node_js: - '5.4.1' addons: - firefox: latest apt: sources: - ubuntu-toolchain-r-test packages: - g++-4.8 - hosts: - - localhost.firebaseio.test cache: directories: - node_modules - - typings + - ./.chrome/chromium env: - CXX=g++-4.8 +before_install: + - ./scripts/install_chromium.sh + install: - npm install + - ./node_modules/.bin/typings install + - ./node_modules/.bin/webdriver-manager update before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start script: - - npm run build - - ./node_modules/.bin/karma start --single-run --browsers Firefox - # Can't run until https://github.com/angular/protractor/issues/2784 is resolved - #- ./node_modules/.bin/protractor protractor.conf.js --browser firefox + - npm run build_e2e + - ./node_modules/.bin/protractor protractor.conf.js --capabilities.chromeOptions.binary=$CHROMIUM_BIN + - ./node_modules/.bin/karma start --single-run + notifications: webhooks: diff --git a/protractor.conf.js b/protractor.conf.js index 992fb8e75..a2696dff1 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -8,7 +8,10 @@ exports.config = { seleniumServerJar: 'node_modules/protractor/selenium/selenium-server-standalone-2.48.2.jar', // Capabilities to be passed to the webdriver instance. capabilities: { - 'browserName': 'chrome' + 'browserName': 'chrome', + chromeOptions: { + binary: process.env.CHROMIUM_BIN + } }, // Framework to use. Jasmine is recommended. diff --git a/scripts/install_chromium.sh b/scripts/install_chromium.sh new file mode 100755 index 000000000..3170dc6c0 --- /dev/null +++ b/scripts/install_chromium.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +set -e -x + +# Setup environment +cd `dirname $0` +source ../ci-lite/env.sh + + +# 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 the following version of Chromium, and inform about availability of newer build from https://omahaproxy.appspot.com/all +# +CHROMIUM_VERSION=386251 # Chrome 50 linux stable, see https://www.chromium.org/developers/calendar +export CHROME_BIN=${HOME}/.chrome/chromium/chrome-linux/chrome + + +PLATFORM="$(uname -s)" +case "$PLATFORM" in + (Darwin) + ARCHITECTURE=Mac + DIST_FILE=chrome-mac.zip + ;; + (Linux) + ARCHITECTURE=Linux_x64 + DIST_FILE=chrome-linux.zip + ;; + (*) + echo Unsupported platform $PLATFORM. Exiting ... >&2 + exit 3 + ;; +esac + +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 + LATEST_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/${ARCHITECTURE}/${NEXT}/${DIST_FILE}" -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 + +if [[ "$CHROMIUM_VERSION" != "$LATEST_CHROMIUM_VERSION" ]]; then + echo "New version of Chromium available. Update install_chromium.sh with build number: ${LATEST_CHROMIUM_VERSION}" +fi