CI #15
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: [ "master" ] | |
pull_request: | |
branches: [ "*" ] | |
schedule: | |
- cron: "0 0 * * 0" # Runs at 00:00 UTC on Sun. | |
permissions: | |
contents: read | |
jobs: | |
######################### | |
# Run PHPUnit testsuite # | |
######################### | |
testsuite: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3'] | |
db-type: [mysql] | |
prefer-lowest: ['', 'prefer-lowest'] | |
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=cakephp -p 3306:3306 -d mysql:8 --default-authentication-plugin=mysql_native_password --disable-log-bin | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict | |
- 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: test-${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: mbstring, intl | |
- name: Install composer dependencies | |
run: | | |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then | |
composer update --prefer-lowest --prefer-stable | |
elif ${{ matrix.php-version == '8.2' }}; then | |
composer update --ignore-platform-req=php | |
else | |
composer update | |
fi | |
- name: Wait for MySQL | |
if: matrix.db-type == 'mysql' | |
run: while ! `mysqladmin ping -h 127.0.0.1 --silent`; do printf 'Waiting for MySQL...\n'; sleep 2; done; | |
- name: Run PHPUnit testsuite | |
run: | | |
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then | |
export DB_URL='mysql://root:[email protected]/cakephp'; | |
mysql -h 127.0.0.1 -u root -proot cakephp < ./tests/Schema/articles.sql | |
fi | |
vendor/bin/phpunit --stderr; | |
############## | |
# Code style # | |
############## | |
cs: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php-versions: ['7.4'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict | |
- 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: cs-${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }} | |
restore-keys: | | |
cs-${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: mbstring, intl | |
- name: Install composer dependencies | |
run: composer update --no-interaction | |
- name: Run CS check | |
run: composer cs-check |