From f8fa9748e914ba5ca1cfcb73e11271644f1c86a3 Mon Sep 17 00:00:00 2001 From: shirletan Date: Fri, 5 May 2017 13:12:53 -0700 Subject: [PATCH] add osx travis test run job (#1074) --- .travis.yml | 32 +++++++++++++++++--------------- scripts/get_chromedriver.sh | 11 ++++++----- scripts/get_geckdriver.sh | 6 ++++++ scripts/get_selenium.sh | 5 ++--- scripts/setup_linux_env.sh | 8 ++++++++ scripts/setup_osx_env.sh | 8 ++++++++ 6 files changed, 47 insertions(+), 23 deletions(-) create mode 100755 scripts/setup_linux_env.sh create mode 100755 scripts/setup_osx_env.sh diff --git a/.travis.yml b/.travis.yml index 6d662f4af..af2620c3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,17 @@ language: node_js -node_js: -- "stable" -sudo: required -dist: trusty -addons: - apt: - sources: - - google-chrome - packages: - - google-chrome-stable +matrix: + include: + - os: linux + dist: trusty + node_js: stable + sudo: required + addons: + apt: + packages: + - google-chrome-stable + - os: osx + node_js: stable + osx_image: xcode8.3 before_install: - npm install google-closure-library @@ -16,12 +19,11 @@ before_install: - ln -s $(npm root)/google-closure-library ../closure-library before_script: - - export CHROME_BIN=/usr/bin/google-chrome - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start + - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then ( scripts/setup_linux_env.sh ) fi + - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then ( scripts/setup_osx_env.sh ) fi + - sleep 2 + script: - set -x - npm test - -os: - - linux diff --git a/scripts/get_chromedriver.sh b/scripts/get_chromedriver.sh index c3e3d6453..7bff39c16 100755 --- a/scripts/get_chromedriver.sh +++ b/scripts/get_chromedriver.sh @@ -5,12 +5,13 @@ if [ ! -d $chromedriver_dir ]; then mkdir $chromedriver_dir fi -if [[ $os_name == 'Linux' ]]; then - cd chromedriver && curl -L https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip > tmp.zip && unzip -o tmp.zip && rm tmp.zip +echo "downloading chromedriver" + +if [[ $os_name == 'Linux' && ! -f $chromedriver_dir/chromedriver ]]; then + cd chromedriver && curl -L https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip > tmp.zip && unzip -o tmp.zip && rm tmp.zip # wait until download finish sleep 5 -elif [[ $os_name == 'Darwin' ]]; then - cd chromedriver && curl -L https://chromedriver.storage.googleapis.com/2.29/chromedriver_mac64.zip | tar xz - # wait until download finish +elif [[ $os_name == 'Darwin' && ! -f $chromedriver_dir/chromedriver ]]; then + cd chromedriver && curl -L https://chromedriver.storage.googleapis.com/2.29/chromedriver_mac64.zip | tar xz sleep 5 fi diff --git a/scripts/get_geckdriver.sh b/scripts/get_geckdriver.sh index 12002b608..77fecd4ec 100755 --- a/scripts/get_geckdriver.sh +++ b/scripts/get_geckdriver.sh @@ -1,5 +1,11 @@ #!/bin/bash os_name=`uname` + +if [ -f geckodriver ]; then + exit 0 +fi +echo "downloading gechdriver" + if [[ $os_name == 'Linux' ]]; then cd ../ && curl -L https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz | tar xz sleep 5 diff --git a/scripts/get_selenium.sh b/scripts/get_selenium.sh index 108313ff9..0dac3e9b5 100755 --- a/scripts/get_selenium.sh +++ b/scripts/get_selenium.sh @@ -6,10 +6,9 @@ if [ ! -d $DIR ]; then mkdir $DIR fi +echo "downloading selenium jar" + if [ ! -f $DIR/$FILE ]; then cd $DIR && curl -O http://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar sleep 5 fi - - - diff --git a/scripts/setup_linux_env.sh b/scripts/setup_linux_env.sh new file mode 100755 index 000000000..da3d0ce6c --- /dev/null +++ b/scripts/setup_linux_env.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ "${TRAVIS_OS_NAME}" == "linux" ] + then + export CHROME_BIN="/usr/bin/google-chrome" + export DISPLAY=:99.0 + sh -e /etc/init.d/xvfb start & +fi diff --git a/scripts/setup_osx_env.sh b/scripts/setup_osx_env.sh new file mode 100755 index 000000000..92891f966 --- /dev/null +++ b/scripts/setup_osx_env.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ "${TRAVIS_OS_NAME}" == "osx" ] + then + brew cask install google-chrome + sudo Xvfb :99 -ac -screen 0 1024x768x8 & + export CHROME_BIN="/Applications/Google Chrome.app" +fi