Skip to content

Commit

Permalink
Merge pull request #36 from nanasess/revert-33-remove-sudo
Browse files Browse the repository at this point in the history
Revert "Remove to sudo"
  • Loading branch information
nanasess authored Dec 11, 2021
2 parents 088821f + 1ce024d commit df42850
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 72 deletions.
48 changes: 6 additions & 42 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- name: setup
run: |
sudo pip3 install selenium
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # disable headless mode
python3 $GITHUB_WORKSPACE/__tests__/chromedriver.py
test_default_version:
Expand All @@ -62,46 +65,7 @@ jobs:
run: |
"$CHROMEAPP" --version
sudo pip3 install selenium
python3 $GITHUB_WORKSPACE/__tests__/chromedriver.py
test_slim_image:
runs-on: ubuntu-latest
container:
image: debian:stable-slim
steps:
- run: |
apt-get update
apt-get install -y curl
curl -fsSL https://deb.nodesource.com/setup_17.x | bash -
curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
apt install -y ./google-chrome-stable_current_amd64.deb
apt-get install -y nodejs python3-pip
- uses: actions/checkout@v2
- run: npm ci
- run: npm test
- run: |
CHROME_VERSION=$(google-chrome --version | cut -f 3 -d ' ' | cut -d '.' -f 1)
echo "CHROMEDRIVER_VERSION=$(curl --location --fail --retry 10 http://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION})" >> $GITHUB_ENV
- uses: ./
with:
chromedriver-version: ${{ env.CHROMEDRIVER_VERSION }}
- name: setup
run: |
pip3 install selenium
python3 $GITHUB_WORKSPACE/__tests__/chromedriver.py
test_slim_image_default_version:
runs-on: ubuntu-latest
container:
image: debian:stable-slim
steps:
- run: |
apt-get update
apt-get install -y python3-pip
- uses: actions/checkout@v2
- uses: ./
- name: setup
run: |
google-chrome --version
pip3 install selenium
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # disable headless mode
python3 $GITHUB_WORKSPACE/__tests__/chromedriver.py
8 changes: 1 addition & 7 deletions __tests__/chromedriver.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')
options.add_argument('--disable-extensions')
driver = webdriver.Chrome(options=options) # Optional argument, if not specified will search path.
driver = webdriver.Chrome() # Optional argument, if not specified will search path.
driver.get('http://www.google.com/');
print(driver.title)
time.sleep(5) # Let the user actually see something!
Expand Down
28 changes: 5 additions & 23 deletions lib/setup-chromedriver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,12 @@ set -eo pipefail

VERSION=$1
ARCH=$2
SUDO=
if command -v sudo &> /dev/null
then
SUDO=$(echo command -v sudo)
fi

if [ "$ARCH" == "linux64" ]; then
if ! type -a gnupg > /dev/null 2>&1; then
$SUDO apt-get update
$SUDO apt-get install -y gnupg
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
curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | $SUDO apt-key add -
curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
$SUDO apt install -y ./google-chrome-stable_current_amd64.deb
fi
CHROMEAPP=google-chrome
if ! type -a unzip > /dev/null 2>&1; then
$SUDO apt-get update
$SUDO apt-get install -y unzip
if ! type -a google-chrome > /dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y google-chrome
fi
elif [ "$ARCH" == "mac64" ]; then
CHROMEAPP="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
Expand All @@ -38,7 +20,7 @@ if [ "$VERSION" == "" ]; then
VERSION=$(curl --location --fail --retry 10 http://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION})
fi

curl --location --fail --retry 10 -O https://chromedriver.storage.googleapis.com/${VERSION}/chromedriver_${ARCH}.zip
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
sudo mv chromedriver /usr/local/bin/chromedriver
rm chromedriver_${ARCH}.zip

0 comments on commit df42850

Please sign in to comment.