forked from luca-script/communism
-
Notifications
You must be signed in to change notification settings - Fork 0
258 lines (229 loc) · 8.96 KB
/
Copy pathphp.yml
File metadata and controls
258 lines (229 loc) · 8.96 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
name: Run Tests
on:
push:
branches: [ "master", "staging", "experimental" ]
pull_request:
branches: [ "master", "staging", "experimental" ]
permissions:
contents: read
jobs:
setup:
name: "Set up environment (${{ matrix.os.name }})"
strategy:
matrix:
os:
- name: Linux
id: ubuntu-26.04
artifact: composer-environment-linux
- name: Windows
id: windows-2025
artifact: composer-environment-windows
runs-on: ${{ matrix.os.id }}
steps:
- uses: actions/checkout@v7
- name: Set up PHP with FFI
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: ffi, mbstring
ini-values: ffi.enable=true
coverage: none
env:
fail-fast: true
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Archive Composer environment
run: tar -czf composer-environment.tar.gz vendor
- name: Share Composer environment
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os.artifact }}
path: composer-environment.tar.gz
if-no-files-found: error
retention-days: 1
test:
needs: setup
name: "${{ matrix.os.name }} (PHP ${{ matrix.php.name }}) - ${{ matrix.suite }}"
strategy:
fail-fast: false
matrix:
os:
- name: Linux
id: ubuntu-26.04
artifact: composer-environment-linux
- name: Windows
id: windows-2025
artifact: composer-environment-windows
php:
- name: 8.4 NTS
version: '8.4'
phpts: nts
- name: 8.4 TS
version: '8.4'
phpts: ts
- name: 8.5 NTS
version: '8.5'
phpts: nts
- name: 8.5 TS
version: '8.5'
phpts: ts
- name: 8.6 NTS
version: '8.6'
phpts: nts
- name: 8.6 TS
version: '8.6'
phpts: ts
suite: [communism, zendful]
runs-on: ${{ matrix.os.id }}
steps:
- uses: actions/checkout@v7
- name: Set up PHP with FFI
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php.version }}
extensions: ffi, mbstring
ini-values: ffi.enable=true
coverage: none
env:
fail-fast: true
phpts: ${{ matrix.php.phpts }}
- name: Verify PHP and FFI
shell: bash
run: |
php --version
php --ri ffi
php -r '
if (!extension_loaded("ffi")) {
fwrite(STDERR, "FFI extension is not loaded\n");
exit(1);
}
if (ini_get("ffi.enable") !== "1") {
fwrite(STDERR, "FFI is not fully enabled\n");
exit(1);
}
echo "FFI is working\n";
'
- name: Restore Composer environment
uses: actions/download-artifact@v8
with:
name: ${{ matrix.os.artifact }}
- name: Extract Composer environment
shell: bash
run: tar -xzf composer-environment.tar.gz
- name: Add Composer binaries to PATH (Linux)
if: matrix.os.name == 'Linux'
shell: bash
run: echo "$GITHUB_WORKSPACE/vendor/bin" >> "$GITHUB_PATH"
- name: Add Composer binaries to PATH (Windows)
if: matrix.os.name == 'Windows'
shell: pwsh
run: Add-Content -Path $env:GITHUB_PATH -Value (Join-Path $env:GITHUB_WORKSPACE 'vendor\bin')
- name: Set up ProcDump (Windows)
if: matrix.os.name == 'Windows'
shell: pwsh
run: |
$dumpDirectory = Join-Path $env:RUNNER_TEMP 'php-crash-dumps'
New-Item -ItemType Directory -Path $dumpDirectory -Force | Out-Null
$archive = Join-Path $env:RUNNER_TEMP 'procdump.zip'
$procdumpDirectory = Join-Path $env:RUNNER_TEMP 'procdump'
Invoke-WebRequest -Uri 'https://download.sysinternals.com/files/Procdump.zip' -OutFile $archive
Expand-Archive -Path $archive -DestinationPath $procdumpDirectory -Force
Add-Content -Path $env:GITHUB_PATH -Value $procdumpDirectory
- name: Run ${{ matrix.suite }} test suite
if: matrix.os.name != 'Windows'
run: composer run-script test:${{ matrix.suite }}
- name: Run ${{ matrix.suite }} test suite under ProcDump (Windows)
if: matrix.os.name == 'Windows'
shell: pwsh
run: |
$dumpDirectory = Join-Path $env:RUNNER_TEMP 'php-crash-dumps'
$procdump = Join-Path $env:RUNNER_TEMP 'procdump\procdump.exe'
$installed = $false
$testExitCode = 0
$waitForDump = $false
$testLog = Join-Path $dumpDirectory 'test-output.log'
try {
# Install ProcDump as Windows' postmortem debugger. This catches
# crashes in PHPStan and any other child process without needing
# to predict or poll the process tree.
$install = Start-Process -FilePath $procdump -ArgumentList @(
'-accepteula',
'-ma',
'-i',
$dumpDirectory
) -Wait -PassThru -NoNewWindow
if ($install.ExitCode -ne 0) {
throw "ProcDump installation failed (exit code $($install.ExitCode))"
}
$installed = $true
Write-Host 'ProcDump installation succeeded; registered AeDebug entries:'
& reg.exe query 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug' /s
& reg.exe query 'HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug' /s
& composer run-script "test:${{ matrix.suite }}" 2>&1 |
Tee-Object -FilePath $testLog
$testExitCode = $LASTEXITCODE
$waitForDump = Select-String -LiteralPath $testLog -Pattern '-1073741819|Child process error \(exit code' -Quiet
if ($testExitCode -ne 0) {
exit $testExitCode
}
} finally {
if ($installed) {
if ($waitForDump) {
# AeDebug starts ProcDump after the crashing process has
# terminated. Wait for it to finish writing before
# unregistering ProcDump and moving to artifact steps.
$deadline = (Get-Date).AddSeconds(360)
$previousLength = -1L
do {
$dump = Get-ChildItem -LiteralPath $dumpDirectory -Filter '*.dmp' -File -ErrorAction SilentlyContinue |
Select-Object -First 1
if ($null -ne $dump) {
Start-Sleep -Seconds 1
$currentLength = (Get-Item -LiteralPath $dump.FullName).Length
if ($currentLength -eq $previousLength) {
break
}
$previousLength = $currentLength
} else {
Start-Sleep -Milliseconds 500
}
} while ((Get-Date) -lt $deadline)
}
& $procdump '-u' | Out-Host
}
}
- name: Detect PHP crash dump (Windows)
if: failure() && matrix.os.name == 'Windows'
id: php-crash
shell: pwsh
run: |
$dumpDirectory = Join-Path $env:RUNNER_TEMP 'php-crash-dumps'
Write-Host 'Windows crash-dump directory contents:'
Get-ChildItem -LiteralPath $dumpDirectory -Force -ErrorAction SilentlyContinue |
Select-Object FullName, Length, LastWriteTime
$dump = Get-ChildItem -LiteralPath $dumpDirectory -Filter '*.dmp' -File -ErrorAction SilentlyContinue | Select-Object -First 1
"found=$([bool]$dump)" | Add-Content -Path $env:GITHUB_OUTPUT
- name: Collect PHP debug files (Windows)
if: failure() && matrix.os.name == 'Windows' && steps.php-crash.outputs.found == 'true'
shell: pwsh
run: |
$dumpDirectory = Join-Path $env:RUNNER_TEMP 'php-crash-dumps'
$symbols = Join-Path $dumpDirectory 'symbols'
$phpDirectory = Split-Path (Get-Command php).Source
New-Item -ItemType Directory -Path $symbols -Force | Out-Null
Get-ChildItem -Path $phpDirectory -File |
Where-Object Extension -in '.exe', '.dll', '.pdb' |
Copy-Item -Destination $symbols -Force
Get-ChildItem -Path (Join-Path $phpDirectory 'ext') -File |
Where-Object Extension -in '.dll', '.pdb' |
Copy-Item -Destination $symbols -Force
- name: Upload PHP crash dumps (Windows)
if: failure() && matrix.os.name == 'Windows' && steps.php-crash.outputs.found == 'true'
uses: actions/upload-artifact@v7
with:
name: php-crash-dumps-${{ matrix.php.name }}-${{ matrix.suite }}
path: ${{ runner.temp }}/php-crash-dumps
if-no-files-found: ignore
retention-days: 3