Messenger: added new Mailing List feature #86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Tests | |
on: | |
pull_request: | |
push: | |
jobs: | |
test: | |
name: ${{ matrix.name }} (PHP ${{ matrix.php-version }}) | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
php-version: ["7.4", "8.0", "8.1", "8.2", "8.3"] | |
experimental: [false] | |
name: ["CI Test"] | |
services: | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
MYSQL_DATABASE: gibbon_test | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Setup PHP ${{ matrix.php-version }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
extensions: gettext, gd, zip, pdo-mysql, intl | |
tools: composer:v2 | |
ini-values: date.timezone="Etc/UTC", xdebug.max_nesting_level=-1, opcache.jit="off" | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
fetch-depth: 0 | |
- name: Setup System Locale | |
run: | | |
cat <<- EOF | | |
en_US.UTF-8 UTF-8 | |
en_GB.UTF-8 UTF-8 | |
es_ES.UTF-8 UTF-8 | |
fr_FR.UTF-8 UTF-8 | |
zh_TW.UTF-8 UTF-8 | |
EOF | |
sudo tee -a /etc/locale.gen >/dev/null | |
sudo locale-gen | |
- name: Run PHP server for tests to run | |
run: | | |
# Start a PHP test server for codeception to run against | |
[ -d ./tests/_logs ] || mkdir ./tests/_logs | |
php --server 127.0.0.1:8888 \ | |
--docroot ${{ github.workspace }} \ | |
--define display_startup_errors=1 \ | |
--define display_errors=1 \ | |
--define error_reporting=E_ALL \ | |
>/dev/null 2>./tests/_logs/server_log & | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/composer-cache | |
key: ${{ runner.os }}-php${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php${{ matrix.php-version }}- | |
- name: Install PHP vendor libraries | |
run: composer install --prefer-dist --no-interaction | |
- name: Run composer test | |
run: composer test | |
continue-on-error: ${{ matrix.experimental }} | |
env: | |
TEST_ENV: codeception | |
ABSOLUTE_URL: http://127.0.0.1:8888 | |
DB_HOST: 127.0.0.1 | |
DB_NAME: gibbon_test | |
DB_USERNAME: root | |
DB_PASSWORD: "" | |
- name: Run phpstan static analysis | |
run: composer test:phpstan | |
- name: Check PHP warning and deprecated messages in server_log | |
if: success() || failure() | |
run: | | |
# Check number of uncaught exceptions. | |
export NUM_EXCEPTION=$(grep --perl-regexp 'Uncaught Exception: ' ./tests/_logs/server_log | wc -l) | |
if [ "$NUM_EXCEPTION" -eq 0 ]; then | |
echo -e '\e[32mNo Uncaught exception.\e[0m' | |
echo | |
else | |
echo -e "\e[1m\e[33mGot $NUM_EXCEPTION uncaught exceptions:\e[0m" | |
grep --line-number --color=always --perl-regexp 'Uncaught Exception: ' ./tests/_logs/server_log | |
echo | |
(exit 1) | |
fi | |
# Check number of warning messages. | |
export NUM_WARNING=$(grep --perl-regexp '(?<!PHP )Warning: ' ./tests/_logs/server_log | wc -l) | |
if [ "$NUM_WARNING" -eq 0 ]; then | |
echo -e '\e[32mNo warning message.\e[0m' | |
echo | |
else | |
echo -e "\e[1m\e[33mGot $NUM_WARNING warning messages:\e[0m" | |
grep --line-number --color=always --perl-regexp '(?<!PHP )Warning: ' ./tests/_logs/server_log || echo -e '\e[32mNo Warning message found in log.\e[0m' | |
echo | |
(exit 1) | |
fi | |
# Check number of PHP warning messages. | |
export NUM_PHP_WARNING=$(grep 'PHP Warning: ' ./tests/_logs/server_log | wc -l) | |
if [ "$NUM_PHP_WARNING" -eq 0 ]; then | |
echo -e '\e[32mNo PHP warning message.\e[0m' | |
echo | |
else | |
echo -e "\e[1m\e[31mGot $NUM_PHP_WARNING PHP warning messages:\e[0m" | |
grep --line-number --color=always 'PHP Warning: ' ./tests/_logs/server_log || echo -e '\e[32mNo PHP Warning message found in log.\e[0m' | |
echo | |
(exit 1) | |
fi | |
# Check number of deprecated messages. Cause error if found. | |
export NUM_DEPRECATED=$(grep 'Deprecated: ' ./tests/_logs/server_log | wc -l) | |
if [ "$NUM_DEPRECATED" -eq 0 ]; then | |
echo -e '\e[32mNo deprecated message.\e[0m' | |
else | |
echo -e "\e[1m\e[31mGot $NUM_DEPRECATED deprecated messages:\e[0m" | |
grep --line-number --color=always 'Deprecated: ' ./tests/_logs/server_log || echo -e '\e[32mNo Deprecated message found in log.\e[0m' | |
echo | |
(exit 1) | |
fi | |
continue-on-error: true | |
- name: Check PHP notice in server_log | |
if: success() || failure() | |
run: | | |
# Check number of notice. | |
export NUM_NOTICE=$(grep --perl-regexp 'Notice: ' ./tests/_logs/server_log | wc -l) | |
if [ "$NUM_NOTICE" -eq 0 ]; then | |
echo -e '\e[32mNo Notice.\e[0m' | |
echo | |
else | |
echo -e "\e[1m\e[33mGot $NUM_NOTICE notice(s):\e[0m" | |
grep --line-number --color=always --perl-regexp 'Notice: ' ./tests/_logs/server_log | |
echo | |
(exit 1) | |
fi | |
continue-on-error: true | |
- name: Export Database if Test Failed | |
if: ${{ failure() }} | |
run: | | |
mkdir -p ./tests/_dump | |
mysqldump -u root --protocol=tcp --column-statistics=0 gibbon_test > ./tests/_dump/mysqldump.sql | |
- name: Save Test Artifacts | |
uses: actions/upload-artifact@v3 | |
if: ${{ failure() || matrix.experimental }} | |
with: | |
name: Test Artifacts (PHP ${{ matrix.php-version }}) | |
path: | | |
tests/_logs | |
tests/_dump | |
tests/_output | |
uploads/cache/templates | |
retention-days: 5 |