-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(): First version of using SauceLabs and BrowserStack on travis.
- Loading branch information
Showing
15 changed files
with
743 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var http = require('http'); | ||
var BrowserStackTunnel = require('browserstacktunnel-wrapper'); | ||
|
||
var HOSTNAME = 'localhost'; | ||
var PORTS = [9876, 9877]; | ||
var ACCESS_KEY = process.env.BROWSER_STACK_ACCESS_KEY; | ||
var READY_FILE = process.env.BROWSER_PROVIDER_READY_FILE; | ||
var TUNNEL_IDENTIFIER = process.env.TRAVIS_JOB_NUMBER; | ||
|
||
// We need to start fake servers, otherwise the tunnel does not start. | ||
var fakeServers = []; | ||
var hosts = []; | ||
|
||
PORTS.forEach(function(port) { | ||
fakeServers.push(http.createServer(function() {}).listen(port)); | ||
hosts.push({ | ||
name: HOSTNAME, | ||
port: port, | ||
sslFlag: 0 | ||
}); | ||
}); | ||
|
||
var tunnel = new BrowserStackTunnel({ | ||
key: ACCESS_KEY, | ||
localIdentifier: TUNNEL_IDENTIFIER, | ||
hosts: hosts | ||
}); | ||
|
||
console.log('Starting tunnel on ports', PORTS.join(', ')); | ||
tunnel.start(function(error) { | ||
if (error) { | ||
console.error('Can not establish the tunnel', error); | ||
} else { | ||
console.log('Tunnel established.'); | ||
fakeServers.forEach(function(server) { | ||
server.close(); | ||
}); | ||
|
||
if (READY_FILE) { | ||
fs.writeFile(READY_FILE, ''); | ||
} | ||
} | ||
}); | ||
|
||
tunnel.on('error', function(error) { | ||
console.error(error); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export BROWSER_STACK_ACCESS_KEY=`echo $BROWSER_STACK_ACCESS_KEY | rev` | ||
|
||
node ./scripts/browserstack/start_tunnel.js & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -e -o pipefail | ||
|
||
|
||
echo "Shutting down Browserstack tunnel" | ||
echo "TODO: implement me" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
|
||
# Wait for Connect to be ready before exiting | ||
# Time out if we wait for more than 2 minutes, so that we can print logs. | ||
let "counter=0" | ||
|
||
while [ ! -f $BROWSER_PROVIDER_READY_FILE ]; do | ||
let "counter++" | ||
if [ $counter -gt 240 ]; then | ||
echo "Timed out after 2 minutes waiting for browser provider ready file" | ||
# We must manually print logs here because travis will not run | ||
# after_script commands if the failure occurs before the script | ||
# phase. | ||
./scripts/ci/print-logs.sh | ||
exit 5 | ||
fi | ||
sleep .5 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Wait for Connect to be ready before exiting | ||
printf "Connecting to Sauce." | ||
while [ ! -f $BROWSER_PROVIDER_READY_FILE ]; do | ||
printf "." | ||
#dart2js takes longer than the travis 10 min timeout to complete | ||
sleep .5 | ||
done | ||
echo "Connected" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
set -e -o pipefail | ||
|
||
# Setup and start Sauce Connect for your TravisCI build | ||
# This script requires your .travis.yml to include the following two private env variables: | ||
# SAUCE_USERNAME | ||
# SAUCE_ACCESS_KEY | ||
# Follow the steps at https://saucelabs.com/opensource/travis to set that up. | ||
# | ||
# Curl and run this script as part of your .travis.yml before_script section: | ||
# before_script: | ||
# - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash | ||
|
||
CONNECT_URL="https://saucelabs.com/downloads/sc-4.3.11-linux.tar.gz" | ||
CONNECT_DIR="/tmp/sauce-connect-$RANDOM" | ||
CONNECT_DOWNLOAD="sc-latest-linux.tar.gz" | ||
|
||
CONNECT_LOG="$LOGS_DIR/sauce-connect" | ||
CONNECT_STDOUT="$LOGS_DIR/sauce-connect.stdout" | ||
CONNECT_STDERR="$LOGS_DIR/sauce-connect.stderr" | ||
|
||
# Get Connect and start it | ||
mkdir -p $CONNECT_DIR | ||
cd $CONNECT_DIR | ||
curl $CONNECT_URL -o $CONNECT_DOWNLOAD 2> /dev/null 1> /dev/null | ||
mkdir sauce-connect | ||
tar --extract --file=$CONNECT_DOWNLOAD --strip-components=1 --directory=sauce-connect > /dev/null | ||
rm $CONNECT_DOWNLOAD | ||
|
||
SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev` | ||
|
||
ARGS="" | ||
|
||
# Set tunnel-id only on Travis, to make local testing easier. | ||
if [ ! -z "$TRAVIS_JOB_NUMBER" ]; then | ||
ARGS="$ARGS --tunnel-identifier $TRAVIS_JOB_NUMBER" | ||
fi | ||
if [ ! -z "$BROWSER_PROVIDER_READY_FILE" ]; then | ||
ARGS="$ARGS --readyfile $BROWSER_PROVIDER_READY_FILE" | ||
fi | ||
|
||
|
||
echo "Starting Sauce Connect in the background, logging into:" | ||
echo " $CONNECT_LOG" | ||
echo " $CONNECT_STDOUT" | ||
echo " $CONNECT_STDERR" | ||
sauce-connect/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY $ARGS \ | ||
--logfile $CONNECT_LOG 2> $CONNECT_STDERR 1> $CONNECT_STDOUT & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
set -e -o pipefail | ||
|
||
|
||
echo "Shutting down Sauce Connect tunnel" | ||
|
||
killall sc | ||
|
||
while [[ -n `ps -ef | grep "sauce-connect-" | grep -v "grep"` ]]; do | ||
printf "." | ||
sleep .5 | ||
done | ||
|
||
echo "" | ||
echo "Sauce Connect tunnel has been shut down" |
Oops, something went wrong.