Skip to content

Commit

Permalink
Support Chrome for Testing on *NIX
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Jul 26, 2023
1 parent 46e6b17 commit 1b5834d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 9 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
matrix:
os: [ ubuntu-latest, ubuntu-20.04, macos-latest, macos-11 ]
branch: [ 'master', 'now' ]
chrome_version: [ 'current', '114.0.5735.90' ]
steps:
- uses: actions/checkout@v3
- if: startsWith(matrix.os, 'ubuntu')
Expand All @@ -37,9 +38,16 @@ jobs:
node_modules/.bin/tsc $GITHUB_WORKSPACE/__tests__/chromedriver.ts
node_modules/.bin/ncc build $GITHUB_WORKSPACE/__tests__/chromedriver.js -o $GITHUB_WORKSPACE/__tests__
rm -rf node_modules
- run: |
CHROME_VERSION=$("$CHROMEAPP" --version | cut -f 3 -d ' ' | cut -d '.' -f 1)
- if: matrix.chrome_version != 'current'
env:
CHROME_VERSION: ${{ matrix.chrome_version }}
run: |
CHROME_VERSION=$(echo $CHROME_VERSION | cut -d '.' -f 1)
echo "CHROMEDRIVER_VERSION=$(curl --location --fail --retry 10 http://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION})" >> $GITHUB_ENV
- if: matrix.chrome_version == 'current'
run: |
CHROME_VERSION=$("$CHROMEAPP" --version | cut -f 3 -d ' ')
echo "CHROMEDRIVER_VERSION=$CHROME_VERSION" >> $GITHUB_ENV
- uses: ./
if: matrix.branch == 'now'
with:
Expand Down
49 changes: 42 additions & 7 deletions lib/setup-chromedriver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,55 @@ ARCH=$2

if [ "$ARCH" == "linux64" ]; then
CHROMEAPP=google-chrome
if ! type -a sudo > /dev/null 2>&1; then
apt-get update
apt-get install -y sudo
fi
if ! type -a curl > /dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y curl
fi
if ! type -a google-chrome > /dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y google-chrome
fi
if ! type -a jq > /dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y jq
fi
if ! type -a bc > /dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y bc
fi
elif [ "$ARCH" == "mac64" ]; then
CHROMEAPP="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
fi
CHROME_VERSION=$("$CHROMEAPP" --version | cut -f 3 -d ' ' | cut -d '.' -f 1)
UNDER115=$(echo "$CHROME_VERSION > 115" | bc)
if [ "$UNDER115" -eq 1 ]; then
if [ "$VERSION" == "" ]; then
VERSION=$(curl --location --fail --retry 10 http://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION})
fi
echo "Installing ChromeDriver $VERSION for $ARCH"

curl --location --fail --retry 10 -O https://chromedriver.storage.googleapis.com/${VERSION}/chromedriver_${ARCH}.zip
unzip -o -q chromedriver_${ARCH}.zip
rm chromedriver_${ARCH}.zip
else
if [ "$VERSION" == "" ]; then
VERSION=$("$CHROMEAPP" --version | cut -f 3 -d ' ')
fi
if [ "$ARCH" == "mac64" ]; then
ARCH="mac-x64"
fi

if [ "$VERSION" == "" ]; then
CHROME_VERSION=$("$CHROMEAPP" --version | cut -f 3 -d ' ' | cut -d '.' -f 1)
VERSION=$(curl --location --fail --retry 10 http://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION})
echo "Installing ChromeDriver $VERSION for $ARCH"
URL=$(curl --location --fail --retry 10 https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json | jq -r ".versions[] | select(.version == \"${VERSION}\") | .downloads.chromedriver[] | select(.platform == \"${ARCH}\") | .url")
echo "Downloading $URL"
curl --location --fail --retry 10 -O "$URL"
unzip -o -q chromedriver-${ARCH}.zip
sudo mv chromedriver /usr/local/bin/chromedriver
rm chromedriver-${ARCH}.zip
fi

wget -c -nc --retry-connrefused --tries=0 https://chromedriver.storage.googleapis.com/${VERSION}/chromedriver_${ARCH}.zip
unzip -o -q chromedriver_${ARCH}.zip
sudo mv chromedriver /usr/local/bin/chromedriver
rm chromedriver_${ARCH}.zip

0 comments on commit 1b5834d

Please sign in to comment.