-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (171 loc) · 5.72 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: ci
on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]
branches:
- main
- sync
paths:
- ".github/workflows/ci.yml"
- "**.php"
- "bin/*"
- "composer.json"
- "phpcs.xml.dist"
- "phpunit.xml.dist"
env:
WP_DB_TEST_NAME: wp_test
WP_DB_TEST_PASS: wp_test
WP_DB_TEST_USER: wp_test
PHP_EXTENSIONS: mysqli
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Setup Composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: php-7.4-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php-7.4-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer:v2
- name: Install dependencies
run: composer install --prefer-dist
- name: Lint codes
run: composer phpcs
test-70:
runs-on: ubuntu-latest
if: ${{ success() }}
needs: lint
strategy:
fail-fast: true
matrix:
php: ['7.0', '7.1']
wp: ['5.*', '6.5'] # WordPress 6.6 requires 7.2.
services:
database:
image: 'mariadb:10.11.5'
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ${{ env.WP_DB_TEST_NAME }}
MYSQL_USER: ${{ env.WP_DB_TEST_USER }}
MYSQL_PASSWORD: ${{ env.WP_DB_TEST_PASS }}
ports:
- 3306:3306
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Setup PHP extensions cache environment
id: php-ext-cache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.PHP_EXTENSIONS }}
key: php-${{ matrix.php }}-ext
- name: Setup PHP extensions cache
uses: actions/cache@v4
with:
path: ${{ steps.php-ext-cache.outputs.dir }}
key: ${{ steps.php-ext-cache.outputs.key }}
restore-keys: ${{ steps.php-ext-cache.outputs.key }}
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Setup Composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php-${{ matrix.php }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.PHP_EXTENSIONS }}
tools: composer:v2
- name: Install dependencies
run: |
composer require "wp-phpunit/wp-phpunit:${{ matrix.wp }}" "roots/wordpress:${{ matrix.wp }}" --no-interaction --no-update --dev
composer remove syntatis/coding-standard rector/rector --dev
composer install --prefer-dist
- name: Run test
env:
WP_DB_TEST_HOST: 127.0.0.1:${{ job.services.database.ports['3306'] }}
WP_ENVIRONMENT_TYPE: development
run: |
vendor/bin/phpunit
test:
runs-on: ubuntu-latest
if: ${{ success() }}
needs: lint
strategy:
fail-fast: true
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
wp: ['5.*', '6.*']
services:
database:
image: 'mariadb:10.11.5'
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ${{ env.WP_DB_TEST_NAME }}
MYSQL_USER: ${{ env.WP_DB_TEST_USER }}
MYSQL_PASSWORD: ${{ env.WP_DB_TEST_PASS }}
ports:
- 3306:3306
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Setup PHP extensions cache environment
id: php-ext-cache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.PHP_EXTENSIONS }}
key: php-${{ matrix.php }}-ext
- name: Setup PHP extensions cache
uses: actions/cache@v4
with:
path: ${{ steps.php-ext-cache.outputs.dir }}
key: ${{ steps.php-ext-cache.outputs.key }}
restore-keys: ${{ steps.php-ext-cache.outputs.key }}
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Setup Composer cache
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php-${{ matrix.php }}-composer-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.PHP_EXTENSIONS }}
tools: composer:v2
- name: Install dependencies
run: |
composer remove syntatis/coding-standard rector/rector --dev
composer install --prefer-dist
- name: Run test
env:
WP_DB_TEST_HOST: 127.0.0.1:${{ job.services.database.ports['3306'] }}
WP_ENVIRONMENT_TYPE: development
run: |
vendor/bin/phpunit