Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
chore: set up Sauce Labs with Travis
Browse files Browse the repository at this point in the history
This should not affect the Jenkins build at all.

Now, the Travis build uses Chrome on Sauce Labs, which in theory gives us opportunity to use any
browser/platform that Sauce Labs offers.
  • Loading branch information
vojtajina committed Jun 28, 2013
1 parent 976edc1 commit 33223e2
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 4 deletions.
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ language: node_js
node_js:
- 0.8

env:
global:
- SAUCE_USERNAME=angular-ci
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987

This comment has been minimized.

Copy link
@mgol

mgol Jan 29, 2014

Member

This access key is not encrypted, that doesn't sound as a good practice... See https://saucelabs.com/opensource/travis#setup-sauce-env

Other projects often use that approach, see e.g.:
Lo-Dash: https://github.com/lodash/lodash/blob/master/.travis.yml#L9
Traceur:
Google Web Tracing Framework: https://github.com/google/tracing-framework/blob/master/.travis.yml#L30

Since the key has been in the open for a long time now, I'd advise to reset it when making this change.

This comment has been minimized.

Copy link
@mgol

mgol Jan 29, 2014

Member

OTH, it seems secure keys are not evaluated for pull requests. Are SauceLabs/BrowserStack OK with it? It seems anyone can just copy these credentials and use them for their own project? Or am I wrong?

EDIT: Also, does those credentials allow to do anything else than to run tests?

This comment has been minimized.

Copy link
@mgol

mgol Jan 29, 2014

Member

Actually, at least BrowserStack is against putting credentials out in the open: #5596

This comment has been minimized.

Copy link
@naomiblack

naomiblack Jun 29, 2014

Contributor

We've spoken with the folks at both Travis and Saucelabs about this -- we leave this key in the open in order to be able to build community PRs. See travis-ci/travis-ci#1946

- SAUCE_CONNECT_READY_FILE=/tmp/sauce-connect-ready

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- export SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev`
- ./lib/sauce/sauce_connect_setup.sh
- npm install -g grunt-cli
- grunt package
- grunt webserver > /dev/null &
- ./lib/sauce/sauce_connect_block.sh

script:
- grunt test --browsers Firefox --reporters=dots
- grunt test --reporters dots --browsers SL_Chrome
2 changes: 2 additions & 0 deletions karma-docs.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ module.exports = function(config) {
suite: 'Docs'
}
});

config.sauceLabs.testName = 'AngularJS: docs';
};
2 changes: 2 additions & 0 deletions karma-e2e.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ module.exports = function(config) {
suite: 'E2E'
}
});

config.sauceLabs.testName = 'AngularJS: e2e';
};
2 changes: 2 additions & 0 deletions karma-jqlite.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ module.exports = function(config) {
suite: 'jqLite'
}
});

config.sauceLabs.testName = 'AngularJS: jqLite';
};
2 changes: 2 additions & 0 deletions karma-jquery.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ module.exports = function(config) {
suite: 'jQuery'
}
});

config.sauceLabs.testName = 'AngularJS: jQuery';
};
2 changes: 2 additions & 0 deletions karma-modules.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ module.exports = function(config) {
suite: 'modules'
}
});

config.sauceLabs.testName = 'AngularJS: modules';
};
16 changes: 15 additions & 1 deletion karma-shared.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ module.exports = function(config) {
autoWatch: true,
logLevel: config.LOG_INFO,
logColors: true,
browsers: ['Chrome']
browsers: ['Chrome'],

// config for Travis CI
sauceLabs: {
testName: 'AngularJS',
startConnect: false,
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
},

customLaunchers: {
'SL_Chrome': {
base: 'SauceLabs',
browserName: 'chrome'
}
}
});
};
7 changes: 7 additions & 0 deletions lib/sauce/sauce_connect_block.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash


# Wait for Connect to be ready before exiting
while [ ! -f $SAUCE_CONNECT_READY_FILE ]; do
sleep .5
done
32 changes: 32 additions & 0 deletions lib/sauce/sauce_connect_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -e

# 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="http://saucelabs.com/downloads/Sauce-Connect-latest.zip"
CONNECT_DIR="/tmp/sauce-connect-$RANDOM"
CONNECT_DOWNLOAD="Sauce_Connect.zip"
CONNECT_LOG="$CONNECT_DIR/log"

# Get Connect and start it
mkdir -p $CONNECT_DIR
cd $CONNECT_DIR
curl $CONNECT_URL > $CONNECT_DOWNLOAD 2> /dev/null
unzip $CONNECT_DOWNLOAD
rm $CONNECT_DOWNLOAD


echo "Starting Sauce Connect in the background"
echo "Logging into $CONNECT_LOG"
java -jar Sauce-Connect.jar --readyfile $SAUCE_CONNECT_READY_FILE \
--tunnel-identifier $TRAVIS_JOB_NUMBER \
$SAUCE_USERNAME $SAUCE_ACCESS_KEY > $CONNECT_LOG &
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"karma-firefox-launcher": "~0.0.1",
"karma-ng-scenario": "~0.0.1",
"karma-junit-reporter": "~0.0.1",
"karma-sauce-launcher": "~0.0.4",
"yaml-js": "0.0.5",
"showdown": "0.3.1",
"rewire": "1.1.3",
Expand Down

0 comments on commit 33223e2

Please sign in to comment.