forked from PHP-CS-Fixer/PHP-CS-Fixer
-
Notifications
You must be signed in to change notification settings - Fork 1
245 lines (201 loc) · 8.69 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: CI
on:
- pull_request
- push
permissions:
contents: read # to fetch code (actions/checkout)
concurrency:
group: ci-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches
cancel-in-progress: true
env:
PHP_MAX: '8.3'
PHP_MIN: '7.4'
jobs:
tests:
strategy:
fail-fast: false
matrix:
include:
- operating-system: 'ubuntu-20.04'
php-version: '7.4'
job-description: 'Fixer with lowest deps'
run-fixer: 'yes'
composer-flags: '--prefer-lowest' # should be checked on the lowest supported PHP version
execute-flex-with-symfony-version: '^5' # explicit check for Symfony 5.x compatibility
- operating-system: 'ubuntu-20.04'
php-version: '7.4'
job-description: 'tests with lowest deps'
run-tests: 'yes'
composer-flags: '--prefer-lowest' # should be checked on the lowest supported PHP version
execute-flex-with-symfony-version: '^5' # explicit check for Symfony 5.x compatibility
- operating-system: 'ubuntu-20.04'
php-version: '8.0'
job-description: 'Fixer'
run-fixer: 'yes'
- operating-system: 'ubuntu-20.04'
php-version: '8.0'
job-description: 'tests'
run-tests: 'yes'
- operating-system: 'ubuntu-20.04'
php-version: '8.1'
job-description: 'Fixer with Symfony ^6'
run-fixer: 'yes'
execute-flex-with-symfony-version: '^6' # explicit check for Symfony 6.x compatibility
- operating-system: 'ubuntu-20.04'
php-version: '8.1'
job-description: 'tests with Symfony ^6'
run-tests: 'yes'
execute-flex-with-symfony-version: '^6' # explicit check for Symfony 6.x compatibility
- operating-system: 'ubuntu-20.04'
php-version: '8.2'
job-description: 'Fixer'
run-fixer: 'yes'
- operating-system: 'ubuntu-20.04'
php-version: '8.2'
job-description: 'tests'
run-tests: 'yes'
- operating-system: 'ubuntu-20.04'
php-version: '8.3'
job-description: 'Fixer'
run-fixer: 'yes'
- operating-system: 'ubuntu-20.04'
php-version: '8.3'
job-description: 'tests'
run-tests: 'yes'
- operating-system: 'ubuntu-20.04'
php-version: '8.3'
job-description: 'Fixer with migration rules'
run-fixer: 'yes'
run-migration-rules: 'yes' # should be checked on the highest supported PHP version
- operating-system: 'ubuntu-20.04'
php-version: '8.3'
job-description: 'tests with migration rules'
run-tests: 'yes'
run-migration-rules: 'yes' # should be checked on the highest supported PHP version
- operating-system: 'ubuntu-20.04'
php-version: '8.3'
job-description: 'Fixer with Symfony ^7'
run-fixer: 'yes'
execute-flex-with-symfony-version: '^7' # explicit check for Symfony 7.x compatibility
- operating-system: 'ubuntu-20.04'
php-version: '8.3'
job-description: 'tests with Symfony ^7'
run-tests: 'yes'
execute-flex-with-symfony-version: '^7' # explicit check for Symfony 7.x compatibility
- operating-system: 'ubuntu-20.04'
php-version: '8.3'
job-description: 'code coverage'
run-tests: 'yes'
collect-code-coverage: 'yes'
- operating-system: 'windows-latest'
php-version: '8.3'
job-description: 'Fixer on Windows'
run-fixer: 'yes'
FAST_LINT_TEST_CASES: 1 # we need full syntax check on one job at least, no need to do it on additional
- operating-system: 'windows-latest'
php-version: '8.3'
job-description: 'tests on Windows'
run-tests: 'yes'
FAST_LINT_TEST_CASES: 1 # we need full syntax check on one job at least, no need to do it on additional systems
- operating-system: 'macos-latest'
php-version: '8.3'
job-description: 'Fixer on macOS'
run-fixer: 'yes'
FAST_LINT_TEST_CASES: 1 # we need full syntax check on one job at least, no need to do it on additional systems
- operating-system: 'macos-latest'
php-version: '8.3'
job-description: 'tests on macOS'
run-tests: 'yes'
FAST_LINT_TEST_CASES: 1 # we need full syntax check on one job at least, no need to do it on additional
- operating-system: 'ubuntu-22.04'
php-version: '8.4'
job-description: 'Fixer'
run-fixer: 'yes'
PHP_CS_FIXER_IGNORE_ENV: 1
- operating-system: 'ubuntu-22.04'
php-version: '8.4'
job-description: 'tests'
run-tests: 'yes'
PHP_CS_FIXER_IGNORE_ENV: 1
name: PHP ${{ matrix.php-version }} ${{ matrix.job-description }}
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP with Composer deps
uses: ./.github/composite-actions/setup-php-with-composer-deps
with:
os: ${{ runner.os }}
php: ${{ matrix.php-version }}
php-coverage: ${{ matrix.collect-code-coverage }}
composer-flags: ${{ matrix.composer-flags }}
composer-flex-with-symfony-version: ${{ matrix.execute-flex-with-symfony-version }}
# Execute migration rules before running tests and self-fixing,
# so we know that our codebase is future-ready.
# Should be checked on the highest supported PHP version.
- name: Run PHP CS Fixer with migration rules
if: env.PHP_MAX == matrix.php-version && matrix.run-migration-rules == 'yes'
env:
PHP_CS_FIXER_FUTURE_MODE: 1
run: php php-cs-fixer fix --config .php-cs-fixer.php-highest.php -q
- name: Disable time limit for tests when collecting coverage
if: matrix.collect-code-coverage == 'yes'
run: sed 's/enforceTimeLimit="true"/enforceTimeLimit="false"/g' phpunit.xml.dist > phpunit.xml
- name: Run tests
if: matrix.run-tests == 'yes' && matrix.collect-code-coverage != 'yes'
env:
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
FAST_LINT_TEST_CASES: ${{ matrix.FAST_LINT_TEST_CASES }}
run: vendor/bin/paraunit run --testsuite unit,integration
- name: Run tests and collect code coverage
if: matrix.run-tests == 'yes' && matrix.collect-code-coverage == 'yes'
env:
FAST_LINT_TEST_CASES: 1
run: vendor/bin/paraunit coverage --testsuite unit --exclude-group covers-nothing --clover build/logs/clover.xml
- name: Upload coverage results to Coveralls
if: matrix.run-tests == 'yes' && matrix.collect-code-coverage == 'yes'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: php vendor/bin/php-coveralls --verbose
- name: Run PHP CS Fixer
if: matrix.run-fixer == 'yes'
env:
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }}
PHP_CS_FIXER_FUTURE_MODE: 1
run: php php-cs-fixer check --diff -v
# Should be checked on the lowest supported PHP version.
# If any type can be converted from PHPDoc to native type on lowest supported PHP, we should commit such change.
- name: Run PHP CS Fixer with PHPDoc to type rules
if: env.PHP_MIN == matrix.php-version && matrix.run-fixer == 'yes'
env:
PHP_CS_FIXER_FUTURE_MODE: 1
run: php php-cs-fixer check --diff -v --config .php-cs-fixer.php-lowest.php
deployment:
needs: tests
strategy:
fail-fast: false
matrix:
include:
- operating-system: 'ubuntu-20.04'
php-version: '8.2'
name: Deployment checks
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP with Composer deps
uses: ./.github/composite-actions/setup-php-with-composer-deps
with:
os: ${{ runner.os }}
php: ${{ matrix.php-version }}
- name: Cache dev-tools
uses: actions/cache@v3
with:
path: dev-tools/bin/
key: Build-${{ hashFiles('dev-tools/build.sh') }}
- name: Build phar
run: ./dev-tools/build.sh
- name: Run smoke tests
env:
FAST_LINT_TEST_CASES: 1
run: vendor/bin/phpunit --testsuite smoke