Skip to content

Improved gltrans descriptions using $_SESSION['StandardCostDecimalPla… #728

Improved gltrans descriptions using $_SESSION['StandardCostDecimalPla…

Improved gltrans descriptions using $_SESSION['StandardCostDecimalPla… #728

Workflow file for this run

name: Continuous Integration
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.operating-system }}
strategy:
# Do not halt all tests in the matrix if one fails
fail-fast: false
# Define a list of test environments to run the test suite in
matrix:
include:
# @see https://github.com/actions/runner-images
# @todo run some tests on 'windows-latest' (no need to try testing on macs: those runners are never
# available on the github cloud, at least for free plans)
# NB: the order of options is picked to make the github page display nicer (test naming in left col)
- php: '8.5'
dbtype: mysql
dbversion: latest
operating-system: ubuntu-24.04
dbport: 3306
- php: '8.4'
dbtype: mysql
# Using 'native' version will result in the mysql service on the host to be used.
# For Ubuntu 22.04 and 24.04 runners, that is mysql 8.0.43
dbversion: native
operating-system: ubuntu-24.04
dbport: 3306
- php: '8.3'
dbtype: mariadb
dbversion: 'latest'
operating-system: ubuntu-24.04
dbport: 3306
- php: '8.2'
dbtype: mysql
dbversion: '5.7'
operating-system: ubuntu-22.04
dbport: 3307
- php: '8.1'
dbtype: mariadb
dbversion: '5.5'
operating-system: ubuntu-22.04
dbport: 3307
# NB: we do not run docker containers using the native `services` tag because we have to mount one or more files
# from the local filesystem to the containers (eg. the db config), and doing so breaks actions/checkout@v5
steps:
- run: echo 'Job was automatically triggered by a ${{ github.event_name }} event'
- run: echo 'Job is now running on a ${{ runner.os }} server'
- run: echo 'Branch is ${{ github.ref }} and Repository is ${{ github.repository }}'
- run: echo "Current directory is ${{ github.workspace }}, current user is $(id -u -n)"
# has to be run before setting up the db and webserver, as we store their config files in the codebase
# @todo this way of checking out the code somehow breaks the build script `run_composer.sh`. We should
# figure out how to fix that - or plain replace this with a `git clone` command
- name: Check out repository code
uses: actions/checkout@v5
- name: Install required packages
run: |
chmod 755 ./tests/setup/setup_packages.sh
sudo ./tests/setup/setup_packages.sh
- name: Set up the database
run: |
chmod 755 ./tests/setup/setup_db.sh
./tests/setup/setup_db.sh -t '${{ matrix.dbtype }}' -v '${{ matrix.dbversion }}' -P '${{ matrix.dbport }}'
- name: Stop php-fpm if running
run: |
if ps auxwww | fgrep -q php-fpm; then
PHPVER=$(php -r 'echo implode(".",array_slice(explode(".",PHP_VERSION),0,2));' 2>/dev/null)
sudo service "php${PHPVER}-fpm" stop || sudo pkill php-fpm
fi
- name: Set up the required php version
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
extensions: bcmath, calendar, curl, ftp, gd, gettext, iconv, mbstring, mysqli, simplexml, sqlite3, xdebug, xml, zip, zlib
ini-values: 'auto_prepend_file=${{ github.workspace }}/tests/setup/config/php/auto_prepend.php'
# Alternative version
#run: |
# chmod 755 ./tests/setup/setup_php.sh
# ./tests/setup/setup_php.sh
# This is required to make fpm take into account the php.ini settings added by shivammathur/setup-php
- name: Restart php-fpm
run: sudo service 'php${{ matrix.php }}-fpm' restart
# Composer latest is installed by shivammathur/setup-php - no need for manual install
#- name: Set up Composer
# run: |
# chmod 755 ./tests/setup/setup_composer.sh
# ./tests/setup/setup_composer.sh
- name: Set up the webserver
# @todo we should set up either nginx or apache depending on the matrix combination
run: |
chmod 755 ./tests/setup/setup_webserver.sh
./tests/setup/setup_webserver.sh
# We run the release-preparing script before messing up the vendor/ dir to run the test suite (except
# for the step of dumping the database, as the db schema has not yet been created, and for the step
# checking php syntax, as that is tested by the unit test requesting every web page)
- name: Test the release-preparing script (run it)
run: |
chmod 755 ./build/make_release.sh
./build/make_release.sh -s check_php,dump_db
- name: Install dev dependencies
run: |
chmod 755 ./tests/setup/setup_dependencies.sh
./tests/setup/setup_dependencies.sh
- name: Set up phpunit configuration
run: |
cp phpunit.dist.xml phpunit.xml
if [ -n '${{ matrix.dbtype }}' ] && [ '${{ matrix.dbtype }}' != mysql ]; then
sed -r -i -e 's|<env name="TEST_DB_TYPE" value="mysqli" />|<env name="TEST_DB_TYPE" value="${{ matrix.dbtype }}" />|' phpunit.xml
fi
if [ -n "${{ matrix.dbport }}" ]; then
sed -r -i -e 's|<env name="TEST_DB_PORT" value="3306" />|<env name="TEST_DB_PORT" value="${{ matrix.dbport }}" />|' phpunit.xml
fi
# Make sure Apache can access the installation in its current dir.
# We set the installation to be fully writeable to anyone - this is a test install anyway
# @todo the `/home/runner` path should not be hardcoded. Figure out if we can get if from some GH param
- name: Fix filesystem permissions
run: |
sudo chmod g+rx,o+rx /home/
sudo chmod -R g+rwX,o+rwX /home/runner/
#- name: Smoke testing
# run: |
# curl -L --fail-with-body http://localhost/images/default_logo.jpg
# echo
# curl -L --fail-with-body http://localhost/index.php
- name: Run the test suite
run: |
./vendor/bin/phpunit --stop-on-failure tests/install
echo
./vendor/bin/phpunit tests/run
# @todo this test always uses the mysql and mysqldump cli tools from the host computer/image. It would be
# nice to also run the dump_database.sh script using the cli tools from the db version being tested
- name: Test the db-dumping script (run it)
run: |
export MYSQL_HOST=127.0.0.1
export MYSQL_PORT='${{ matrix.dbport }}'
export MYSQL_DATABASE=weberp
chmod 755 ./build/dump_database.sh
./build/dump_database.sh -o ./install/sql demo
- name: Failure troubleshooting
if: ${{ failure() }}
run: |
#echo '### running processes'
#ps auxwww | grep -E -v '^root .+:[0-9]{2} \[' | grep -v ' grep'
#echo
#sudo systemctl status mysql.service
#echo
#sudo systemctl status apache2.service
#echo '### fpm socket(s)'
#ls -la /run/php/
#echo
#php -i
#echo
#sudo ls -la /var/log/apache2/
#echo
#sudo cat /var/log/apache2/error.log
#echo
#echo '### apache access log'
#sudo cat /var/log/apache2/access.log
#echo
# failed phpunit tests might have saved to disk the html contents of the failing pages. Show them
if [ -n "$(ls webpage_failing_*.html 2>/dev/null)" ]; then
for PAGE in webpage_failing_*.html; do
echo "### output of failed test $PAGE"
echo
cat "$PAGE"
echo
done
fi