From 1ce024d148655c88b65aa2b051f1bf5658a10d9c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Sat, 11 Dec 2021 10:25:21 +0900 Subject: [PATCH] Revert "Remove to sudo" --- .github/workflows/test.yml | 48 +++++--------------------------------- __tests__/chromedriver.py | 8 +------ lib/setup-chromedriver.sh | 28 ++++------------------ 3 files changed, 12 insertions(+), 72 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3787ed25..2a0c9aed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: @@ -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 diff --git a/__tests__/chromedriver.py b/__tests__/chromedriver.py index 786c85d4..e4653ea6 100644 --- a/__tests__/chromedriver.py +++ b/__tests__/chromedriver.py @@ -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! diff --git a/lib/setup-chromedriver.sh b/lib/setup-chromedriver.sh index 24065355..a2cf18e5 100755 --- a/lib/setup-chromedriver.sh +++ b/lib/setup-chromedriver.sh @@ -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" @@ -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