Update tests #29
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: Tests | |
env: | |
EXTNAME: vse/dbtool # Your extension vendor/package name | |
SNIFF: 1 # Run code sniffer on your code? 1 or 0 | |
IMAGE_ICC: 1 # Run icc profile sniffer on your images? 1 or 0 | |
EPV: 1 # Run EPV (Extension Pre Validator) on your code? 1 or 0 | |
EXECUTABLE_FILES: 1 # Run check for executable files? 1 or 0 | |
PHPBB_BRANCH: 3.3.x # The phpBB branch to run tests on | |
on: | |
push: | |
branches: # Run tests when commits are pushed to these branches in your repo | |
- master | |
- develop | |
pull_request: # Run tests when pull requests are made on these branches in your repo | |
branches: | |
- master | |
- develop | |
jobs: | |
# START Basic Checks Job (EPV, code sniffer, images check, etc.) | |
basic-checks: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
include: | |
- php: '7.2' | |
db: "none" | |
NOTESTS: 1 | |
name: PHP ${{ matrix.php }} - ${{ matrix.db }} | |
steps: | |
- name: Checkout phpBB | |
uses: actions/checkout@v4 | |
with: | |
repository: phpbb/phpbb | |
ref: ${{ env.PHPBB_BRANCH }} | |
path: phpBB3 | |
- name: Checkout extension | |
uses: actions/checkout@v4 | |
with: | |
path: phpBB3/phpBB/ext/${{ env.EXTNAME }} | |
- 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 | |
working-directory: ./phpBB3 | |
- name: Setup EPV | |
if: ${{ env.EPV != 0 }} | |
run: composer require phpbb/epv:dev-master --dev --no-interaction --ignore-platform-reqs | |
working-directory: ./phpBB3/phpBB | |
- name: Run code sniffer | |
if: ${{ env.SNIFF != 0 }} | |
env: | |
NOTESTS: '1' | |
run: .github/ext-sniff.sh $EXTNAME $NOTESTS | |
working-directory: ./phpBB3 | |
- name: Check image ICC profiles | |
if: ${{ env.IMAGE_ICC != 0 }} | |
run: .github/check-image-icc-profiles.sh | |
working-directory: ./phpBB3 | |
- name: Check executable files | |
if: ${{ env.EXECUTABLE_FILES != 0 }} | |
run: .github/ext-check-executable-files.sh ./ $EXTNAME | |
working-directory: ./phpBB3 | |
- name: Run EPV | |
if: ${{ env.EPV != 0 }} | |
run: phpBB/vendor/bin/EPV.php run --dir="phpBB/ext/$EXTNAME/" | |
working-directory: ./phpBB3 | |
# END Basic Checks Job | |
# START MySQL and MariaDB Job | |
mysql-tests: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
include: | |
- php: '7.2' | |
db: "mariadb:10.1" | |
- php: '7.2' | |
db: "mariadb:10.2" | |
- php: '7.2' | |
db: "mariadb:10.3" | |
- php: '7.2' | |
db: "mariadb:10.4" | |
- php: '7.2' | |
db: "mariadb:10.5" | |
- php: '7.2' | |
db: "mysql:5.6" | |
db_alias: "MyISAM Tests" | |
MYISAM: 1 | |
- php: '7.2' | |
db: "mysql:5.6" | |
- php: '7.2' | |
db: "mysql:5.7" | |
COVERAGE: 1 | |
db_alias: "mysql:5.7 with Coverage" | |
- php: '7.3' | |
db: "mysql:5.7" | |
- php: '7.4' | |
db: "mysql:5.7" | |
- php: '7.4' | |
db: "mysql:8.0" | |
- php: '8.0' | |
db: "mysql:5.7" | |
- php: '8.1' | |
db: "mysql:5.7" | |
- php: '8.2' | |
db: "mysql:5.7" | |
- php: '8.3' | |
db: "mysql:5.7" | |
name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} | |
services: | |
mysql: | |
image: ${{ matrix.db }} | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
MYSQL_DATABASE: phpbb_tests | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd="mysqladmin ping" | |
--health-interval=10s | |
--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 phpBB | |
uses: actions/checkout@v4 | |
with: | |
repository: phpbb/phpbb | |
ref: ${{ env.PHPBB_BRANCH }} | |
path: phpBB3 | |
- name: Checkout extension | |
uses: actions/checkout@v4 | |
with: | |
path: phpBB3/phpBB/ext/${{ env.EXTNAME }} | |
- id: database-type | |
env: | |
MATRIX_DB: ${{ matrix.db }} | |
run: | | |
db=$(echo "${MATRIX_DB%%:*}") | |
echo "db=$db" >> $GITHUB_OUTPUT | |
- name: Setup PHP | |
if: ${{ matrix.COVERAGE != 1 }} | |
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 PHP with Coverage | |
if: ${{ matrix.COVERAGE == 1 }} | |
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: xdebug | |
- 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} | |
working-directory: ./phpBB3 | |
- name: Setup database | |
env: | |
DB: ${{steps.database-type.outputs.db}} | |
MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }} | |
run: .github/setup-database.sh $DB $MYISAM | |
working-directory: ./phpBB3 | |
- name: Setup PHPUnit files | |
env: | |
DB: ${{steps.database-type.outputs.db}} | |
COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }} | |
run: | | |
if [ $COVERAGE == '1' ] | |
then | |
sed -n '1h;1!H;${;g;s/<\/php>/<\/php>\n\t<filter>\n\t\t<whitelist>\n\t\t\t<directory>..\/<\/directory>\n\t\t\t<exclude>\n\t\t\t\t<directory>..\/tests\/<\/directory>\n\t\t\t\t<directory>..\/language\/<\/directory>\n\t\t\t\t<directory>..\/migrations\/<\/directory>\n\t\t\t<\/exclude>\n\t\t<\/whitelist>\n\t<\/filter>/g;p;}' .github/phpunit-$DB-github.xml &> phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml | |
else | |
mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_ | |
fi | |
working-directory: ./phpBB3 | |
- name: Run unit tests | |
env: | |
DB: ${{steps.database-type.outputs.db}} | |
COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }} | |
run: | | |
if [ $COVERAGE == '1' ] | |
then | |
phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php --coverage-clover build/logs/clover.xml | |
else | |
phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php | |
fi | |
working-directory: ./phpBB3 | |
- name: Send code coverage | |
if: ${{ matrix.COVERAGE == 1 }} | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./phpBB3/build/logs/clover.xml | |
# END MySQL and MariaDB Job |