Skip to content

Commit 800b42f

Browse files
committed
Whooops sauce_connect wasnt spinning up if cache hit, add OSX support
1 parent 39dc933 commit 800b42f

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ jobs:
3333
${{ runner.os }}-14-node_modules-
3434
- name: NPM install
3535
if: steps.node_modules_cache.outputs.cache-hit != 'true'
36-
# Start sauce connect here, so it's ready to go by the time we need it
37-
run: |
38-
npm ci
39-
./buildtools/sauce_connect.sh &
36+
run: npm ci
4037
- name: Build & run tests
4138
run: npm run test
4239
- name: Run tests in Saucelabs
43-
run: ./buildtools/run_tests.sh --saucelabs
40+
run: |
41+
./buildtools/sauce_connect.sh &
42+
./buildtools/run_tests.sh --saucelabs

buildtools/run_tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ if [[ $1 = "--saucelabs" ]]; then
7676
seleniumStarted=false
7777
sleep 2
7878
echo "Using SauceLabs."
79+
until [ -f '/tmp/sauce-connect-ready' ]
80+
do
81+
sleep 2
82+
done
7983
# $2 contains the tunnelIdentifier argument if specified, otherwise is empty.
8084
$PROTRACTOR_BIN_PATH/protractor protractor.conf.js --saucelabs $2
8185
fi

buildtools/sauce_connect.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
#
2323

2424
# Setup and start Sauce Connect locally.
25-
CONNECT_URL="https://saucelabs.com/downloads/sc-4.6.5-linux.tar.gz"
25+
if [[ $OSTYPE == 'darwin'* ]]; then
26+
CONNECT_URL="https://saucelabs.com/downloads/sc-4.7.1-osx.zip"
27+
else
28+
CONNECT_URL="https://saucelabs.com/downloads/sc-4.7.1-linux.tar.gz"
29+
fi
2630
CONNECT_DIR="/tmp/sauce-connect-$RANDOM"
2731
CONNECT_DOWNLOAD="sc-latest-linux.tar.gz"
2832

@@ -33,8 +37,17 @@ mkdir -p $CONNECT_DIR
3337
cd $CONNECT_DIR
3438
curl $CONNECT_URL -o $CONNECT_DOWNLOAD 2> /dev/null 1> /dev/null
3539
mkdir sauce-connect
36-
tar --extract --file=$CONNECT_DOWNLOAD --strip-components=1 \
40+
41+
if [[ $OSTYPE == 'darwin'* ]]; then
42+
unzip -d sauce-connect $CONNECT_DOWNLOAD &&
43+
f=(sauce-connect/*) &&
44+
mv sauce-connect/*/* sauce-connect &&
45+
rmdir "${f[@]}"
46+
else
47+
tar --extract --file=$CONNECT_DOWNLOAD --strip-components=1 \
3748
--directory=sauce-connect > /dev/null
49+
fi
50+
3851
rm $CONNECT_DOWNLOAD
3952

4053
function removeFiles() {
@@ -63,4 +76,4 @@ echo "Starting Sauce Connect..."
6376

6477
# Start SauceConnect.
6578
sauce-connect/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY \
66-
-i $TUNNEL_IDENTIFIER
79+
-i $TUNNEL_IDENTIFIER -f $BROWSER_PROVIDER_READY_FILE

0 commit comments

Comments
 (0)