Skip to content

CI

CI #990

Workflow file for this run

name: CI
on:
push:
branches:
- 2.x
pull_request:
branches:
- '*'
schedule:
- cron: "0 0 * * *"
jobs:
tests:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
db-type: [sqlite, mysql, mariadb, pgsql, sqlsrv]
php-version: ['8.1', '8.2', '8.3']
cakephp-version: ['latest']
name: |
${{
format(
'{0} - PHP {1} - CakePHP {2}{3}',
matrix.db-type,
matrix.php-version,
matrix.cakephp-version,
fromJSON('["", " - Coverage"]')[matrix.php-version == '8.2' && matrix.cakephp-version == 'latest']
)
}}
steps:
- uses: actions/checkout@v3
- name: Setup MySQL 8
if: matrix.db-type == 'mysql'
run: |
docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=test -p 3306:3306 -d mysql:8 \
--mysql-native-password=ON --disable-log-bin --wait_timeout=240 --connect_timeout=240 --max_allowed_packet=128M
sleep 10
- name: Setup MariaDB latest
if: matrix.db-type == 'mariadb' && matrix.php-version != '8.1'
run: |
docker run --rm --name=mariadb -e MARIADB_ROOT_PASSWORD=root -e MARIADB_DATABASE=test -p 3306:3306 -d mariadb:latest \
--disable-log-bin --wait_timeout=240 --connect_timeout=240 --max_allowed_packet=128M
sleep 10
- name: Setup MariaDB lowest (10.2)
if: matrix.db-type == 'mariadb' && matrix.php-version == '8.1'
run: |
docker run --rm --name=mariadb -e MARIADB_ROOT_PASSWORD=root -e MARIADB_DATABASE=test -p 3306:3306 -d mariadb:10.2 \
--disable-log-bin --wait_timeout=240 --connect_timeout=240 --max_allowed_packet=128M
sleep 10
- name: Setup PostgreSQL latest
if: matrix.db-type == 'pgsql' && matrix.php-version != '8.1'
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=test -p 5432:5432 -d postgres
- name: Setup PostgreSQL lowest (9.4)
if: matrix.db-type == 'pgsql' && matrix.php-version == '8.1'
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=test -p 5432:5432 -d postgres:9.4
- name: Setup SQL Server 2019
if: matrix.db-type == 'sqlsrv' && matrix.php-version != '8.1'
run: |
docker run --rm --name=sqlsrv -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Sql!Server' -e 'MSSQL_PID=Express' -p 1433:1433 \
-d mcr.microsoft.com/mssql/server:2019-CU10-ubuntu-20.04
sleep 10
docker exec sqlsrv /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Sql!Server -Q "create database test;"
- name: Setup SQL Server 2017
if: matrix.db-type == 'sqlsrv' && matrix.php-version == '8.1'
run: |
docker run --rm --name=sqlsrv -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Sql!Server' -e 'MSSQL_PID=Express' -p 1433:1433 \
-d mcr.microsoft.com/mssql/server:2017-CU22-ubuntu-16.04
sleep 10
docker exec sqlsrv /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Sql!Server' -Q "create database test;"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, pdo_${{ fromJSON(format('["{0}", "mysql"]', matrix.db-type))[matrix.db-type == 'mariadb'] }}
coverage: pcov
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Get date part for cache key
id: key-date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}
- name: Composer install
run: |
if [[ ${{ matrix.cakephp-version }} != 'latest' ]]; then
composer require --no-update cakephp/cakephp:~${{ matrix.cakephp-version }}
fi
composer install --optimize-autoloader
- name: Setup problem matchers for PHPUnit
if: matrix.php-version != '8.2' && matrix.cakephp-version != 'latest'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Run PHPUnit
run: |
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DATABASE_URL='sqlite:///:memory:'; fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DATABASE_URL='mysql://root:root@127.0.0.1/test'; fi
if [[ ${{ matrix.db-type }} == 'mariadb' ]]; then export DATABASE_URL='mysql://root:root@127.0.0.1/test'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DATABASE_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi
if [[ ${{ matrix.db-type }} == 'sqlsrv' ]]; then export DATABASE_URL='sqlserver://sa:Sql!Server@127.0.0.1/test'; fi
if [[ ${{ matrix.php-version }} == '8.2' && ${{ matrix.cakephp-version }} == 'latest' ]]; then
composer test-coverage
else
composer test
fi
- name: Code Coverage Report
if: success() && matrix.php-version == '8.2' && matrix.cakephp-version == 'latest'
uses: codecov/codecov-action@v3
with:
files: coverage.xml,coverage-autoquote.xml
cs-stan:
name: Coding Standards & Static Analysis
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, intl
coverage: none
tools: cs2pr
- name: Composer Install
run: composer stan-setup
- name: Run phpcs
run: composer cs-check -- --parallel=1 --report=checkstyle | cs2pr
- name: Run psalm
run: composer psalm -- --output-format=github
- name: Run phpstan (src)
run: composer phpstan-src -- --error-format=github
- name: Run phpstan (tests)
run: composer phpstan-tests -- --error-format=github