-
Notifications
You must be signed in to change notification settings - Fork 16
349 lines (328 loc) · 13.1 KB
/
Copy pathphpstan.yml
File metadata and controls
349 lines (328 loc) · 13.1 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
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
name: PHPStan CI
on: push
concurrency:
group: phpstan-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
changes:
name: Detect changed projects
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v7
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
ngessentials:
- 'NGEssentials/**'
- 'libraries/**'
- 'shared/**'
- 'scripts/**'
lobby:
- 'Lobby/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
skywars:
- 'Skywars/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
bedwars:
- 'Bedwars/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
conquests:
- 'Conquests/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
duels:
- 'Duels/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
mommasays:
- 'MommaSays/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
murdermystery:
- 'MurderMystery/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
soccer:
- 'Soccer/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
thebridge:
- 'TheBridge/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
uhc:
- 'UHC/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
survivalgames:
- 'SurvivalGames/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
meltdown:
- 'Meltdown/**'
- 'libraries/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
libdiscord:
- 'libraries/libDiscord/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
libphysx:
- 'libraries/libPhysX/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
libreplay:
- 'libraries/libReplay/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
libvanilla:
- 'libraries/libVanilla/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
libasyncio:
- 'libraries/libasyncio/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
libforms:
- 'libraries/libforms/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
libminigames:
- 'libraries/libminigames/**'
- 'NGEssentials/**'
- 'shared/**'
- 'scripts/**'
shared:
- '.github/workflows/phpstan.yml'
- 'phpstan.neon.dist'
- name: Build matrix
id: set-matrix
env:
MSG: ${{ github.event.head_commit.message }}
run: |
FORCE_ALL=false
if echo "$MSG" | grep -qE '\[All\]'; then
FORCE_ALL=true
fi
if [ "${{ steps.filter.outputs.shared }}" = "true" ]; then
FORCE_ALL=true
fi
ALL='[
{"project":"NGEssentials"},
{"project":"Lobby"},
{"project":"Skywars"},
{"project":"Bedwars"},
{"project":"Conquests"},
{"project":"Duels"},
{"project":"MommaSays"},
{"project":"MurderMystery"},
{"project":"Soccer"},
{"project":"TheBridge"},
{"project":"UHC"},
{"project":"SurvivalGames"},
{"project":"Meltdown"},
{"project":"libraries/libDiscord"},
{"project":"libraries/libPhysX"},
{"project":"libraries/libReplay"},
{"project":"libraries/libVanilla"},
{"project":"libraries/libasyncio"},
{"project":"libraries/libforms"},
{"project":"libraries/libminigames"}
]'
if [ "$FORCE_ALL" = "true" ]; then
INCLUDE=$(echo "$ALL" | jq -c '.')
else
INCLUDE='[]'
if [ "${{ steps.filter.outputs.ngessentials }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[0]]')
fi
if [ "${{ steps.filter.outputs.lobby }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[1]]')
fi
if [ "${{ steps.filter.outputs.skywars }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[2]]')
fi
if [ "${{ steps.filter.outputs.bedwars }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[3]]')
fi
if [ "${{ steps.filter.outputs.conquests }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[4]]')
fi
if [ "${{ steps.filter.outputs.duels }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[5]]')
fi
if [ "${{ steps.filter.outputs.mommasays }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[6]]')
fi
if [ "${{ steps.filter.outputs.murdermystery }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[7]]')
fi
if [ "${{ steps.filter.outputs.soccer }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[8]]')
fi
if [ "${{ steps.filter.outputs.thebridge }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[9]]')
fi
if [ "${{ steps.filter.outputs.uhc }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[10]]')
fi
if [ "${{ steps.filter.outputs.survivalgames }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[11]]')
fi
if [ "${{ steps.filter.outputs.meltdown }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[12]]')
fi
if [ "${{ steps.filter.outputs.libdiscord }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[13]]')
fi
if [ "${{ steps.filter.outputs.libphysx }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[14]]')
fi
if [ "${{ steps.filter.outputs.libreplay }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[15]]')
fi
if [ "${{ steps.filter.outputs.libvanilla }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[16]]')
fi
if [ "${{ steps.filter.outputs.libasyncio }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[17]]')
fi
if [ "${{ steps.filter.outputs.libforms }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[18]]')
fi
if [ "${{ steps.filter.outputs.libminigames }}" = "true" ]; then
INCLUDE=$(echo "$INCLUDE" | jq -c --argjson all "$ALL" '. += [$all[19]]')
fi
fi
echo "matrix={\"include\":$INCLUDE}" >> $GITHUB_OUTPUT
phpstan:
name: PHPStan Analysis (${{ matrix.project }})
needs: changes
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && needs.changes.outputs.matrix != '{\"include\":[]}'"
strategy:
fail-fast: false
max-parallel: 4
matrix: ${{ fromJSON(needs.changes.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Cache PHP Release
id: cache-php
uses: actions/cache@v6
with:
path: bin
key: php-8.4-pm5-linux-x86_64-v1
- name: Download PHP Release
if: steps.cache-php.outputs.cache-hit != 'true'
uses: dsaltares/fetch-gh-release-asset@1.1.2
with:
file: PHP-8.4-Linux-x86_64-PM5.tar.gz
repo: NetherGamesMC/php-build-scripts
version: "tags/pm5-php-8.4-latest"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Unpack PHP Release
if: steps.cache-php.outputs.cache-hit != 'true'
run: |
tar -xzvf PHP-8.4-Linux-x86_64-PM5.tar.gz
rm -f PHP-8.4-Linux-x86_64-PM5.tar.gz
- name: Configure PHP
run: |
EXT_DIR=$(find bin/php7/lib/php/extensions -mindepth 1 -maxdepth 1 -type d 2>/dev/null | head -n 1)
if [ -n "$EXT_DIR" ]; then
ABS_EXT_DIR="${{ github.workspace }}/$EXT_DIR"
find bin -name "*.ini" -exec sed -i "s|extension_dir = .*|extension_dir = \"$ABS_EXT_DIR\"|g" {} +
find bin -name "*.ini" -exec sed -i "s|/home/runner/work/[^/]*/[^/]*/bin/php7/lib/php/extensions/[^/\"']*|$ABS_EXT_DIR|g" {} +
fi
if [ -z "$EXT_DIR" ] || [ ! -f "$EXT_DIR/opcache.so" ]; then
find bin -name "*.ini" -exec sed -i "s|^zend_extension.*opcache.*|;zend_extension=opcache.so|g" {} +
fi
if [ -z "$EXT_DIR" ] || [ ! -f "$EXT_DIR/ext_quiche.so" ]; then
find bin -name "*.ini" -exec sed -i "s|^extension.*ext_quiche.*|;extension=ext_quiche.so|g" {} +
fi
- name: Cache vendor
id: cache-vendor
uses: actions/cache@v6
with:
path: ${{ matrix.project }}/vendor
key: vendor-dev-${{ matrix.project }}-${{ hashFiles(format('{0}/composer.json', matrix.project), 'shared/repositories.json') }}
- name: Cache Composer metadata & repo cache
if: steps.cache-vendor.outputs.cache-hit != 'true'
uses: actions/cache@v6
with:
path: ~/.cache/composer
key: composer-cache-${{ runner.os }}-${{ hashFiles(format('{0}/composer.json', matrix.project), 'shared/repositories.json') }}
restore-keys: |
composer-cache-${{ runner.os }}-
composer-cache-
- name: Cache Composer Phar
id: cache-composer-phar
if: steps.cache-vendor.outputs.cache-hit != 'true'
uses: actions/cache@v6
with:
path: composer.phar
key: composer-stable-phar-v1
- name: Download Composer
if: steps.cache-vendor.outputs.cache-hit != 'true' && steps.cache-composer-phar.outputs.cache-hit != 'true'
run: curl -o composer.phar "https://getcomposer.org/composer-stable.phar"
- name: Add Composer GitHub access token
if: steps.cache-vendor.outputs.cache-hit != 'true'
env:
NG_TOKEN: ${{ secrets.ng_token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TOKEN="${NG_TOKEN:-$GITHUB_TOKEN}"
${{ github.workspace }}/bin/php7/bin/php composer.phar config --global github-oauth.github.com "$TOKEN"
- name: Merge shared repositories
if: steps.cache-vendor.outputs.cache-hit != 'true'
run: >
${{ github.workspace }}/bin/php7/bin/php
${{ github.workspace }}/scripts/merge-composer.php
${{ github.workspace }}/${{ matrix.project }}/composer.json
${{ github.workspace }}/shared/repositories.json
${{ github.workspace }}/${{ matrix.project }}/composer.merged.json
- name: Install Composer dependencies
if: steps.cache-vendor.outputs.cache-hit != 'true'
working-directory: ${{ matrix.project }}
run: COMPOSER_ROOT_VERSION=dev-stable COMPOSER=composer.merged.json ${{ github.workspace }}/bin/php7/bin/php ${{ github.workspace }}/composer.phar install --prefer-dist --no-interaction --no-progress
- name: Run PHPStan
working-directory: ${{ matrix.project }}
run: ${{ github.workspace }}/bin/php7/bin/php vendor/bin/phpstan analyze --no-progress --memory-limit=2G