Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/types/yauzl-2.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess authored Oct 22, 2023
2 parents 756bb98 + 1adcded commit 7e28b3e
Show file tree
Hide file tree
Showing 3 changed files with 406 additions and 373 deletions.
62 changes: 36 additions & 26 deletions lib/setup-chromedriver.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
#!/bin/bash
#!/usr/bin/env bash

set -eo pipefail

CURL="curl --silent --location --fail --retry 10"
JSON_URL=https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json

VERSION=$1
ARCH=$2
VERSION="${1:-}"
ARCH="${2:-linux64}"

sudo=$(command -v sudo)

if [[ "${ARCH}" =~ ^linux64 ]]; then
CHROMEAPP=google-chrome
sudo=$(command -v sudo)
APP="${CHROMEAPP}"
if ! dpkg -s "${APP}" >/dev/null; then
${sudo} apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A040830F7FAC5991
echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" | ${sudo} tee /etc/apt/sources.list.d/google.list
APP=google-chrome-stable
fi
apps=()
test -z "${sudo}" && apps+=(sudo)
type -a curl > /dev/null 2>&1 || apps+=(curl)
type -a "${CHROMEAPP}" > /dev/null 2>&1 || apps+=("${APP}")
type -a jq > /dev/null 2>&1 || apps+=(jq)
type -a unzip > /dev/null 2>&1 || apps+=(unzip)
if (("${#apps[@]}")); then
echo "Installing ${apps[*]}..."
export DEBIAN_FRONTEND=noninteractive
${sudo} apt-get update
${sudo} apt-get install -y "${apps[@]}"
if command -v dpkg &>/dev/null; then
if ! dpkg -s "${APP}" >/dev/null; then
${sudo} apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A040830F7FAC5991
echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" | ${sudo} tee /etc/apt/sources.list.d/google.list >/dev/null
APP=google-chrome-stable
fi
apps=()
test -z "${sudo}" && apps+=(sudo)
type -a curl > /dev/null 2>&1 || apps+=(curl)
type -a "${CHROMEAPP}" > /dev/null 2>&1 || apps+=("${APP}")
type -a jq > /dev/null 2>&1 || apps+=(jq)
type -a unzip > /dev/null 2>&1 || apps+=(unzip)
if (("${#apps[@]}")); then
echo "Installing ${apps[*]}..."
export DEBIAN_FRONTEND=noninteractive
${sudo} apt-get update
${sudo} apt-get install -y --no-install-recommends "${apps[@]}"
fi
fi
fi

if [[ "${ARCH}" =~ ^mac64 ]]; then
CHROMEAPP="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
fi

if [[ "${VERSION}" ]]; then
if [[ -n "${VERSION}" ]]; then
CHROME_VERSION=$(cut -d '.' -f 1 <<<"${VERSION}")
else
CHROME_VERSION=$("${CHROMEAPP}" --version | cut -f 3 -d ' ' | cut -d '.' -f 1)
CHROME_VERSION=$("${CHROMEAPP}" --version | cut -d ' ' -f 3 | cut -d '.' -f 1)
fi
echo "CHROME_VERSION=${CHROME_VERSION}"

Expand All @@ -54,13 +57,13 @@ if ((CHROME_VERSION < 115)); then
echo "Downloading ${URL}..."
${CURL} -o chromedriver.zip "${URL}"
unzip -o -q chromedriver.zip
sudo mv chromedriver /usr/local/bin/chromedriver
${sudo} mv chromedriver /usr/local/bin/chromedriver
rm -f chromedriver.zip
exit
fi

if [[ -z "${VERSION}" ]]; then
VERSION=$("${CHROMEAPP}" --version | cut -f 3 -d ' ')
VERSION=$("${CHROMEAPP}" --version | cut -d ' ' -f 3)
echo "VERSION=${VERSION}"
fi
if [[ "${ARCH}" =~ ^mac64 ]]; then
Expand All @@ -73,7 +76,7 @@ JQ=".versions[] | select(.version == \"${VERSION}\") | .downloads.chromedriver[]
URL=$(jq -r "${JQ}" <<<"${JSON}")
if [[ -z "${URL}" ]]; then
echo "Falling back to latest version of ChromeDriver for ${ARCH}"
VERSION3=$(cut -d '.' -f1-3 <<<"${VERSION}")
VERSION3=$(cut -d '.' -f 1-3 <<<"${VERSION}")
echo "VERSION3=${VERSION3}"
JQ2="[ .versions[] | select(.version | startswith(\"${VERSION3}.\")) ] | last | .version"
VERSION=$(jq -r "${JQ2}" <<<"${JSON}")
Expand All @@ -85,5 +88,12 @@ echo "Installing ChromeDriver ${VERSION} for ${ARCH}"
echo "Downloading ${URL}..."
${CURL} -o chromedriver.zip "${URL}"
unzip -o -q chromedriver.zip
sudo mv "chromedriver-${ARCH}/chromedriver" /usr/local/bin/chromedriver
echo Installing chromedriver to /usr/local/bin
${sudo} mv "chromedriver-${ARCH}/chromedriver" /usr/local/bin/chromedriver
rm -fr chromedriver.zip chromedriver-*
if [[ -x "${CHROMEAPP}" ]]; then
echo Chrome version:
"${CHROMEAPP}" --version
fi
echo Chromedriver version:
/usr/local/bin/chromedriver --version
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@
"dependencies": {
"@actions/core": "1.10.1",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"@actions/github": "^6.0.0",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1",
"semver": "^7.5.4",
"typed-rest-client": "^1.8.11"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/node": "^20.5.1",
"@types/node": "^20.6.2",
"@types/selenium-webdriver": "^4.1.16",
"@types/semver": "^7.5.1",
"@types/yauzl": "^2.10.1",
"@vercel/ncc": "^0.36.1",
"@vercel/ncc": "^0.38.0",
"husky": "^8.0.3",
"jest": "^27.5.1",
"jest-circus": "^29.6.3",
"prettier": "^3.0.2",
"jest-circus": "^29.7.0",
"prettier": "^3.0.3",
"selenium-webdriver": "^4.11.1",
"ts-jest": "^27.1.3",
"ts-node": "^10.9.1",
Expand Down
Loading

0 comments on commit 7e28b3e

Please sign in to comment.