Skip to content

Commit d4202f0

Browse files
authoredDec 16, 2022
Upgrade to CakePHP 4.4 (#50)
* Replace travis CI with Github Actions * Upgrade to CakePHP 4.4 * Add CS check job
1 parent 480439b commit d4202f0

File tree

4 files changed

+124
-42
lines changed

4 files changed

+124
-42
lines changed
 

‎.github/workflows/ci.yml

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
schedule:
9+
- cron: "0 0 * * 0" # Runs at 00:00 UTC on Sun.
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
#########################
16+
# Run PHPUnit testsuite #
17+
#########################
18+
testsuite:
19+
20+
runs-on: ubuntu-latest
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
php-version: ['7.4', '8.0', '8.1', '8.2']
26+
db-type: [sqlite, mysql]
27+
prefer-lowest: ['', 'prefer-lowest']
28+
29+
steps:
30+
- uses: actions/checkout@v3
31+
32+
- name: Setup MySQL 8
33+
if: matrix.db-type == 'mysql'
34+
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
35+
36+
- name: Validate composer.json and composer.lock
37+
run: composer validate --strict
38+
39+
- name: Get composer cache directory
40+
id: composer-cache
41+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
42+
43+
- name: Get date part for cache key
44+
id: key-date
45+
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
46+
47+
- name: Cache composer dependencies
48+
uses: actions/cache@v3
49+
with:
50+
path: ${{ steps.composer-cache.outputs.dir }}
51+
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
52+
53+
- name: Install composer dependencies
54+
run: |
55+
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
56+
composer update --prefer-lowest --prefer-stable
57+
elif ${{ matrix.php-version == '8.2' }}; then
58+
composer update --ignore-platform-req=php
59+
else
60+
composer update
61+
fi
62+
63+
- name: Wait for MySQL
64+
if: matrix.db-type == 'mysql'
65+
run: while ! `mysqladmin ping -h 127.0.0.1 --silent`; do printf 'Waiting for MySQL...\n'; sleep 2; done;
66+
67+
- name: Run PHPUnit testsuite
68+
run: |
69+
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
70+
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi
71+
vendor/bin/phpunit --stderr;
72+
73+
##############
74+
# Code style #
75+
##############
76+
cs:
77+
78+
runs-on: ubuntu-latest
79+
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
php-version: ['8.0']
84+
85+
steps:
86+
- uses: actions/checkout@v3
87+
88+
- name: Validate composer.json and composer.lock
89+
run: composer validate --strict
90+
91+
- name: Get composer cache directory
92+
id: composer-cache
93+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
94+
95+
- name: Get date part for cache key
96+
id: key-date
97+
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
98+
99+
- name: Cache composer dependencies
100+
uses: actions/cache@v3
101+
with:
102+
path: ${{ steps.composer-cache.outputs.dir }}
103+
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
104+
105+
- name: Install composer dependencies
106+
run: |
107+
composer update
108+
109+
- name: Run CS check
110+
run: |
111+
vendor/bin/phpcs -n -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests;

‎.travis.yml

-39
This file was deleted.

‎composer.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
}
1313
],
1414
"require": {
15-
"cakephp/cakephp": "^4.3"
15+
"cakephp/cakephp": "^4.4"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "^8.5",
18+
"phpunit/phpunit": "^8.5.23",
1919
"cakephp/cakephp-codesniffer": "^4.0",
20-
"cakephp/migrations": "^3.3",
20+
"cakephp/migrations": "^3.7",
2121
"php-coveralls/php-coveralls": "^2.1"
2222
},
2323
"autoload": {
@@ -31,5 +31,10 @@
3131
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests",
3232
"TestApp\\": "tests/test_app/src/"
3333
}
34+
},
35+
"config": {
36+
"allow-plugins": {
37+
"dealerdirect/phpcodesniffer-composer-installer": true
38+
}
3439
}
3540
}

‎tests/bootstrap.php

+5
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,10 @@
2727
TransportFactory::setConfig(['default' => ['className' => 'Debug', 'additionalParameters' => true]]);
2828
Mailer::setConfig(['default' => ['transport' => 'default', 'from' => 'foo@bar.com']]);
2929

30+
$cakeVendorPath = $root . '/vendor/cakephp/cakephp';
31+
if (! file_exists($cakeVendorPath . '/tests/test_app/config')) {
32+
mkdir($cakeVendorPath . '/tests/test_app/config', 0744, true);
33+
}
34+
3035
$source = '..' . DS . '..' . DS . '..' . DS . '..' . DS . '..' . DS . '..' . DS . 'config' . DS . 'Migrations';
3136
(new Migrator())->run(compact('source'));

0 commit comments

Comments
 (0)
Please sign in to comment.