Skip to content

Commit 82ffa95

Browse files
committed
Setting up Travis with saucelabs.
1 parent f0db817 commit 82ffa95

3 files changed

Lines changed: 64 additions & 0 deletions

File tree

scripts/sauce_connect_setup.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Taken from the Angular2 repo.
3+
4+
set -e -o pipefail
5+
6+
# Setup and start Sauce Connect for your TravisCI build
7+
# This script requires your .travis.yml to include the following two private env variables:
8+
# SAUCE_USERNAME
9+
# SAUCE_ACCESS_KEY
10+
# Follow the steps at https://saucelabs.com/opensource/travis to set that up.
11+
#
12+
# Curl and run this script as part of your .travis.yml before_script section:
13+
# before_script:
14+
# - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash
15+
16+
CONNECT_URL="https://saucelabs.com/downloads/sc-${SAUCE_CONNECT_VERSION}-linux.tar.gz"
17+
CONNECT_DIR="/tmp/sauce-connect-$RANDOM"
18+
CONNECT_DOWNLOAD="sc-latest-linux.tar.gz"
19+
20+
CONNECT_LOG="$LOGS_DIR/sauce-connect"
21+
CONNECT_STDOUT="$LOGS_DIR/sauce-connect.stdout"
22+
CONNECT_STDERR="$LOGS_DIR/sauce-connect.stderr"
23+
24+
# Get Connect and start it
25+
mkdir -p $CONNECT_DIR
26+
cd $CONNECT_DIR
27+
curl $CONNECT_URL -o $CONNECT_DOWNLOAD 2> /dev/null 1> /dev/null
28+
mkdir sauce-connect
29+
tar --extract --file=$CONNECT_DOWNLOAD --strip-components=1 --directory=sauce-connect > /dev/null
30+
rm $CONNECT_DOWNLOAD
31+
32+
SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev`
33+
34+
ARGS=""
35+
36+
# Set tunnel-id only on Travis, to make local testing easier.
37+
if [ ! -z "$TRAVIS_JOB_NUMBER" ]; then
38+
ARGS="$ARGS --tunnel-identifier $TRAVIS_JOB_NUMBER"
39+
fi
40+
if [ ! -z "$BROWSER_PROVIDER_READY_FILE" ]; then
41+
ARGS="$ARGS --readyfile $BROWSER_PROVIDER_READY_FILE"
42+
fi
43+
44+
45+
echo "Starting Sauce Connect in the background, logging into:"
46+
echo " $CONNECT_LOG"
47+
echo " $CONNECT_STDOUT"
48+
echo " $CONNECT_STDERR"
49+
sauce-connect/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY $ARGS \
50+
--logfile $CONNECT_LOG 2> $CONNECT_STDERR 1> $CONNECT_STDOUT &

scripts/travis_setup.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Sets up the test environment on Travis.
2+
3+
# Start Xvfb when running locally.
4+
if [[ ${TRAVIS} && (${CI_MODE} == "local") ]]; then
5+
/etc/init.d/xvfb start
6+
fi
7+
8+
# Start SauceConnect when running on SauceLabs.
9+
if [[ ${TRAVIS} && (${CI_MODE} == "saucelabs") ]]; then
10+
./scripts/sauce_connect_setup.sh
11+
fi

scripts/travis_test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Runs the Travis CI
2+
3+

0 commit comments

Comments
 (0)