-
-
Notifications
You must be signed in to change notification settings - Fork 76
244 lines (224 loc) · 6.9 KB
/
ci.yml
File metadata and controls
244 lines (224 loc) · 6.9 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
name: 📁 PHP CI & Docker Build
on:
push:
branches:
- '*.*.x'
tags: ['*']
pull_request: ~
workflow_dispatch: ~
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
pre_checks:
name: "0️⃣ Pre-checks"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: "Check file permissions"
run: |
NON_EXECUTABLE=$(find . -type f -not -path './.git/*' -not -path './bin/console' -not -path './frankenphp/docker-entrypoint.sh' -not -path './link' -executable)
if [[ -n "$NON_EXECUTABLE" ]]; then
echo "Found non-executable files with executable permission:"
echo "$NON_EXECUTABLE"
exit 1
fi
- name: "Find non-printable ASCII characters"
run: |
if LC_ALL=C.UTF-8 find . -type f -name "*.php" -print0 | xargs -0 grep -PHn "[[:cntrl:]]"; then
echo "Non-printable ASCII characters found"
exit 1
fi
prepare_dependencies:
name: "📦 Prepare Composer Dependencies"
needs: [pre_checks]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
outputs:
cache-key: ${{ steps.cache-key-generator.outputs.key }}
steps:
- uses: actions/checkout@v5
- id: cache-key-generator
run: echo "key=composer-${{ runner.os }}-${{ hashFiles('composer.lock') }}" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ steps.cache-key-generator.outputs.key }}
restore-keys: |
composer-${{ runner.os }}-
- uses: ramsey/composer-install@v3
with:
dependency-versions: highest
composer-options: --optimize-autoloader
phpstan:
name: "1️⃣ Static Analysis (PHPStan)"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: castor phpstan
ecs:
name: "2️⃣ Coding Standards (ECS)"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: castor ecs
rector:
name: "3️⃣ Refactoring (Rector)"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: castor rector
validate:
name: "4️⃣ Validate composer.json"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: |
composer dump-autoload --optimize --strict-psr
composer validate --strict
composer normalize --dry-run --diff || true
lint:
name: "5️⃣ Syntax Check"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- run: composer exec -- parallel-lint src tests
check_licenses:
name: "6️⃣ License Check"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- run: castor check-licenses
deptrac:
name: "7️⃣ Architecture Layer Check (Deptrac)"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
steps:
- uses: actions/checkout@v5
- uses: actions/cache@v4
with:
path: |
vendor
~/.composer/cache
key: ${{ needs.prepare_dependencies.outputs.cache-key }}
- run: castor deptrac
tests:
name: "🧪 Unit & Functional Tests (PHP ${{ matrix.php-version }}${{ matrix.lowest-deps && ' - Lowest Deps' || '' }})"
needs:
- prepare_dependencies
- phpstan
- ecs
- rector
- lint
- validate
- check_licenses
- deptrac
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental || false }}
strategy:
fail-fast: false
matrix:
include:
- php-version: '8.2'
lowest-deps: true
- php-version: '8.2'
- php-version: '8.3'
- php-version: '8.4'
- php-version: '8.5'
experimental: true
container:
image: ghcr.io/spomky-labs/phpqa:${{ matrix.php-version }}
env:
XDEBUG_MODE: coverage
PHP_VERSION: ${{ matrix.php-version }}
steps:
- uses: actions/checkout@v5
- name: Install dependencies
run: |
if [ "${{ matrix.lowest-deps || 'false' }}" = "true" ]; then
composer update --prefer-lowest --no-interaction --no-progress
else
composer install --no-interaction --no-progress
fi
- name: Run PHPUnit
run: castor phpunit
infection:
name: "🧬 Mutation Testing"
needs: [tests]
if: ${{ endsWith(github.ref_name, '.x') }}
runs-on: ubuntu-latest
container:
image: ghcr.io/spomky-labs/phpqa:8.4
env:
XDEBUG_MODE: coverage
steps:
- uses: actions/checkout@v5
- name: Install dependencies
run: composer install --no-interaction --no-progress
- name: Run PHPUnit
run: castor phpunit
- name: Execute Infection
run: castor infect
exported_files:
name: "8️⃣ Exported Files Check"
needs: [prepare_dependencies]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Check exported files
run: |
EXPECTED="CODE_OF_CONDUCT.md,LICENSE,README.md,RELEASES.md,SECURITY.md,composer.json"
CURRENT=$(git archive HEAD | tar --list | grep -v '/$' | grep -Ev '^(assets|bin|config|fixtures|frankenphp|migrations|public|src|templates|translations)/' | sort | paste -sd "," -)
echo "CURRENT = ${CURRENT}"
echo "EXPECTED = ${EXPECTED}"
if [[ "$CURRENT" != "$EXPECTED" ]]; then
echo "❌ Exported files do not match expected list"
exit 1
fi