Skip to content

Commit

Permalink
! try actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Spuds committed Mar 30, 2024
1 parent e5a5f83 commit 82cd0f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 52 deletions.
59 changes: 8 additions & 51 deletions .github/setup-selenium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,15 @@
set -e
set -x

# Access passed params
DB=$1
PHP_VERSION=$2

# Some vars to make this easy to change
SELENIUM_HUB_URL='http://127.0.0.1:4444'
SELENIUM_JAR=/usr/share/selenium/selenium-server-standalone.jar
SELENIUM_DOWNLOAD_URL=https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar

# Location of geckodriver for use as webdriver in xvfb
GECKODRIVER_DOWNLOAD_URL=https://github.com/mozilla/geckodriver/releases/download/v0.29.1/geckodriver-v0.29.1-linux64.tar.gz
GECKODRIVER_TAR=/tmp/geckodriver.tar.gz

# Location of chromedriver for use as webdriver in xvfb
CHROMEDRIVER_ZIP=/tmp/chromedriver_linux64.zip

# Download Selenium
echo "Downloading Selenium"
sudo mkdir -p $(dirname "$SELENIUM_JAR")
sudo wget -nv -O "$SELENIUM_JAR" "$SELENIUM_DOWNLOAD_URL"

# Install Fx or Chrome
echo "Installing Browser"
# sudo apt install firefox -y -qq > /dev/null
# Available Chrome Versions
# https://www.ubuntuupdates.org/package/google_chrome/stable/main/base/google-chrome-stable?id=202706
# Per actions in the tests.yaml file
#
CHROME_VERSION='113.0.5672.63-1' #'110.0.5481.100-1' # '91.0.4472.114-1'
wget -v -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
sudo dpkg -i /tmp/chrome.deb

# Download Chrome Driver
echo "Downloading Browser Driver"
CHROME_VERSION=$(google-chrome --version | cut -f 3 -d ' ' | cut -d '.' -f 1) \
&& CHROMEDRIVER_RELEASE=$(curl --location --fail --retry 3 https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}) \
&& wget -nv -O "$CHROMEDRIVER_ZIP" "https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_RELEASE/chromedriver_linux64.zip" \
&& unzip "$CHROMEDRIVER_ZIP" \
&& rm -rf "$CHROMEDRIVER_ZIP" \
&& sudo mv chromedriver /usr/local/bin/chromedriver \
&& sudo chmod +x /usr/local/bin/chromedriver \
&& chromedriver --version
# Current Versions for Ref
# Selenium 3.141.59 jar
# Chrome 123.0.6312.58
# ChromeDriver 123.0.6312.58

# Download Gecko driver
#echo "Downloading geckodriver"
#wget -nv -O "$GECKODRIVER_TAR" "$GECKODRIVER_DOWNLOAD_URL" \
# && sudo tar -xvf "$GECKODRIVER_TAR" -C "/usr/local/bin/" \
# && sudo chmod +x /usr/local/bin/geckodriver \
# && geckodriver --version

# Start Selenium using default chosen webdriver
export DISPLAY=:99.0
xvfb-run --server-args="-screen 0, 2560x1440x24" java -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver -jar "$SELENIUM_JAR" > /tmp/selenium.log &
echo "Ensuring Selenium Started"
SELENIUM_HUB_URL='http://127.0.0.1:4444'
wget --retry-connrefused --tries=120 --waitretry=3 --output-file=/dev/null "$SELENIUM_HUB_URL/wd/hub/status" -O /dev/null

# Test to see if the selenium server really did start
Expand All @@ -76,7 +33,7 @@ else
# Copy RemoteCoverage.php back to vendor, this version supports phpunit RawCodeCoverageData
sudo cp ./tests/RemoteCoverage.php ./vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon

# This keeps triggering in tests for the 2 second rule
# This keeps triggering in tests for the 2 second rule, lets try to fix that
sudo sed -i -e "s|spamProtection('login');|//spamProtection('login');|g" ./sources/ElkArte/Controller/Auth.php

# Run the phpunit selenium tests
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ jobs:
run: .github/setup-elkarte.sh $DB $PHP_VERSION
working-directory: ./elkarte

- name: Download Selenium
run: |
sudo mkdir -p /usr/share/selenium
wget -nv -O /usr/share/selenium/selenium-server-standalone.jar https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar
sudo chmod 777 /usr/share/selenium/selenium-server-standalone.jar
- name: Setup ChromeDriver
uses: nanasess/setup-chromedriver@v2

- name: Start ChromeDriver
run: |
export DISPLAY=:99.0
xvfb-run --server-args="-screen 0, 2560x1440x24" java -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver -jar /usr/share/selenium/selenium-server-standalone.jar > /tmp/selenium.log &
- name: Run Unit Tests
env:
DB: ${{ matrix.db }}
Expand All @@ -93,7 +107,7 @@ jobs:
run: |
sudo cat /var/log/nginx/127.0.0.1.error.log
sudo cat /tmp/php_errors.log
# sudo cat /tmp/selenium.log
sudo cat /tmp/selenium.log
.github/setup-failure.sh $DB $PHP_VERSION
working-directory: ./elkarte
# End Selenium headless browser testing
Expand Down

0 comments on commit 82cd0f6

Please sign in to comment.