Skip to content

Commit 80d0f98

Browse files
committed
chore(travis): clean up logs
Forward SauceConnect logs and Karma debug logs into a file and print these files at the very end of a build.
1 parent c64a985 commit 80d0f98

9 files changed

+49
-25
lines changed

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ env:
77
- SAUCE_USERNAME=angular-ci
88
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987
99
- SAUCE_CONNECT_READY_FILE=/tmp/sauce-connect-ready
10+
- LOGS_DIR=/tmp/angular-build/logs
11+
12+
before_script:
13+
- mkdir -p $LOGS_DIR
1014

1115
script:
1216
- ./travis_build.sh
17+
18+
after_script:
19+
- ./travis_print_logs.sh

karma-docs.conf.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var sharedConfig = require('./karma-shared.conf');
22

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

66
config.set({
77
files: [
@@ -35,6 +35,4 @@ module.exports = function(config) {
3535
suite: 'Docs'
3636
}
3737
});
38-
39-
config.sauceLabs.testName = 'AngularJS: docs';
4038
};

karma-e2e.conf.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var sharedConfig = require('./karma-shared.conf');
22

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

66
config.set({
77
frameworks: [],
@@ -22,6 +22,4 @@ module.exports = function(config) {
2222
suite: 'E2E'
2323
}
2424
});
25-
26-
config.sauceLabs.testName = 'AngularJS: e2e';
2725
};

karma-jqlite.conf.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var angularFiles = require('./angularFiles');
22
var sharedConfig = require('./karma-shared.conf');
33

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

77
config.set({
88
files: angularFiles.mergeFilesFor('karma'),
@@ -13,6 +13,4 @@ module.exports = function(config) {
1313
suite: 'jqLite'
1414
}
1515
});
16-
17-
config.sauceLabs.testName = 'AngularJS: jqLite';
1816
};

karma-jquery.conf.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var angularFiles = require('./angularFiles');
22
var sharedConfig = require('./karma-shared.conf');
33

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

77
config.set({
88
files: angularFiles.mergeFilesFor('karmaJquery'),
@@ -13,6 +13,4 @@ module.exports = function(config) {
1313
suite: 'jQuery'
1414
}
1515
});
16-
17-
config.sauceLabs.testName = 'AngularJS: jQuery';
1816
};

karma-modules.conf.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var angularFiles = require('./angularFiles');
22
var sharedConfig = require('./karma-shared.conf');
33

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

77
config.set({
88
files: angularFiles.mergeFilesFor('karmaModules', 'angularSrcModules'),
@@ -12,6 +12,4 @@ module.exports = function(config) {
1212
suite: 'modules'
1313
}
1414
});
15-
16-
config.sauceLabs.testName = 'AngularJS: modules';
1715
};

karma-shared.conf.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function(config) {
1+
module.exports = function(config, specificOptions) {
22
config.set({
33
frameworks: ['jasmine'],
44
autoWatch: true,
@@ -9,11 +9,13 @@ module.exports = function(config) {
99

1010
// config for Travis CI
1111
sauceLabs: {
12-
testName: 'AngularJS',
12+
testName: specificOptions.testName || 'AngularJS',
1313
startConnect: false,
1414
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
1515
},
1616

17+
// For more browsers on Sauce Labs see:
18+
// https://saucelabs.com/docs/platforms/webdriver
1719
customLaunchers: {
1820
'SL_Chrome': {
1921
base: 'SauceLabs',
@@ -51,9 +53,16 @@ module.exports = function(config) {
5153
});
5254

5355

54-
// TODO(vojta): remove once SauceLabs supports websockets.
55-
// This speeds up the capturing a bit, as browsers don't even try to use websocket.
5656
if (process.env.TRAVIS) {
57+
// TODO(vojta): remove once SauceLabs supports websockets.
58+
// This speeds up the capturing a bit, as browsers don't even try to use websocket.
5759
config.transports = ['xhr-polling'];
60+
61+
// Debug logging into a file, that we print out at the end of the build.
62+
config.loggers.push({
63+
type: 'file',
64+
filename: process.env.LOGS_DIR + '/' + (specificOptions.logFile || 'karma.log'),
65+
level: config.LOG_DEBUG
66+
});
5867
}
5968
};

lib/sauce/sauce_connect_setup.sh

+13-6
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ set -e
1515
CONNECT_URL="http://saucelabs.com/downloads/Sauce-Connect-latest.zip"
1616
CONNECT_DIR="/tmp/sauce-connect-$RANDOM"
1717
CONNECT_DOWNLOAD="Sauce_Connect.zip"
18-
CONNECT_LOG="$CONNECT_DIR/log"
18+
19+
CONNECT_LOG="$LOGS_DIR/sauce-connect"
20+
CONNECT_STDOUT="$LOGS_DIR/sauce-connect.stdout"
21+
CONNECT_STDERR="$LOGS_DIR/sauce-connect.stderr"
1922

2023
# Get Connect and start it
2124
mkdir -p $CONNECT_DIR
2225
cd $CONNECT_DIR
23-
curl $CONNECT_URL > $CONNECT_DOWNLOAD 2> /dev/null
24-
unzip $CONNECT_DOWNLOAD
26+
curl $CONNECT_URL -o $CONNECT_DOWNLOAD 2> /dev/null 1> /dev/null
27+
unzip $CONNECT_DOWNLOAD > /dev/null
2528
rm $CONNECT_DOWNLOAD
2629

2730

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

39-
echo "Starting Sauce Connect in the background"
40-
echo "Logging into $CONNECT_LOG"
41-
java -jar Sauce-Connect.jar $ARGS $SAUCE_USERNAME $SAUCE_ACCESS_KEY > $CONNECT_LOG &
42+
43+
echo "Starting Sauce Connect in the background, logging into:"
44+
echo " $CONNECT_LOG"
45+
echo " $CONNECT_STDOUT"
46+
echo " $CONNECT_STDERR"
47+
java -jar Sauce-Connect.jar $ARGS $SAUCE_USERNAME $SAUCE_ACCESS_KEY \
48+
--logfile $CONNECT_LOG 2> $CONNECT_STDERR 1> $CONNECT_STDOUT &

travis_print_logs.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
LOG_FILES=$LOGS_DIR/*
4+
5+
for FILE in $LOG_FILES; do
6+
echo -e "\n\n\n"
7+
echo "================================================================================"
8+
echo " $FILE"
9+
echo "================================================================================"
10+
cat $FILE
11+
done

0 commit comments

Comments
 (0)