mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
113 lines
3.3 KiB
YAML
113 lines
3.3 KiB
YAML
|
name: Flarum Backend Jobs
|
||
|
|
||
|
on:
|
||
|
workflow_call:
|
||
|
inputs:
|
||
|
enable_backend_testing:
|
||
|
description: "Enable Backend Testing?"
|
||
|
type: boolean
|
||
|
default: true
|
||
|
required: false
|
||
|
|
||
|
backend_directory:
|
||
|
description: The directory of the project where backend code is located. This should contain a `composer.json` file, and is generally the root directory of the repo.
|
||
|
type: string
|
||
|
required: false
|
||
|
default: '.'
|
||
|
|
||
|
php_versions:
|
||
|
description: Versions of PHP to test with. Should be array of strings encoded as JSON array
|
||
|
type: string
|
||
|
required: false
|
||
|
default: '["7.4", "8.0", "8.1"]'
|
||
|
db_versions:
|
||
|
description: Versions of databases to test with. Should be array of strings encoded as JSON array
|
||
|
type: string
|
||
|
required: false
|
||
|
default: '["mysql:5.7", "mariadb"]'
|
||
|
|
||
|
php_ini_values:
|
||
|
description: PHP ini values
|
||
|
type: string
|
||
|
required: false
|
||
|
default: error_reporting=E_ALL
|
||
|
|
||
|
env:
|
||
|
COMPOSER_ROOT_VERSION: dev-main
|
||
|
FLARUM_TEST_TMP_DIR_LOCAL: tests/integration/tmp
|
||
|
|
||
|
jobs:
|
||
|
test:
|
||
|
runs-on: ubuntu-latest
|
||
|
|
||
|
strategy:
|
||
|
matrix:
|
||
|
php: ${{ fromJSON(inputs.php_versions) }}
|
||
|
service: ${{ fromJSON(inputs.db_versions) }}
|
||
|
prefix: ['', flarum_]
|
||
|
|
||
|
include:
|
||
|
- service: 'mysql:5.7'
|
||
|
db: MySQL
|
||
|
- service: mariadb
|
||
|
db: MariaDB
|
||
|
- prefix: flarum_
|
||
|
prefixStr: (prefix)
|
||
|
|
||
|
exclude:
|
||
|
- php: 8.0
|
||
|
service: 'mysql:5.7'
|
||
|
prefix: flarum_
|
||
|
- php: 8.0
|
||
|
service: mariadb
|
||
|
prefix: flarum_
|
||
|
|
||
|
services:
|
||
|
mysql:
|
||
|
image: ${{ matrix.service }}
|
||
|
ports:
|
||
|
- 13306:3306
|
||
|
|
||
|
name: 'PHP ${{ matrix.php }} / ${{ matrix.db }} ${{ matrix.prefixStr }}'
|
||
|
|
||
|
if: inputs.enable_backend_testing
|
||
|
|
||
|
steps:
|
||
|
- uses: actions/checkout@master
|
||
|
|
||
|
- name: Setup PHP
|
||
|
uses: shivammathur/setup-php@v2
|
||
|
with:
|
||
|
php-version: ${{ matrix.php }}
|
||
|
coverage: xdebug
|
||
|
extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
|
||
|
tools: phpunit, composer:v2
|
||
|
ini-values: ${{ inputs.php_ini_values }}
|
||
|
|
||
|
# The authentication alter is necessary because newer mysql versions use the `caching_sha2_password` driver,
|
||
|
# which isn't supported prior to PHP7.4
|
||
|
# When we drop support for PHP7.3, we should remove this from the setup.
|
||
|
- name: Create MySQL Database
|
||
|
run: |
|
||
|
sudo systemctl start mysql
|
||
|
mysql -uroot -proot -e 'CREATE DATABASE flarum_test;' --port 13306
|
||
|
mysql -uroot -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" --port 13306
|
||
|
|
||
|
- name: Install Composer dependencies
|
||
|
run: composer install
|
||
|
working-directory: ${{ inputs.backend_directory }}
|
||
|
|
||
|
- name: Setup Composer tests
|
||
|
run: composer test:setup
|
||
|
working-directory: ${{ inputs.backend_directory }}
|
||
|
env:
|
||
|
DB_PORT: 13306
|
||
|
DB_PASSWORD: root
|
||
|
DB_PREFIX: ${{ matrix.prefix }}
|
||
|
|
||
|
- name: Run Composer tests
|
||
|
run: composer test
|
||
|
working-directory: ${{ inputs.backend_directory }}
|
||
|
env:
|
||
|
COMPOSER_PROCESS_TIMEOUT: 600
|