diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 19:47:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 19:47:39 +0000 |
commit | 8d13bdc6cac0e20c43c6f909fc0208774b9c5c84 (patch) | |
tree | 5fd46925c6b4a881c9208772ed8e5cc0588bc164 /scripts/setup_travis.sh | |
parent | Initial commit. (diff) | |
download | privacybadger-8d13bdc6cac0e20c43c6f909fc0208774b9c5c84.tar.xz privacybadger-8d13bdc6cac0e20c43c6f909fc0208774b9c5c84.zip |
Adding upstream version 2020.10.7.upstream/2020.10.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/setup_travis.sh')
-rwxr-xr-x | scripts/setup_travis.sh | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/scripts/setup_travis.sh b/scripts/setup_travis.sh new file mode 100755 index 0000000..5e4bbf0 --- /dev/null +++ b/scripts/setup_travis.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# stop on errors (nonzero exit codes), uninitialized vars +set -eu + +toplevel=$(git rev-parse --show-toplevel) + +function setup_firefox { + # Install the latest version of geckodriver + version=$(curl -sI https://github.com/mozilla/geckodriver/releases/latest | grep -i "^Location: " | sed 's/.*\///' | tr -d '\r') + + # check that we got something + if [ -z "$version" ]; then + echo "Failed to determine the latest geckodriver version!" + exit 1 + fi + + # Geckodriver distribution is MacOS or Linux specific + os="$(uname -s)" + if [[ $os == "Darwin" ]]; then + os_dist="macos.tar.gz" + else + os_dist="linux64.tar.gz" + fi + + echo "Setting up geckodriver version $version ..." + url="https://github.com/mozilla/geckodriver/releases/download/${version}/geckodriver-${version}-${os_dist}" + wget -q -O /tmp/geckodriver.tar.gz "$url" + sudo tar -xvf /tmp/geckodriver.tar.gz -C /usr/local/bin/ + sudo chmod a+x /usr/local/bin/geckodriver + + # check that geckodriver is now present + type geckodriver >/dev/null 2>&1 || { + echo "Failed to install geckodriver!" + exit 1 + } +} + +function browser_setup { + # install python stuff + pip install -r "$toplevel"/tests/requirements.txt +} + +function setup_lint { + # "--production" to skip installing devDependencies modules + npm install --production || exit 1 +} + +# check that the desired browser is present as it might fail to install +# for example: https://travis-ci.org/EFForg/privacybadger/jobs/362381214 +function check_browser { + type "$BROWSER" >/dev/null 2>&1 || { + echo "$BROWSER seems to be missing!" + exit 1 + } + + # print the version + echo "Found $("$BROWSER" --version)" +} + +case $INFO in + *chrome*) + check_browser + "$toplevel"/scripts/chromedriver.sh "$BROWSER" + browser_setup + ;; + *firefox*) # Install the latest version of geckodriver + check_browser + setup_firefox + browser_setup + ;; + *lint*) + setup_lint + ;; + *) + echo "bad INFO variable, got $INFO" + exit 1 + ;; +esac |