Skip to content

Commit

Permalink
Merge pull request #3775 from Spuds/PWA
Browse files Browse the repository at this point in the history
PWA App
  • Loading branch information
Spuds committed Mar 30, 2024
2 parents f9d3d6a + 6d9ab46 commit da87155
Show file tree
Hide file tree
Showing 28 changed files with 1,506 additions and 87 deletions.
7 changes: 7 additions & 0 deletions .github/setup-elkarte.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ then
composer remove phpunit/phpunit phpunit/phpunit-selenium --dev
composer require phpunit/phpunit:9.3.11 phpunit/phpunit-selenium:9.0.1 --dev --update-with-all-dependencies --ignore-platform-reqs
fi

# Provide a way to return from actions redirectexit & obexit, so we can get results for Unit Test
if [[ "$WEBSERVER" == "none" ]]
then
sudo sed -i '/global $db_show_debug;/a \\n\tif (defined("PHPUNITBOOTSTRAP") && defined("STDIN")){return $setLocation;}' ./sources/Subs.php
sudo sed -i '/call_integration_hook('"'"'integrate_exit'"'"', \[$do_footer\]);/a \\n\tif (defined("PHPUNITBOOTSTRAP") && defined("STDIN")){return;}' ./sources/Subs.php
fi
60 changes: 8 additions & 52 deletions .github/setup-selenium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +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='110.0.5481.100-1' # '91.0.4472.114-1'

wget https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb -q
sudo dpkg -i google-chrome-stable_${CHROME_VERSION}_amd64.deb

# Download Chrome Driver
echo "Downloading chromedriver"
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 @@ -77,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 @@ -41,7 +41,7 @@ jobs:
- name: Checkout ElkArte
uses: actions/checkout@v4
with:
repository: Spuds/Elkarte
repository: elkarte/elkarte
fetch-depth: 10
ref: ${{ env.ELKARTE_BRANCH }}
path: elkarte
Expand Down 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 Down
28 changes: 28 additions & 0 deletions elkManifest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* This simply returns the manifest json info as generated by the manifest controller
*
* @package ElkArte Forum
* @copyright ElkArte Forum contributors
* @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
*
* @version 2.0 dev
*
*/

global $ssi_guest_access;

// Need to bootstrap to do much
use ElkArte\ManifestMinimus;

require_once(__DIR__ . '/bootstrap.php');
$ssi_guest_access = true;
new Bootstrap(true);

// Our Manifest controller
$controller = new ManifestMinimus();
$controller->create();

// Always exit as successful
exit(0);

0 comments on commit da87155

Please sign in to comment.