From ef22a029b25e0bf986c9fccc2c83cef665a1dfbf Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 16 Dec 2020 21:46:57 +0100 Subject: [PATCH] [ticket/16659] Split up tests for each database type PHPBB3-16659 --- .github/check-doctum-parse-errors.sh | 26 +++ .github/check-executable-files.sh | 63 ++++++ .github/check-image-icc-profiles.sh | 14 ++ .github/ldap/base.ldif | 41 ++++ .github/ldap/slapd.conf | 17 ++ .github/phing-sniff.sh | 16 ++ .github/phpunit-mariadb-github.xml | 39 ++++ .github/phpunit-mssql-github.xml | 41 ++++ .github/phpunit-mysql-github.xml | 41 ++++ .github/phpunit-postgres-github.xml | 41 ++++ .github/phpunit-sqlite3-github.xml | 41 ++++ .github/setup-database.sh | 26 +++ .github/setup-exiftool.sh | 14 ++ .github/setup-ldap.sh | 19 ++ .github/setup-phpbb.sh | 36 +++ .github/setup-unbuffer.sh | 14 ++ .github/setup-webserver.sh | 81 +++++++ .github/workflows/tests.yml | 314 +++++++++++++++++++-------- 18 files changed, 789 insertions(+), 95 deletions(-) create mode 100755 .github/check-doctum-parse-errors.sh create mode 100755 .github/check-executable-files.sh create mode 100755 .github/check-image-icc-profiles.sh create mode 100644 .github/ldap/base.ldif create mode 100644 .github/ldap/slapd.conf create mode 100755 .github/phing-sniff.sh create mode 100644 .github/phpunit-mariadb-github.xml create mode 100644 .github/phpunit-mssql-github.xml create mode 100644 .github/phpunit-mysql-github.xml create mode 100644 .github/phpunit-postgres-github.xml create mode 100644 .github/phpunit-sqlite3-github.xml create mode 100755 .github/setup-database.sh create mode 100755 .github/setup-exiftool.sh create mode 100755 .github/setup-ldap.sh create mode 100755 .github/setup-phpbb.sh create mode 100755 .github/setup-unbuffer.sh create mode 100755 .github/setup-webserver.sh diff --git a/.github/check-doctum-parse-errors.sh b/.github/check-doctum-parse-errors.sh new file mode 100755 index 0000000000..86abe86b36 --- /dev/null +++ b/.github/check-doctum-parse-errors.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +if [ ! -f doctum.phar ]; then + # Download the latest (5.1.x) release if the file does not exist + # Remove it to update your phar + curl -O https://doctum.long-term.support/releases/5.1/doctum.phar + rm -f doctum.phar.sha256 + curl -O https://doctum.long-term.support/releases/5.1/doctum.phar.sha256 + sha256sum --strict --check doctum.phar.sha256 + rm -f doctum.phar.sha256 + # You can fetch the latest (5.1.x) version code here: + # https://doctum.long-term.support/releases/5.1/VERSION +fi +# Show the version to inform users of the script +php doctum.phar --version +php doctum.phar parse build/doctum-checkout.conf.php -v diff --git a/.github/check-executable-files.sh b/.github/check-executable-files.sh new file mode 100755 index 0000000000..d9d0800f00 --- /dev/null +++ b/.github/check-executable-files.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +root="$1" +path="${root}phpBB/" + +# Check the permissions of the files + +# The following variables MUST NOT contain any wildcard +# Directories to skip +directories_skipped="-path ${path}develop -o -path ${path}vendor" + +# Files to skip +files_skipped="-false" + +# Files which have to be executable +executable_files="-path ${path}bin/* -o -path ${path}install/phpbbcli.php" + +incorrect_files=$( \ + find ${path} \ + '(' \ + '(' \ + ${directories_skipped} \ + ')' \ + -a -type d -prune -a -type f \ + ')' -o \ + '(' \ + -type f -a \ + -not '(' \ + ${files_skipped} \ + ')' -a \ + '(' \ + '(' \ + '(' \ + ${executable_files} \ + ')' -a \ + -not -perm /100 \ + ')' -o \ + '(' \ + -not '(' \ + ${executable_files} \ + ')' -a \ + -perm /111 \ + ')' \ + ')' \ + ')' \ + ) + +if [ "${incorrect_files}" != '' ] +then + echo "The following files do not have proper permissions:"; + ls -la ${incorrect_files} + exit 1; +fi diff --git a/.github/check-image-icc-profiles.sh b/.github/check-image-icc-profiles.sh new file mode 100755 index 0000000000..d0444dc7f5 --- /dev/null +++ b/.github/check-image-icc-profiles.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +find . -type f -a -iregex '.*\.\(gif\|jpg\|jpeg\|png\)$' -a -not -wholename '*vendor/*' | \ + parallel --gnu --keep-order 'phpBB/develop/strip_icc_profiles.sh {}' diff --git a/.github/ldap/base.ldif b/.github/ldap/base.ldif new file mode 100644 index 0000000000..09fe7cecc6 --- /dev/null +++ b/.github/ldap/base.ldif @@ -0,0 +1,41 @@ +dn: dc=example,dc=com +objectClass: top +objectClass: dcObject +objectClass: organization +o: example +dc: example + +dn: ou=foo,dc=example,dc=com +objectClass: organizationalUnit +ou: foo + +dn: cn=admin,dc=example,dc=com +objectClass: simpleSecurityObject +objectClass: organizationalRole +cn: admin +description: LDAP administrator +userPassword:: e1NTSEF9NytMR2gveUxTMzdsc3RRd1V1dENZSVA0TWdYdm9SdDY= + +dn: ou=group,dc=example,dc=com +objectClass: organizationalUnit +ou: group + +dn: cn=admin,ou=foo,dc=example,dc=com +objectClass: posixAccount +objectClass: inetOrgPerson +objectClass: organizationalPerson +objectClass: person +loginShell: /bin/bash +homeDirectory: /home/admin +uid: admin +cn: admin +uidNumber: 10000 +gidNumber: 10000 +sn: admin +mail: admin@example.com +userPassword:: e1NTSEF9WHpueGZURHZZc21JSkl6czdMVXBjdCtWYTA1dlMzVlQ= + +dn: cn=admin,ou=group,dc=example,dc=com +objectClass: posixGroup +gidNumber: 10000 +cn: admin diff --git a/.github/ldap/slapd.conf b/.github/ldap/slapd.conf new file mode 100644 index 0000000000..9f6aa980f7 --- /dev/null +++ b/.github/ldap/slapd.conf @@ -0,0 +1,17 @@ +# See slapd.conf(5) for details on configuration options. +include /etc/ldap/schema/core.schema +include /etc/ldap/schema/cosine.schema +include /etc/ldap/schema/inetorgperson.schema +include /etc/ldap/schema/nis.schema + +pidfile /var/tmp/slapd/slapd.pid +argsfile /var/tmp/slapd/slapd.args + +modulepath /usr/lib/openldap + +database ldif +directory /var/tmp/slapd + +suffix "dc=example,dc=com" +rootdn "cn=admin,dc=example,dc=com" +rootpw adminadmin diff --git a/.github/phing-sniff.sh b/.github/phing-sniff.sh new file mode 100755 index 0000000000..7e1595c385 --- /dev/null +++ b/.github/phing-sniff.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +cd build +../phpBB/vendor/bin/phing sniff +cd .. diff --git a/.github/phpunit-mariadb-github.xml b/.github/phpunit-mariadb-github.xml new file mode 100644 index 0000000000..74b3b85483 --- /dev/null +++ b/.github/phpunit-mariadb-github.xml @@ -0,0 +1,39 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + diff --git a/.github/phpunit-mssql-github.xml b/.github/phpunit-mssql-github.xml new file mode 100644 index 0000000000..37c1deae2d --- /dev/null +++ b/.github/phpunit-mssql-github.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + diff --git a/.github/phpunit-mysql-github.xml b/.github/phpunit-mysql-github.xml new file mode 100644 index 0000000000..d14359d618 --- /dev/null +++ b/.github/phpunit-mysql-github.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + diff --git a/.github/phpunit-postgres-github.xml b/.github/phpunit-postgres-github.xml new file mode 100644 index 0000000000..2648f27bef --- /dev/null +++ b/.github/phpunit-postgres-github.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + diff --git a/.github/phpunit-sqlite3-github.xml b/.github/phpunit-sqlite3-github.xml new file mode 100644 index 0000000000..f5b2b67b22 --- /dev/null +++ b/.github/phpunit-sqlite3-github.xml @@ -0,0 +1,41 @@ + + + + + ../tests + ../tests/functional + ../tests/lint_test.php + + + ../tests/functional + + + + + + slow + + + + + + + + + + + + + + + + diff --git a/.github/setup-database.sh b/.github/setup-database.sh new file mode 100755 index 0000000000..d34c7898b7 --- /dev/null +++ b/.github/setup-database.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +DB=$1 +MYISAM=$2 + +if [ "$DB" == "postgres" ] +then + psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres + psql -c 'create database phpbb_tests;' -U postgres +fi + +if [ "$MYISAM" == '1' ] +then + mysql -h 127.0.0.1 -u root -e 'SET GLOBAL storage_engine=MyISAM;' +fi diff --git a/.github/setup-exiftool.sh b/.github/setup-exiftool.sh new file mode 100755 index 0000000000..04999b8600 --- /dev/null +++ b/.github/setup-exiftool.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +sudo apt-get update +sudo apt-get install -y parallel libimage-exiftool-perl diff --git a/.github/setup-ldap.sh b/.github/setup-ldap.sh new file mode 100755 index 0000000000..d554654e87 --- /dev/null +++ b/.github/setup-ldap.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +sudo apt-get -y install ldap-utils slapd +mkdir /var/tmp/slapd +cp .github/ldap/slapd.conf /var/tmp/slapd/slapd.conf +slapd -d 256 -d 128 -f /var/tmp/slapd/slapd.conf -h ldap://localhost:3389 & +sleep 3 +ldapadd -h localhost:3389 -D "cn=admin,dc=example,dc=com" -w adminadmin -f .github/ldap/base.ldif diff --git a/.github/setup-phpbb.sh b/.github/setup-phpbb.sh new file mode 100755 index 0000000000..c74f29d5cf --- /dev/null +++ b/.github/setup-phpbb.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +DB=$1 +PHP_VERSION=$2 +NOTESTS=$3 + +if [ "$NOTESTS" == '1' ] +then + .github/setup-exiftool.sh + .github/setup-unbuffer.sh +fi + +if [ "$NOTESTS" != '1' ] +then + .github/setup-webserver.sh +fi + +cd phpBB +php ../composer.phar install --dev --no-interaction +if [[ "$PHP_VERSION" =~ ^nightly$ || "$PHP_VERSION" =~ ^8 ]] +then + php ../composer.phar remove phpunit/dbunit --dev --update-with-dependencies \ + && php ../composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-all-dependencies --ignore-platform-reqs +fi +cd .. diff --git a/.github/setup-unbuffer.sh b/.github/setup-unbuffer.sh new file mode 100755 index 0000000000..4423d1b8b6 --- /dev/null +++ b/.github/setup-unbuffer.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e + +sudo apt-get update +sudo apt-get install -y expect-dev diff --git a/.github/setup-webserver.sh b/.github/setup-webserver.sh new file mode 100755 index 0000000000..0ee15ce061 --- /dev/null +++ b/.github/setup-webserver.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# +# This file is part of the phpBB Forum Software package. +# +# @copyright (c) phpBB Limited +# @license GNU General Public License, version 2 (GPL-2.0) +# +# For full copyright and license information, please see +# the docs/CREDITS.txt file. +# +set -e +set -x + +sudo apt-get update +sudo apt-get install -y nginx coreutils + +sudo service nginx stop + +DIR=$(dirname "$0") +USER=$(whoami) +PHPBB_ROOT_PATH=$(realpath "$DIR/../phpBB") +NGINX_SITE_CONF="/etc/nginx/sites-enabled/default" +NGINX_CONF="/etc/nginx/nginx.conf" +APP_SOCK=$(realpath "$DIR")/php-app.sock +NGINX_PHP_CONF="$DIR/nginx-php.conf" + +# php-fpm +PHP_FPM_BIN="/usr/sbin/php-fpm$PHP_VERSION" +PHP_FPM_CONF="$DIR/php-fpm.conf" + +if [ ! -f $PHP_FPM_BIN ] && [ "$PHP_VERSION" == '8.1' ] && [ -f "/usr/bin/php-fpm" ] +then + PHP_FPM_BIN="/usr/bin/php-fpm" +fi + +if [ ! -f $PHP_FPM_BIN ] && [ "$PHP_VERSION" != '8.1' ] +then + sudo apt-get install php$PHP_VERSION-fpm php$PHP_VERSION-cli \ + php$PHP_VERSION-curl php$PHP_VERSION-xml php$PHP_VERSION-mbstring \ + php$PHP_VERSION-zip php$PHP_VERSION-mysql php$PHP_VERSION-sqlite3 \ + php$PHP_VERSION-intl php$PHP_VERSION-gd php$PHP_VERSION-pgsql + sudo service php$PHP_VERSION-fpm start + sudo service php$PHP_VERSION-fpm status +fi + +echo " + [global] + + [ci] + user = $USER + group = $USER + listen = $APP_SOCK + listen.mode = 0666 + pm = static + pm.max_children = 2 + + php_admin_value[memory_limit] = 128M +" > $PHP_FPM_CONF + +sudo $PHP_FPM_BIN \ + --fpm-config "$DIR/php-fpm.conf" + +# nginx +sudo sed -i "s/user www-data;/user $USER;/g" $NGINX_CONF +sudo cp "$DIR/../phpBB/docs/nginx.sample.conf" "$NGINX_SITE_CONF" +sudo sed -i \ + -e "s/example\.com/localhost/g" \ + -e "s|root /path/to/phpbb;|root $PHPBB_ROOT_PATH;|g" \ + $NGINX_SITE_CONF + +# Generate FastCGI configuration for Nginx +echo " +upstream php { + server unix:$APP_SOCK; +} +" > $NGINX_PHP_CONF + +sudo mv "$NGINX_PHP_CONF" /etc/nginx/conf.d/php.conf + +sudo nginx -T +sudo service nginx start diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c976ffa360..5ecac57913 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,14 +12,67 @@ on: - master jobs: - unit-tests: + # Basic checks, e.g. parse errors, commit messages, etc. + basic-checks: runs-on: ubuntu-18.04 strategy: matrix: include: - - php: '7.1' - db: "none" + - db: 'none' + php: '7.1' NOTESTS: 1 + + name: PHP ${{ matrix.php }} - ${{ matrix.db }} + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap + coverage: none + + - name: Setup environment for phpBB + env: + DB: ${{ matrix.db }} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: '1' + run: | + .github/setup-phpbb.sh $DB $PHP_VERSION $NOTESTS + + - name: Phing sniff + run: | + .github/phing-sniff.sh + + - name: Check doctum parse errors + run: | + .github/check-doctum-parse-errors.sh + + - name: Check image ICC profiles + run: | + .github/check-image-icc-profiles.sh + + - name: Check executable files + run: | + .github/check-executable-files.sh ./ + + - name: Check commit message + env: + BRANCH: ${{ github.event.pull_request.base.ref }} + PR_SHA: ${{ github.event.pull_request.head.sha }} + if: ${{ github.event.pull_request.head.sha != '' && github.event.pull_request.base.ref != '' }} + run: | + git remote set-branches --add origin $BRANCH && git fetch && git-tools/commit-msg-hook-range.sh origin/$BRANCH..$PR_SHA + + # Tests for MySQL and MariaDB + mysql-tests: + runs-on: ubuntu-18.04 + strategy: + matrix: + include: - php: '7.1' db: "mariadb:10.1" - php: '7.1' @@ -30,20 +83,6 @@ jobs: db: "mariadb:10.4" - php: '7.1' db: "mariadb:10.5" - - php: '7.1' - db: "postgres:9.5" - - php: '7.1' - db: "postgres:9.6" - - php: '7.1' - db: "postgres:10" - - php: '7.1' - db: "postgres:11" - - php: '7.1' - db: "postgres:12" - - php: '7.1' - db: "postgres:13" - - php: '7.1' - db: "sqlite3" - php: '7.1' db: "mysql:5.6" db_alias: "MySQL Slow Tests" @@ -56,12 +95,6 @@ jobs: db: "mysql:5.6" - php: '7.1' db: "mysql:5.7" - - php: '7.2' - db: "mcr.microsoft.com/mssql/server:2017-latest" - db_alias: 'MSSQL 2017' - - php: '7.2' - db: "mcr.microsoft.com/mssql/server:2019-latest" - db_alias: 'MSSQL 2019' - php: '7.2' db: "mysql:5.7" - php: '7.3' @@ -79,7 +112,7 @@ jobs: services: mysql: - image: ${{ matrix.db != 'mysql:5.6' && matrix.db != 'mysql:5.7' && matrix.db != 'mysql:8.0' && matrix.db != 'mariadb:10.1' && matrix.db != 'mariadb:10.2' && matrix.db != 'mariadb:10.3' && matrix.db != 'mariadb:10.4' && matrix.db != 'mariadb:10.5' && 'mysql:5.7' || matrix.db }} + image: ${{ matrix.db }} env: MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_DATABASE: phpbb_tests @@ -91,6 +124,95 @@ jobs: --health-timeout=5s --health-retries=3 + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - id: database-type + env: + MATRIX_DB: ${{ matrix.db }} + run: | + db=$(echo "${MATRIX_DB%%:*}") + echo "::set-output name=db::$db" + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap + coverage: none + + - name: Setup environment for phpBB + env: + DB: ${{steps.database-type.outputs.db}} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: '0' + run: | + .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} + + - name: Setup database + env: + DB: ${{steps.database-type.outputs.db}} + MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }} + run: | + .github/setup-database.sh $DB $MYISAM + + - name: Setup LDAP + if: ${{ matrix.SLOWTESTS == 1 }} + run: | + .github/setup-ldap.sh + + - name: Lint tests + if: ${{ matrix.SLOWTESTS != 1 && steps.database-type.outputs.db == 'mysql' }} + run: phpBB/vendor/bin/phpunit tests/lint_test.php + + - name: Run unit tests + env: + DB: ${{steps.database-type.outputs.db}} + if: ${{ matrix.SLOWTESTS != 1 && matrix.NOTESTS != 1 }} + run: | + phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error + + - name: Slow tests + env: + DB: ${{steps.database-type.outputs.db}} + if: ${{ matrix.SLOWTESTS == 1 }} + run: | + phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --group slow + + # Tests for PostgreSQL + postgres-tests: + runs-on: ubuntu-18.04 + strategy: + matrix: + include: + - php: '7.1' + db: "postgres:9.5" + - php: '7.1' + db: "postgres:9.6" + - php: '7.1' + db: "postgres:10" + - php: '7.1' + db: "postgres:11" + - php: '7.1' + db: "postgres:12" + - php: '7.1' + db: "postgres:13" + + name: PHP ${{ matrix.php }} - ${{ matrix.db }} + + services: postgres: image: ${{ matrix.db != 'postgres:9.5' && matrix.db != 'postgres:9.6' && matrix.db != 'postgres:10' && matrix.db != 'postgres:11' && matrix.db != 'postgres:12' && matrix.db != 'postgres:13' && 'postgres:10' || matrix.db }} env: @@ -106,6 +228,74 @@ jobs: --health-timeout 5s --health-retries 5 + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - id: database-type + env: + MATRIX_DB: ${{ matrix.db }} + run: | + db=$(echo "${MATRIX_DB%%:*}") + echo "::set-output name=db::$db" + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap + coverage: none + + - name: Setup environment for phpBB + env: + DB: ${{steps.database-type.outputs.db}} + PHP_VERSION: ${{ matrix.php }} + NOTESTS: '0' + run: | + .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} + + - name: Setup database + env: + DB: ${{steps.database-type.outputs.db}} + MYISAM: '0' + run: | + .github/setup-database.sh $DB $MYISAM + + - name: Run unit tests + env: + DB: ${{steps.database-type.outputs.db}} + run: | + phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error + + # Other database types, namely sqlite3 and mssql + other-tests: + runs-on: ubuntu-18.04 + strategy: + matrix: + include: + - php: '7.1' + db: "sqlite3" + - php: '7.2' + db: "mcr.microsoft.com/mssql/server:2017-latest" + db_alias: 'MSSQL 2017' + - php: '7.2' + db: "mcr.microsoft.com/mssql/server:2019-latest" + db_alias: 'MSSQL 2019' + + name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} + + services: mssql: image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-latest' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} env: @@ -158,85 +348,19 @@ jobs: env: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - MYSQL8: ${{ matrix.db }} == 'mysql:8.0' + NOTESTS: '0' run: | - travis/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} ${MYSQL8:-0} + .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} - name: Setup database env: DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }} + MYISAM: '0' run: | - travis/setup-database.sh $DB $PHP_VERSION $NOTESTS $MYISAM - - - name: Setup LDAP - env: - SLOWTESTS: ${{ matrix.SLOWTESTS }} - if: ${{ matrix.SLOWTESTS == 1 }} - run: | - travis/setup-ldap.sh $SLOWTESTS - - - name: Phing sniff - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - if: ${{ matrix.NOTESTS == 1 }} - run: | - travis/phing-sniff.sh $DB $PHP_VERSION $NOTESTS - - - name: Check doctum parse errors - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - if: ${{ matrix.NOTESTS == 1 }} - run: | - travis/check-doctum-parse-errors.sh $DB $PHP_VERSION $NOTESTS - - - name: Check image ICC profiles - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - if: ${{ matrix.NOTESTS == 1 }} - run: | - travis/check-image-icc-profiles.sh $DB $PHP_VERSION $NOTESTS - - - name: Check executable files - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: ${{ matrix.NOTESTS != 1 && '0' || '1' }} - if: ${{ matrix.NOTESTS == 1 }} - run: | - travis/check-executable-files.sh $DB $PHP_VERSION $NOTESTS ./ - - - name: Lint tests - if: ${{ matrix.SLOWTESTS != 1 && steps.database-type.outputs.db == 'mysql' }} - run: phpBB/vendor/bin/phpunit tests/lint_test.php + .github/setup-database.sh $DB $MYISAM - name: Run unit tests env: DB: ${{steps.database-type.outputs.db}} - if: ${{ matrix.SLOWTESTS != 1 && matrix.NOTESTS != 1 }} run: | - phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --verbose --stop-on-error - - - name: Slow tests - env: - DB: ${{steps.database-type.outputs.db}} - if: ${{ matrix.SLOWTESTS == 1 }} - run: | - phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --group slow - - - name: Check commit message - env: - BRANCH: ${{ github.event.pull_request.base.ref }} - PR_SHA: ${{ github.event.pull_request.head.sha }} - if: ${{ matrix.NOTESTS == 1 && github.event.pull_request.head.sha != '' && github.event.pull_request.base.ref != '' }} - run: | - git remote set-branches --add origin $BRANCH && git fetch && git-tools/commit-msg-hook-range.sh origin/$BRANCH..$PR_SHA + phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error