-
-
Notifications
You must be signed in to change notification settings - Fork 100
354 lines (302 loc) · 13.9 KB
/
requirement-checker.yaml
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
name: RequirementChecker
on:
push:
branches: [ main ]
pull_request: ~
schedule:
# Do not make it the first of the month and/or midnight since it is a very busy time
- cron: "* 10 5 * *"
# See https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
POLLING_INTERVALS_SEC: 30
SLEEP_TIME_SEC: 60s
#TERMINFO: /usr/lib/terminfo
TERM: xterm
jobs:
cs-lint:
runs-on: ubuntu-latest
name: Lint CS
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
coverage: none
- name: Install the Composer (root) dependencies
uses: ramsey/composer-install@v2
- name: Ensure that the make target is up to date
run: make _vendor_install
- name: Install PHP-CS-Fixer
uses: ramsey/composer-install@v2
with:
working-directory: vendor-bin/php-cs-fixer
- name: Ensure that the PHP-CS-Fixer make target is up to date
run: make php_cs_fixer_install
- name: Install the Composer dependencies
uses: ramsey/composer-install@v2
with:
working-directory: requirement-checker
- name: Ensure that the make target is up to date
run: cd requirement-checker; make _vendor_install
- name: Lint CS
run: cd requirement-checker; make cs_lint
autoreview-test:
runs-on: ubuntu-latest
name: AutoReview Tests
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
coverage: none
- name: Install the Composer dependencies
uses: ramsey/composer-install@v2
with:
working-directory: requirement-checker
- name: Ensure that the make target is up to date
run: cd requirement-checker; make _vendor_install
- name: Run tests
run: cd requirement-checker; make phpunit_autoreview
unit-tests:
runs-on: ubuntu-latest
name: Unit Tests (PHP ${{ matrix.php }}, ${{ matrix.dependency }}${{ matrix.composer-options == null && ')' || format(', {0})', matrix.composer-options) }}
strategy:
fail-fast: false
matrix:
# The lowest dependency is tested via an e2e test rather than by executing the tests like so.
# The reason being using tools such as PHPUnit for a version as low as the lowest supported version
# is a serious strain for close to no benefits: the e2e test is simpler.
php: [ '8.1' ]
dependency: [ locked ]
composer-options: [ null ]
include:
- php: '8.1'
dependency: lowest
composer-options: ~
- php: '8.1'
dependency: highest
composer-options: ~
- php: '8.2'
dependency: highest
composer-options: ~
- php: '8.3'
dependency: highest
composer-options: --ignore-platform-req=php+
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer
coverage: none
- name: Install the Composer dependencies
uses: ramsey/composer-install@v2
with:
working-directory: requirement-checker
dependency-versions: ${{ matrix.dependency }}
composer-options: ${{ matrix.composer-options }}
- name: Ensure that the make target is up to date
run: cd requirement-checker; make _vendor_install
- name: Install the Composer (root) dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.php.dependency }}
composer-options: ${{ matrix.php.composer-options }}
- name: Ensure that the make target is up to date
run: make _vendor_install
- name: Install the Composer (requirement checker bin namespace) dependencies
uses: ramsey/composer-install@v2
with:
working-directory: vendor-bin/requirement-checker
dependency-versions: highest
composer-options: ${{ matrix.php.composer-options }}
- name: Ensure that the make target is up to date
run: make requirement_checker_install
- name: Runs the tests
run: cd requirement-checker; make test_unit
wait-for-phar-and-docker-images:
runs-on: ubuntu-latest
name: Wait for the PHAR & Docker images
steps:
# Reduce the amount polling done without increasing the polling internal too much.
- name: Sleep
run: sleep ${{ env.SLEEP_TIME_SEC }}
shell: bash
# I could not make this workflow work with a on.workflow_run. Hence instead of adding this
# wait step for _every_ e2e job, which will block more runners, we wait in one and only one
# runner.
- name: Wait for the PHAR to be built
uses: fountainhead/[email protected]
with:
checkName: Build PHAR
ref: ${{ github.event.pull_request.head.sha || github.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
intervalSeconds: ${{ env.POLLING_INTERVALS_SEC }}
- name: Wait for the Docker images to be pushed
uses: fountainhead/[email protected]
with:
checkName: Docker status
ref: ${{ github.event.pull_request.head.sha || github.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
intervalSeconds: ${{ env.POLLING_INTERVALS_SEC }}
e2e-tests:
runs-on: ubuntu-latest
name: End-to-End Tests
needs: wait-for-phar-and-docker-images
strategy:
fail-fast: false
matrix:
e2e:
- command: _test_e2e_pass_no_config_min_composer_php
docker-image: ghcr.io/box-project/box_php725
- command: _test_e2e_pass_no_config_min_box_php
docker-image: ghcr.io/box-project/box_php81
- command: _test_e2e_pass_complete_min_composer_php
docker-image: ghcr.io/box-project/box_php725
- command: _test_e2e_pass_complete_min_box_php
docker-image: ghcr.io/box-project/box_php81
- command: _test_e2e_fail_complete_min_composer_php
docker-image: ghcr.io/box-project/box_php725
- command: _test_e2e_fail_complete_min_box_php
docker-image: ghcr.io/box-project/box_php81
- command: _test_e2e_skip_min_composer_php
docker-image: ghcr.io/box-project/box_php725
- command: _test_e2e_pass_complete_requirement_checker_not_disabled
docker-image: ghcr.io/box-project/box_php725
- command: _test_e2e_fail_conflict
docker-image: ghcr.io/box-project/box_php81
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
coverage: none
# We cannot use the regular actions/download-artifact here since the artifact is stored
# in a different workflow.
# See https://github.com/actions/download-artifact/issues/172
- name: Retrieve built PHAR
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: release.yaml
check_artifacts: true
name: box-phar
# The original target is for the publishing, which is different from the internal name used.
- name: Ensure the make target is up to date
run: |
mkdir -p vendor
mv -vf box.phar bin/box.phar
touch -c bin/box.phar
# See https://github.com/actions/download-artifact#limitations
# the permissions are not guaranteed to be preserved
- name: Ensure PHAR is executable
run: chmod 755 bin/box.phar
- name: Check that the PHAR works
run: bin/box.phar --ansi --version
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull the docker image
run: docker pull ${{ matrix.e2e.docker-image }}
- name: Runs the tests
run: cd requirement-checker; make ${{ matrix.e2e.command }}
# This is a "trick", a meta task which does not change, and we can use in
# the protected branch rules as opposed to the tests one above which
# may change regularly.
validate-tests:
name: RequirementChecker status
runs-on: ubuntu-latest
needs:
- cs-lint
- autoreview-test
- unit-tests
- e2e-tests
if: always()
steps:
- name: Successful run
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Failing run
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
update-requirement-checker:
name: Update the RequirementChecker
if: ${{ github.repository == 'box-project/box' && github.ref_name == 'main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: '0' # Ensures the tags are fetched
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
coverage: none
- name: Install the Composer dependencies
uses: ramsey/composer-install@v2
with:
working-directory: requirement-checker
dependency-versions: ${{ matrix.php.dependency }}
composer-options: ${{ matrix.php.composer-options }}
env:
COMPOSER_ROOT_VERSION: "4.x.x-dev"
- name: Ensure that the make target is up to date
run: cd requirement-checker; make _vendor_install
- name: Install the Composer (root) dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.php.dependency }}
composer-options: ${{ matrix.php.composer-options }}
env:
COMPOSER_ROOT_VERSION: "4.x.x-dev"
- name: Ensure that the make target is up to date
run: make _vendor_install
- name: Install the Composer (requirement checker bin namespace) dependencies
uses: ramsey/composer-install@v2
with:
working-directory: vendor-bin/requirement-checker
dependency-versions: highest
composer-options: ${{ matrix.php.composer-options }}
- name: Ensure that the make target is up to date
run: make requirement_checker_install
- name: Dump the requirement checker
run: make dump_requirement_checker
- name: Check for changes
run: |
if [ $(git status --porcelain | wc -l) -eq "0" ]; then
echo "🟢 No change detected."
echo "requirement_checker_changed=false" >> $GITHUB_ENV
else
echo "requirement_checker_changed=true" >> $GITHUB_ENV
fi
- name: Create Pull Request
if: env.requirement_checker_changed == 'true'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch-suffix: random
delete-branch: true
title: "build: Update the RequirementChecker"
committer: "box-bot <[email protected]>"
commit-message: "Update the RequirementChecker"