Skip to content

Commit

Permalink
chore(travis): clean up logs
Browse files Browse the repository at this point in the history
Forward SauceConnect logs and Karma debug logs into a file and print these files at the very end of a build.
  • Loading branch information
vojtajina committed Aug 23, 2013
1 parent c64a985 commit 80d0f98
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 25 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ env:
- SAUCE_USERNAME=angular-ci
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987
- SAUCE_CONNECT_READY_FILE=/tmp/sauce-connect-ready
- LOGS_DIR=/tmp/angular-build/logs

before_script:
- mkdir -p $LOGS_DIR

script:
- ./travis_build.sh

after_script:
- ./travis_print_logs.sh
4 changes: 1 addition & 3 deletions karma-docs.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var sharedConfig = require('./karma-shared.conf');

module.exports = function(config) {
sharedConfig(config);
sharedConfig(config, {testName: 'AngularJS: docs', logFile: 'karma-docs.log'});

config.set({
files: [
Expand Down Expand Up @@ -35,6 +35,4 @@ module.exports = function(config) {
suite: 'Docs'
}
});

config.sauceLabs.testName = 'AngularJS: docs';
};
4 changes: 1 addition & 3 deletions karma-e2e.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var sharedConfig = require('./karma-shared.conf');

module.exports = function(config) {
sharedConfig(config);
sharedConfig(config, {testName: 'AngularJS: e2e', logFile: 'karma-e2e.log'});

config.set({
frameworks: [],
Expand All @@ -22,6 +22,4 @@ module.exports = function(config) {
suite: 'E2E'
}
});

config.sauceLabs.testName = 'AngularJS: e2e';
};
4 changes: 1 addition & 3 deletions karma-jqlite.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var angularFiles = require('./angularFiles');
var sharedConfig = require('./karma-shared.conf');

module.exports = function(config) {
sharedConfig(config);
sharedConfig(config, {testName: 'AngularJS: jqLite', logFile: 'karma-jqlite.log'});

config.set({
files: angularFiles.mergeFilesFor('karma'),
Expand All @@ -13,6 +13,4 @@ module.exports = function(config) {
suite: 'jqLite'
}
});

config.sauceLabs.testName = 'AngularJS: jqLite';
};
4 changes: 1 addition & 3 deletions karma-jquery.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var angularFiles = require('./angularFiles');
var sharedConfig = require('./karma-shared.conf');

module.exports = function(config) {
sharedConfig(config);
sharedConfig(config, {testName: 'AngularJS: jQuery', logFile: 'karma-jquery.log'});

config.set({
files: angularFiles.mergeFilesFor('karmaJquery'),
Expand All @@ -13,6 +13,4 @@ module.exports = function(config) {
suite: 'jQuery'
}
});

config.sauceLabs.testName = 'AngularJS: jQuery';
};
4 changes: 1 addition & 3 deletions karma-modules.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var angularFiles = require('./angularFiles');
var sharedConfig = require('./karma-shared.conf');

module.exports = function(config) {
sharedConfig(config);
sharedConfig(config, {testName: 'AngularJS: modules', logFile: 'karma-modules.log'});

config.set({
files: angularFiles.mergeFilesFor('karmaModules', 'angularSrcModules'),
Expand All @@ -12,6 +12,4 @@ module.exports = function(config) {
suite: 'modules'
}
});

config.sauceLabs.testName = 'AngularJS: modules';
};
17 changes: 13 additions & 4 deletions karma-shared.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function(config) {
module.exports = function(config, specificOptions) {
config.set({
frameworks: ['jasmine'],
autoWatch: true,
Expand All @@ -9,11 +9,13 @@ module.exports = function(config) {

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

// For more browsers on Sauce Labs see:
// https://saucelabs.com/docs/platforms/webdriver
customLaunchers: {
'SL_Chrome': {
base: 'SauceLabs',
Expand Down Expand Up @@ -51,9 +53,16 @@ module.exports = function(config) {
});


// TODO(vojta): remove once SauceLabs supports websockets.
// This speeds up the capturing a bit, as browsers don't even try to use websocket.
if (process.env.TRAVIS) {
// TODO(vojta): remove once SauceLabs supports websockets.
// This speeds up the capturing a bit, as browsers don't even try to use websocket.
config.transports = ['xhr-polling'];

// Debug logging into a file, that we print out at the end of the build.
config.loggers.push({
type: 'file',
filename: process.env.LOGS_DIR + '/' + (specificOptions.logFile || 'karma.log'),
level: config.LOG_DEBUG
});
}
};
19 changes: 13 additions & 6 deletions lib/sauce/sauce_connect_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ set -e
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"

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 > $CONNECT_DOWNLOAD 2> /dev/null
unzip $CONNECT_DOWNLOAD
curl $CONNECT_URL -o $CONNECT_DOWNLOAD 2> /dev/null 1> /dev/null
unzip $CONNECT_DOWNLOAD > /dev/null
rm $CONNECT_DOWNLOAD


Expand All @@ -36,6 +39,10 @@ if [ ! -z "$SAUCE_CONNECT_READY_FILE" ]; then
ARGS="$ARGS --readyfile $SAUCE_CONNECT_READY_FILE"
fi

echo "Starting Sauce Connect in the background"
echo "Logging into $CONNECT_LOG"
java -jar Sauce-Connect.jar $ARGS $SAUCE_USERNAME $SAUCE_ACCESS_KEY > $CONNECT_LOG &

echo "Starting Sauce Connect in the background, logging into:"
echo " $CONNECT_LOG"
echo " $CONNECT_STDOUT"
echo " $CONNECT_STDERR"
java -jar Sauce-Connect.jar $ARGS $SAUCE_USERNAME $SAUCE_ACCESS_KEY \
--logfile $CONNECT_LOG 2> $CONNECT_STDERR 1> $CONNECT_STDOUT &
11 changes: 11 additions & 0 deletions travis_print_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

LOG_FILES=$LOGS_DIR/*

for FILE in $LOG_FILES; do
echo -e "\n\n\n"
echo "================================================================================"
echo " $FILE"
echo "================================================================================"
cat $FILE
done

0 comments on commit 80d0f98

Please sign in to comment.