-
Notifications
You must be signed in to change notification settings - Fork 362
207 lines (187 loc) · 6.89 KB
/
Copy pathphp-lint-tests.yml
File metadata and controls
207 lines (187 loc) · 6.89 KB
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
201
202
203
204
205
206
207
name: PHP Tests
on:
push:
branches:
- develop
- main
# Only run if PHP-related files changed.
paths:
- '.github/workflows/php-lint-tests.yml'
- 'includes/**'
- 'tests/phpunit/**'
- 'tests/phpstan/**'
- '**.php'
- 'phpcs.xml*'
- 'phpstan.neon.*'
- 'phpunit*.xml*'
- composer.json
- composer.lock
- feature-flags.json
- readme.txt
- changelog.txt
- assets/js/analytics-advanced-tracking.js
- 'assets/**/*.json'
pull_request:
branches:
- develop
- main
- 'feature/**'
# Only run if PHP-related files changed.
paths:
- '.github/workflows/php-lint-tests.yml'
- includes/**
- 'tests/phpunit/**'
- 'tests/phpstan/**'
- '**.php'
- 'phpcs.xml*'
- 'phpstan.neon.*'
- 'phpunit*.xml*'
- composer.json
- composer.lock
- feature-flags.json
- readme.txt
- changelog.txt
- assets/js/analytics-advanced-tracking.js
- 'assets/**/*.json'
types:
- opened
- reopened
- synchronize
concurrency:
group: php-lint-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
php-lint:
name: PHP Lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
- uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # ratchet:shivammathur/setup-php@v2
with:
php-version: '8.4'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # ratchet:actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Validate Composer configuration
run: composer validate --strict
- name: Composer Install
run: composer install --no-interaction --no-progress
- name: PHP Lint
run: composer lint
php-static-analysis:
name: PHP Static Analysis
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
# Using PHP 8.4 here for Composer install to trigger PHP Scoper as the latest supported active version of PHP.
- name: Setup PHP for Composer
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # ratchet:shivammathur/setup-php@v2
with:
php-version: '8.4'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # ratchet:actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Validate Composer configuration
run: composer validate --strict
- name: Composer Install
run: composer install --no-interaction --no-progress
- name: Run Analysis
run: composer analyze
php-tests:
name: PHP Tests (PHP ${{ matrix.php_version }}, WordPress ${{ matrix.wp_version }}${{ matrix.wp_multisite && ', Multisite' }})
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
composer_dev_require: ['']
php_version: ['7.4', '8.1', '8.4']
wp_multisite: ['']
wp_version: ['latest']
include:
# Min supported PHP + WP Oldest
- php_version: '7.4'
wp_version: '5.3.18' # PHP 7.4 support
composer_dev_require: 'phpunit/phpunit:^7 yoast/phpunit-polyfills:^1'
# Min supported PHP + WP Latest Multisite
- php_version: '7.4'
wp_multisite: '1'
wp_version: 'latest'
# Min supported PHP + WP Nightly
- php_version: '7.4'
wp_version: 'nightly'
services:
mysql:
image: mysql:5.7 # ratchet:exclude
env:
MYSQL_ROOT_PASSWORD: wordpress
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
env:
DB_HOST: 127.0.0.1
DB_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: wordpress
MYSQL_DATABASE: wordpress_test
WP_MULTISITE: ${{ matrix.wp_multisite }}
WP_VERSION: ${{ matrix.wp_version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
- name: Install SVN
run: sudo apt-get update && sudo apt-get install -y subversion
- name: Setup PHP for Composer
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # ratchet:shivammathur/setup-php@v2
with:
php-version: '8.4'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # ratchet:actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Configure Composer Dev Packages
if: ${{ matrix.composer_dev_require }}
run: |
composer config audit.ignore '{"PKSA-z3gr-8qht-p93v": "Necessary to install PHPUnit 7"}' --json --merge
composer require ${{ matrix.composer_dev_require }} --dev --with-dependencies --no-install --no-scripts
- name: Composer Install
run: composer install --no-interaction --no-progress -vv
- name: Setup PHP for Tests
uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # ratchet:shivammathur/setup-php@v2
with:
extensions: mysqli, uopz
php-version: ${{ matrix.php_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up PHP test data
run: tests/phpunit/bin/install-wp-tests.sh "${MYSQL_DATABASE}" "${MYSQL_USER}" "${MYSQL_PASSWORD}" "${DB_HOST}":"${DB_PORT}" "${WP_VERSION}"
- name: Run Unit Tests
run: composer test -- --verbose
if: ${{ !matrix.wp_multisite }}
- name: Run Unit Tests
run: composer test:multisite -- --verbose
if: ${{ matrix.wp_multisite }}