Merge pull request #17372 from cnizzardini/patch-2 #154
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 | |
on: | |
push: | |
branches: | |
- '4.x' | |
- '4.next' | |
- '5.x' | |
pull_request: | |
branches: | |
- '*' | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
jobs: | |
testsuite: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: ['7.4', '8.0'] | |
db-type: [sqlite, mysql, pgsql] | |
prefer-lowest: [''] | |
exclude: | |
- php-version: '7.4' | |
db-type: 'mysql' | |
include: | |
- php-version: '7.4' | |
db-type: 'mariadb' | |
- php-version: '7.4' | |
db-type: 'mysql' | |
prefer-lowest: 'prefer-lowest' | |
- php-version: '8.1' | |
db-type: 'mysql' | |
- php-version: '8.2' | |
db-type: 'mysql' | |
services: | |
redis: | |
image: redis | |
ports: | |
- 6379/tcp | |
memcached: | |
image: memcached | |
ports: | |
- 11211/tcp | |
steps: | |
- name: Setup MySQL latest | |
if: matrix.db-type == 'mysql' && matrix.php-version == '7.4' | |
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin | |
- name: Setup MySQL 5.6 | |
if: matrix.db-type == 'mysql' && matrix.php-version != '7.4' | |
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp -p 3306:3306 -d mysql:5.6 --character-set-server=utf8 | |
- name: Setup PostgreSQL latest | |
if: matrix.db-type == 'pgsql' && matrix.php-version == '7.4' | |
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres | |
- name: Setup PostgreSQL 9.4 | |
if: matrix.db-type == 'pgsql' && matrix.php-version != '7.4' | |
run: docker run --rm --name=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=cakephp -p 5432:5432 -d postgres:9.4 | |
- uses: getong/[email protected] | |
if: matrix.db-type == 'mariadb' | |
with: | |
mysql database: 'cakephp' | |
mysql root password: 'root' | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
extensions: mbstring, intl, apcu, memcached, redis, pdo_${{ matrix.db-type }} | |
ini-values: apc.enable_cli = 1 | |
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') }}-${{ matrix.prefer-lowest }} | |
- name: Install packages | |
run: | | |
sudo locale-gen da_DK.UTF-8 | |
sudo locale-gen de_DE.UTF-8 | |
- name: Composer install | |
run: | | |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then | |
composer update --prefer-lowest --prefer-stable | |
else | |
composer update | |
fi | |
- name: Setup problem matchers for PHPUnit | |
if: matrix.php-version == '7.4' && matrix.db-type == 'mysql' | |
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | |
- name: Wait for MySQL | |
if: matrix.db-type == 'mysql' || matrix.db-type == 'mariadb' | |
run: while ! `mysqladmin ping -h 127.0.0.1 --silent`; do printf 'Waiting for MySQL...\n'; sleep 2; done; | |
- name: Run PHPUnit | |
env: | |
REDIS_PORT: ${{ job.services.redis.ports['6379'] }} | |
MEMCACHED_PORT: ${{ job.services.memcached.ports['11211'] }} | |
run: | | |
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi | |
if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} == '7.4' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi | |
if [[ ${{ matrix.db-type }} == 'mysql' && ${{ matrix.php-version }} != '7.4' ]]; then export DB_URL='mysql://root:[email protected]/cakephp?encoding=utf8'; fi | |
if [[ ${{ matrix.db-type }} == 'mariadb' ]]; then export DB_URL='mysql://root:[email protected]/cakephp'; fi | |
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi | |
if [[ ${{ matrix.php-version }} == '8.0' ]]; then | |
export CODECOVERAGE=1 | |
vendor/bin/phpunit --verbose --coverage-clover=coverage.xml | |
CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --verbose --testsuite=database | |
vendor/bin/phpunit --verbose --testsuite=globalfunctions --coverage-clover=coverage-functions.xml | |
else | |
vendor/bin/phpunit | |
CAKE_TEST_AUTOQUOTE=1 vendor/bin/phpunit --testsuite=database | |
fi | |
- name: Prefer lowest check | |
if: matrix.prefer-lowest == 'prefer-lowest' | |
run: composer require --dev dereuromark/composer-prefer-lowest && vendor/bin/validate-prefer-lowest -m | |
- name: Submit code coverage | |
if: matrix.php-version == '8.0' | |
uses: codecov/codecov-action@v3 | |
with: | |
files: coverage.xml,coverage-functions.xml | |
testsuite-windows: | |
runs-on: windows-2022 | |
name: Windows - PHP 8.0 & SQL Server | |
env: | |
EXTENSIONS: mbstring, intl, apcu, redis, wincache, pdo_sqlsrv | |
PHP_VERSION: '8.0' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get date part for cache key | |
id: key-date | |
run: echo "date=$(date +'%Y-%m')" >> $env:GITHUB_OUTPUT | |
- name: Setup PHP extensions cache | |
id: php-ext-cache | |
uses: shivammathur/cache-extensions@v1 | |
with: | |
php-version: ${{ env.PHP_VERSION }} | |
extensions: ${{ env.EXTENSIONS }} | |
key: ${{ steps.key-date.outputs.date }} | |
- name: Cache PHP extensions | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.php-ext-cache.outputs.dir }} | |
key: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }} | |
restore-keys: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache.outputs.key }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION }} | |
extensions: ${{ env.EXTENSIONS }} | |
ini-values: apc.enable_cli = 1, extension = php_fileinfo.dll | |
coverage: none | |
- name: Setup SQLServer | |
run: | | |
# MSSQLLocalDB is the default SQL LocalDB instance | |
SqlLocalDB start MSSQLLocalDB | |
SqlLocalDB info MSSQLLocalDB | |
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "create database cakephp;" | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $env: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') }}-${{ matrix.prefer-lowest }} | |
- name: Composer install | |
run: composer update | |
- name: Run PHPUnit | |
env: | |
DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp' | |
run: | | |
set CAKE_DISABLE_GLOBAL_FUNCS=1 | |
vendor/bin/phpunit --verbose | |
- name: Run PHPUnit (autoquote enabled) | |
env: | |
DB_URL: 'sqlserver://@(localdb)\MSSQLLocalDB/cakephp' | |
run: | | |
set CAKE_TEST_AUTOQUOTE=1 | |
vendor/bin/phpunit --verbose --testsuite=database | |
cs-stan: | |
name: Coding Standard & Static Analysis | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '7.4' | |
extensions: mbstring, intl, apcu, memcached, redis | |
coverage: none | |
tools: phive, cs2pr | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- 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') }}-${{ matrix.prefer-lowest }} | |
- name: Composer install | |
run: composer update | |
- name: Install PHP tools with phive. | |
run: phive install --trust-gpg-keys 'CF1A108D0E7AE720,51C67305FFC2E5C0,12CE0F1D262429A5' | |
- name: Run phpcs | |
if: always() | |
run: vendor/bin/phpcs --report=checkstyle src/ tests/ | cs2pr | |
- name: Run psalm | |
if: always() | |
run: tools/psalm --output-format=github | |
- name: Run phpstan | |
if: always() | |
run: tools/phpstan analyse --error-format=github | |
- name: Run phpstan for tests | |
if: always() | |
run: tools/phpstan analyse -c tests/phpstan.neon --error-format=github | |
- name: Run class deprecation aliasing validaton script | |
if: always() | |
run: php contrib/validate-deprecation-aliases.php |