Skip to content

CakePHP Plugin CI

CakePHP Plugin CI #26

Workflow file for this run

name: CakePHP Plugin CI
on:
push:
branches:
- cake5
pull_request:
branches:
- '*'
schedule:
- cron: "0 7 1 * *"
jobs:
testsuite:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
cakephp-version: ['5.0.*']
php-version: ['8.1', '8.2', '8.3']
db-type: ['mysql']
prefer-lowest: ['']
coverage: ['no']
include:
- cakephp-version: '5.0.*'
php-version: '8.1'
db-type: 'mysql:8.0'
prefer-lowest: 'prefer-lowest'
coverage: 'no'
- cakephp-version: '5.0.*'
php-version: '8.3'
db-type: 'mysql'
prefer-lowest: ''
coverage: 'no'
- php-version: '8.3'
cakephp-version: '5.0.*'
db-type: 'mysql'
prefer-lowest: ''
coverage: 'coverage'
steps:
- name: Setup MySQL latest
if: matrix.db-type == 'mysql'
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp_test -p 3306:3306 -d mysql --disable-log-bin
- name: Setup MySQL 8.0
if: matrix.db-type == 'mysql:8.0'
run: docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=cakephp_test -p 3306:3306 -d mysql:8.0 --default-authentication-plugin=mysql_native_password --disable-log-bin
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, apcu, sqlite, pdo_mysql, pdo_sqlite
ini-values: apc.enable_cli = 1
coverage: xdebug
- 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@v4
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: Change CakePHP version
run: |
composer require cakephp/cakephp:${{ matrix.cakephp-version }}
- name: Composer install
run: |
if [[ ${{ matrix.php-version }} == '8.1' ]]; then
composer update --ignore-platform-reqs
elif ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer update
fi
- name: Wait for MySQL
if: matrix.db-type == 'mysql' || matrix.db-type == 'mysql:8.0'
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' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp_test?encoding=utf8mb4&init[]=SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"'; fi
if [[ ${{ matrix.db-type }} == 'mysql:8.0' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp_test?encoding=utf8mb4&init[]=SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"'; fi
if [[ ${{ matrix.coverage }} == 'coverage' ]]; then
export CODECOVERAGE=1 && vendor/bin/phpunit --stderr --coverage-clover=coverage.xml
else
vendor/bin/phpunit --stderr
fi
- name: Submit code coverage
if: matrix.coverage == 'coverage'
uses: codecov/codecov-action@v3
cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, intl, apcu
coverage: none
- 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@v4
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 install
#
# - name: composer install
# run: composer stan-setup
- name: Run PHP CodeSniffer
run: vendor/bin/phpcs --report=checkstyle -p --extensions=php src/ tests/
#
# - name: Run psalm
# if: success() || failure()
# run: vendor/bin/psalm.phar --output-format=github
#
# - name: Run phpstan
# if: success() || failure()
# run: vendor/bin/phpstan.phar analyse --error-format=github