Skip to content

Commit 87bfa23

Browse files
authored
chore: update chrome for testing to display clearer error messages when version is omitted. Also allow chromedriver to optionally be installed. Defaults to true to avoid a breaking change (#137)
1 parent bc17c13 commit 87bfa23

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

src/commands/install_chrome_for_testing.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@ description: >
44
https://developer.chrome.com/blog/chrome-for-testing/
55
66
parameters:
7+
version:
8+
type: string
9+
description: >
10+
Which version to install. No default version provided, you must specify the one you want.
11+
712
install_dir:
813
type: string
914
default: /usr/local/bin
1015
description: >
1116
Directory in which to download chrome and the driver.
1217
13-
version:
14-
type: string
15-
default: ""
18+
install_chromedriver:
19+
type: boolean
20+
default: true
1621
description: >
17-
Which version to install. No default version provided, you must specify the one you want.
22+
Whether or not to install Chrome for Testing chromedriver alongside Chrome for Testing
1823
steps:
1924
- run:
2025
name: Install Chrome for testing
2126
environment:
2227
ORB_PARAM_DIR: <<parameters.install_dir>>
2328
ORB_PARAM_VERSION: <<parameters.version>>
29+
ORB_PARAM_INSTALL_CHROMEDRIVER: <<parameters.install_chromedriver>>
2430
command: <<include(scripts/install_chrome_for_testing.sh)>>
Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
#!/bin/bash
22
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
33

4-
cd "$ORB_PARAM_DIR" || exit 1
4+
cd "$ORB_PARAM_DIR" || { echo "$ORB_PARAM_DIR does not exist. Exiting"; exit 1; }
5+
6+
if [ -z "$ORB_PARAM_VERSION" ]; then
7+
echo "ORB_PARAM_VERSION is not set. Exiting."
8+
exit 1
9+
fi
510

611
if uname -a | grep Darwin >/dev/null 2>&1; then
7-
$SUDO wget -q -O chrome-for-testing.zip "https://storage.googleapis.com/chrome-for-testing-public/$ORB_PARAM_VERSION/mac-arm64/chrome-mac-arm64.zip"
12+
$SUDO curl -s -o chrome-for-testing.zip "https://storage.googleapis.com/chrome-for-testing-public/$ORB_PARAM_VERSION/mac-arm64/chrome-mac-arm64.zip"
813
if [ -s "chrome-for-testing.zip" ]; then
914
$SUDO unzip chrome-for-testing.zip >/dev/null 2>&1
1015
else
1116
echo "Version $ORB_PARAM_VERSION doesn't exist"
1217
exit 1
1318
fi
14-
$SUDO wget -q -O chrome-for-testing-driver.zip "https://storage.googleapis.com/chrome-for-testing-public/$ORB_PARAM_VERSION/mac-arm64/chromedriver-mac-arm64.zip"
15-
$SUDO unzip chrome-for-testing-driver.zip >/dev/null 2>&1
16-
$SUDO mv chromedriver-mac-arm64/chromedriver chromedriver
19+
20+
if [ "$ORB_PARAM_INSTALL_CHROMEDRIVER" = true ] ; then
21+
$SUDO curl -s -o chrome-for-testing-driver.zip "https://storage.googleapis.com/chrome-for-testing-public/$ORB_PARAM_VERSION/mac-arm64/chromedriver-mac-arm64.zip"
22+
$SUDO unzip chrome-for-testing-driver.zip >/dev/null 2>&1
23+
$SUDO mv chromedriver-mac-arm64/chromedriver chromedriver
24+
fi
1725
elif command -v apt >/dev/null 2>&1; then
18-
$SUDO wget -q -O chrome-for-testing.zip "https://storage.googleapis.com/chrome-for-testing-public/$ORB_PARAM_VERSION/linux64/chrome-linux64.zip"
26+
$SUDO curl -s -o chrome-for-testing.zip "https://storage.googleapis.com/chrome-for-testing-public/$ORB_PARAM_VERSION/linux64/chrome-linux64.zip"
1927
if [ -s "chrome-for-testing.zip" ]; then
2028
$SUDO unzip chrome-for-testing.zip >/dev/null 2>&1
2129
else
@@ -27,15 +35,22 @@ elif command -v apt >/dev/null 2>&1; then
2735
$SUDO apt-get satisfy -y --no-install-recommends "${pkg}";
2836
done < chrome-linux64/deb.deps;
2937

30-
$SUDO wget -q -O chrome-for-testing-driver.zip "https://storage.googleapis.com/chrome-for-testing-public/$ORB_PARAM_VERSION/linux64/chromedriver-linux64.zip"
31-
$SUDO unzip chrome-for-testing-driver.zip >/dev/null 2>&1
32-
$SUDO mv chromedriver-linux64/chromedriver chromedriver
38+
if [ "$ORB_PARAM_INSTALL_CHROMEDRIVER" = true ] ; then
39+
$SUDO curl -s -o chrome-for-testing-driver.zip "https://storage.googleapis.com/chrome-for-testing-public/$ORB_PARAM_VERSION/linux64/chromedriver-linux64.zip"
40+
$SUDO unzip chrome-for-testing-driver.zip >/dev/null 2>&1
41+
$SUDO mv chromedriver-linux64/chromedriver chromedriver
42+
fi
3343
fi
34-
$SUDO chmod +x chromedriver
3544

36-
if chromedriver --version | grep "$ORB_PARAM_VERSION" >/dev/null 2>&1; then
37-
echo "Chrome for testing installed correctly"
38-
else
39-
echo "Error installing Chrome for testing"
40-
exit 1
45+
if [ "$ORB_PARAM_INSTALL_CHROMEDRIVER" = true ] ; then
46+
$SUDO chmod +x chromedriver
4147
fi
48+
49+
if [ "$ORB_PARAM_INSTALL_CHROMEDRIVER" = true ] ; then
50+
if chromedriver --version | grep "$ORB_PARAM_VERSION" >/dev/null 2>&1; then
51+
echo "chromedriver for Chrome for testing installed correctly"
52+
else
53+
echo "Error installing Chrome for testing"
54+
exit 1
55+
fi
56+
fi

0 commit comments

Comments
 (0)