-
Notifications
You must be signed in to change notification settings - Fork 14
125 lines (99 loc) · 3.59 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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