@@ -2,105 +2,62 @@ name: CI
22
33on :
44 push :
5+ branches : [ main ]
56 pull_request :
6- workflow_dispatch :
7+ branches : [ main ]
8+
9+ env :
10+ PHP_EXTENSIONS : intl pdo_sqlite
711
812jobs :
9- testsuite :
10- runs-on : ubuntu-24.04
13+ test :
14+ runs-on : ubuntu-latest
1115 strategy :
12- fail-fast : false
1316 matrix :
14- php-version : ['8.2', '8.4']
15- db-type : [sqlite, mysql, pgsql]
16-
17- services :
18- postgres :
19- image : postgres
20- ports :
21- - 5432:5432
22- env :
23- POSTGRES_PASSWORD : postgres
24-
17+ php-version : [8.2, 8.3, 8.4]
18+ prefer-lowest : ['']
19+ include :
20+ - php-version : ' 8.2'
21+ db-type : ' sqlite'
22+ prefer-lowest : ' prefer-lowest'
23+
24+ container :
25+ image : thecodingmachine/php:${{ matrix.php-version }}-v5-cli
2526 steps :
26- - uses : actions/checkout@v4
27-
28- - name : Setup Service
29- if : matrix.db-type == 'mysql'
30- run : |
31- sudo service mysql start
32- mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;'
33-
34- - name : Setup PHP
35- uses : shivammathur/setup-php@v2
36- with :
37- php-version : ${{ matrix.php-version }}
38- extensions : mbstring, intl, pdo_${{ matrix.db-type }}
39- coverage : pcov
40-
41- - name : Get composer cache directory
42- id : composercache
43- run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
44-
45- - name : Cache dependencies
46- uses : actions/cache@v4
47- with :
48- path : ${{ steps.composercache.outputs.dir }}
49- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
50- restore-keys : ${{ runner.os }}-composer-
27+ - name : Checkout code
28+ uses : actions/checkout@v4
5129
52- - name : Composer install
30+ - name : Install dependencies
5331 run : |
54- composer install --no-progress --prefer-dist --optimize-autoloader
55-
32+ if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
33+ composer update --prefer-lowest --prefer-stable
34+ composer require --dev dereuromark/composer-prefer-lowest:dev-master
35+ else
36+ composer install --prefer-dist --no-interaction --no-progress
37+ fi
5638
5739 - name : Run PHPUnit
5840 run : |
59- if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
60- if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi
61- if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi
62- if [[ ${{ matrix.php-version }} == '8.2' ]]; then
41+ if [[ ${{ matrix.php-version }} == '8.4' ]]; then
6342 vendor/bin/phpunit --coverage-clover=coverage.xml
6443 else
6544 vendor/bin/phpunit
6645 fi
6746
68- - name : Upload coverage reports to Codecov
69- if : success() && matrix.php-version == '8.2'
70- uses : codecov/codecov-action@v4
71- with :
72- token : ${{ secrets.CODECOV_TOKEN }}
73-
74- validation :
75- name : Coding Standard & Static Analysis
76- runs-on : ubuntu-24.04
77-
47+ static-analysis :
48+ runs-on : ubuntu-latest
49+ if : github.event_name == 'push' || github.event_name == 'pull_request'
50+ container :
51+ image : thecodingmachine/php:8.4-v5-cli
7852 steps :
79- - uses : actions/checkout@v4
80-
81- - name : Setup PHP
82- uses : shivammathur/setup-php@v2
83- with :
84- php-version : ' 8.2'
85- extensions : mbstring, intl
86- coverage : none
87-
88- - name : Get composer cache directory
89- id : composercache
90- run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
91-
92- - name : Cache dependencies
93- uses : actions/cache@v4
94- with :
95- path : ${{ steps.composercache.outputs.dir }}
96- key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
97- restore-keys : ${{ runner.os }}-composer-
53+ - name : Checkout code
54+ uses : actions/checkout@v4
9855
99- - name : Composer Setup
100- run : composer stan-setup
56+ - name : Install dependencies
57+ run : composer install --prefer-dist --no-interaction --no-progress
10158
102- - name : Run phpstan
103- run : vendor/bin/phpstan analyse --error-format=github
59+ - name : Run PHPStan
60+ run : vendor/bin/phpstan analyse --no-progress -- error-format=github
10461
105- - name : Run phpcs
106- run : composer cs-check
62+ - name : Run PHPCS
63+ run : vendor/bin/phpcs src/ tests/
0 commit comments