Skip to content

Commit a681438

Browse files
devversionmmalerba
authored andcommitted
build: suppress logging of sauce-connect (#4856)
* Suppresses normal log messages from Saucelabs Conect. Error messages will still show up (In a follow-up PR the normal stdout will be printed together with the stdout on CI failures) * No longer suppresses the whole Browserstack Tunnel execution. Stderr output will be printed if present. (In a follow-up stdout will be printed as well on CI failures) * Switches to best-practice variable referencing in Bash
1 parent 3a14d3a commit a681438

File tree

4 files changed

+40
-47
lines changed

4 files changed

+40
-47
lines changed

scripts/browserstack/start-tunnel.sh

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,66 @@ set -e -o pipefail
44

55
# Workaround for Travis CI cookbook https://github.com/travis-ci/travis-ci/issues/4862,
66
# where $PATH will be extended with relative paths to the NPM binaries.
7-
PATH=`echo $PATH | sed -e 's/:\.\/node_modules\/\.bin//'`
7+
PATH=`echo ${PATH} | sed -e 's/:\.\/node_modules\/\.bin//'`
88

99
TUNNEL_FILE="BrowserStackLocal-linux-x64.zip"
10-
TUNNEL_URL="https://www.browserstack.com/browserstack-local/$TUNNEL_FILE"
10+
TUNNEL_URL="https://www.browserstack.com/browserstack-local/${TUNNEL_FILE}"
1111
TUNNEL_DIR="/tmp/browserstack-tunnel"
12-
TUNNEL_LOG="$LOGS_DIR/browserstack-tunnel.log"
12+
TUNNEL_LOG="${LOGS_DIR}/browserstack-tunnel.log"
1313

14-
BROWSER_STACK_ACCESS_KEY=`echo $BROWSER_STACK_ACCESS_KEY | rev`
14+
BROWSER_STACK_ACCESS_KEY=`echo ${BROWSER_STACK_ACCESS_KEY} | rev`
1515

1616
# Cleanup and create the folder structure for the tunnel connector.
17-
rm -rf $TUNNEL_DIR $BROWSER_PROVIDER_READY_FILE
18-
mkdir -p $TUNNEL_DIR
19-
touch $TUNNEL_LOG
17+
rm -rf ${TUNNEL_DIR} ${BROWSER_PROVIDER_READY_FILE}
18+
mkdir -p ${TUNNEL_DIR}
19+
touch ${TUNNEL_LOG}
2020

21-
cd $TUNNEL_DIR
21+
cd ${TUNNEL_DIR}
2222

2323
# Download the browserstack local binaries.
24-
curl $TUNNEL_URL -o $TUNNEL_FILE 2> /dev/null 1> /dev/null
24+
curl ${TUNNEL_URL} -o ${TUNNEL_FILE} 2> /dev/null 1> /dev/null
2525

2626
# Extract the browserstack local binaries from the tarball.
2727
mkdir -p browserstack-tunnel
28-
unzip -q $TUNNEL_FILE -d browserstack-tunnel
28+
unzip -q ${TUNNEL_FILE} -d browserstack-tunnel
2929

3030
# Cleanup the download directory.
31-
rm $TUNNEL_FILE
31+
rm ${TUNNEL_FILE}
3232

3333
ARGS=""
3434

3535
# Set tunnel-id only on Travis, to make local testing easier.
36-
if [ ! -z "$TRAVIS_JOB_ID" ]; then
37-
ARGS="$ARGS --local-identifier $TRAVIS_JOB_ID"
36+
if [ ! -z "${TRAVIS_JOB_ID}" ]; then
37+
ARGS="${ARGS} --local-identifier ${TRAVIS_JOB_ID}"
3838
fi
3939

40-
echo "Starting Browserstack Local in the background, logging into:"
41-
echo " $TUNNEL_LOG"
42-
echo " ---"
43-
echo " $ARGS"
40+
echo "Starting Browserstack Local in the background, logging into: ${TUNNEL_LOG}"
4441

4542
# Extension to the BrowserStackLocal binaries, because those can't create a readyfile.
4643
function create_ready_file {
4744

4845
# To be able to exit the tail properly we need to have a sub shell spawned, which is
4946
# used to track the state of tail.
50-
{ sleep 120; touch $BROWSER_PROVIDER_ERROR_FILE; } &
47+
{ sleep 120; touch ${BROWSER_PROVIDER_ERROR_FILE}; } &
5148

52-
TIMER_PID=$!
49+
TIMER_PID=${!}
5350

5451
# Disown the background process, because we don't want to show any messages when killing
5552
# the timer.
5653
disown
5754

5855
# When the tail recognizes the `Ctrl-C` log message the BrowserStack Tunnel is up.
5956
{
60-
tail -n0 -f $TUNNEL_LOG --pid $TIMER_PID | { sed '/Ctrl/q' && kill -9 $TIMER_PID; };
57+
tail -n0 -f ${TUNNEL_LOG} --pid ${TIMER_PID} | { sed '/Ctrl/q' && kill -9 ${TIMER_PID}; };
6158
} &> /dev/null
6259

6360
echo
6461
echo "BrowserStack Tunnel ready"
6562

66-
touch $BROWSER_PROVIDER_READY_FILE
63+
touch ${BROWSER_PROVIDER_READY_FILE}
6764
}
6865

69-
browserstack-tunnel/BrowserStackLocal -k $BROWSER_STACK_ACCESS_KEY $ARGS &>> $TUNNEL_LOG &
66+
browserstack-tunnel/BrowserStackLocal -k ${BROWSER_STACK_ACCESS_KEY} ${ARGS} 2>&1 >> ${TUNNEL_LOG} &
7067

7168
# Wait for the tunnel to be ready and create the readyfile with the Browserstack PID
7269
create_ready_file &

scripts/browserstack/wait-tunnel.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ while [ ! -f $BROWSER_PROVIDER_READY_FILE ]; do
2626
printf "."
2727
sleep .5
2828
done
29+
30+
echo ""
31+
echo "Connected to Browserstack"

scripts/saucelabs/start-tunnel.sh

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,39 @@
33
set -e -o pipefail
44

55
TUNNEL_FILE="sc-4.4.6-linux.tar.gz"
6-
TUNNEL_URL="https://saucelabs.com/downloads/$TUNNEL_FILE"
6+
TUNNEL_URL="https://saucelabs.com/downloads/${TUNNEL_FILE}"
77
TUNNEL_DIR="/tmp/saucelabs-connect"
88

9-
TUNNEL_LOG="$LOGS_DIR/sauce-connect"
9+
TUNNEL_LOG="${LOGS_DIR}/sauce-connect"
1010

11-
SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev`
11+
SAUCE_ACCESS_KEY=`echo ${SAUCE_ACCESS_KEY} | rev`
1212

1313
# Cleanup and create the folder structure for the tunnel connector.
14-
rm -rf $TUNNEL_DIR $BROWSER_PROVIDER_READY_FILE
15-
mkdir -p $TUNNEL_DIR
14+
rm -rf ${TUNNEL_DIR} ${BROWSER_PROVIDER_READY_FILE}
15+
mkdir -p ${TUNNEL_DIR}
1616

17-
cd $TUNNEL_DIR
17+
cd ${TUNNEL_DIR}
1818

1919
# Download the saucelabs connect binaries.
20-
curl $TUNNEL_URL -o $TUNNEL_FILE 2> /dev/null 1> /dev/null
20+
curl ${TUNNEL_URL} -o ${TUNNEL_FILE} 2> /dev/null 1> /dev/null
2121

2222
# Extract the saucelabs connect binaries from the tarball.
2323
mkdir -p sauce-connect
24-
tar --extract --file=$TUNNEL_FILE --strip-components=1 --directory=sauce-connect > /dev/null
24+
tar --extract --file=${TUNNEL_FILE} --strip-components=1 --directory=sauce-connect > /dev/null
2525

2626
# Cleanup the download directory.
27-
rm $TUNNEL_FILE
27+
rm ${TUNNEL_FILE}
2828

2929
ARGS=""
3030

3131
# Set tunnel-id only on Travis, to make local testing easier.
32-
if [ ! -z "$TRAVIS_JOB_ID" ]; then
33-
ARGS="$ARGS --tunnel-identifier $TRAVIS_JOB_ID"
32+
if [ ! -z "${TRAVIS_JOB_ID}" ]; then
33+
ARGS="${ARGS} --tunnel-identifier ${TRAVIS_JOB_ID}"
3434
fi
35-
if [ ! -z "$BROWSER_PROVIDER_READY_FILE" ]; then
36-
ARGS="$ARGS --readyfile $BROWSER_PROVIDER_READY_FILE"
35+
if [ ! -z "${BROWSER_PROVIDER_READY_FILE}" ]; then
36+
ARGS="${ARGS} --readyfile ${BROWSER_PROVIDER_READY_FILE}"
3737
fi
3838

39-
echo "Starting Sauce Connect in the background, logging into:"
40-
echo " $TUNNEL_LOG"
41-
echo " ---"
42-
echo " $ARGS"
39+
echo "Starting Sauce Connect in the background, logging into: ${TUNNEL_LOG}"
4340

44-
sauce-connect/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY $ARGS --logfile $TUNNEL_LOG &
41+
sauce-connect/bin/sc -u ${SAUCE_USERNAME} -k ${SAUCE_ACCESS_KEY} ${ARGS} 2>&1 >> ${TUNNEL_LOG} &

scripts/saucelabs/wait-tunnel.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/bin/bash
22

3-
# Wait for Connect to be ready before exiting
4-
echo "Connecting to Sauce Labs"
5-
6-
73
# Wait for Saucelabs Connect to be ready before exiting
84
# Time out if we wait for more than 2 minutes, so the process won't run forever.
95
let "counter=0"
@@ -12,7 +8,7 @@ while [ ! -f $BROWSER_PROVIDER_READY_FILE ]; do
128
let "counter++"
139

1410
if [ $counter -gt 240 ]; then
15-
echo
11+
echo ""
1612
echo "Timed out after 2 minutes waiting for tunnel ready file"
1713
exit 5
1814
fi
@@ -21,5 +17,5 @@ while [ ! -f $BROWSER_PROVIDER_READY_FILE ]; do
2117
sleep .5
2218
done
2319

24-
echo
25-
echo "Connected"
20+
echo ""
21+
echo "Connected to Saucelabs"

0 commit comments

Comments
 (0)