-
Notifications
You must be signed in to change notification settings - Fork 6
375 lines (342 loc) · 11.6 KB
/
build-linux.yml
File metadata and controls
375 lines (342 loc) · 11.6 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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
name: True Async Linux x64 Build
on:
push:
branches: [main]
jobs:
build-linux-x64:
strategy:
fail-fast: false
matrix:
debug: [true, false]
zts: [true, false]
asan: [false, true]
exclude:
# Only run ASAN on debug+zts build to reduce test matrix
- asan: true
debug: false
- asan: true
zts: false
name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || ''}}"
runs-on: ubuntu-22.04
timeout-minutes: ${{ matrix.asan && 360 || 60 }}
env:
MYSQL_TEST_HOST: 127.0.0.1
MYSQL_TEST_PORT: 3306
MYSQL_TEST_USER: root
MYSQL_TEST_PASSWD: root
MYSQL_TEST_DB: test
PDO_MYSQL_TEST_DSN: "mysql:host=127.0.0.1;dbname=test"
PDO_MYSQL_TEST_HOST: 127.0.0.1
PDO_MYSQL_TEST_USER: root
PDO_MYSQL_TEST_PASS: root
PDO_PGSQL_TEST_DSN: "pgsql:host=127.0.0.1 port=5432 dbname=test user=postgres password=postgres"
services:
mysql:
image: mysql:8.3
ports:
- 3306:3306
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: root
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout php-async repo
uses: actions/checkout@v4
with:
path: async
- name: Clone php-src (true-async-stable)
run: |
git clone --depth=1 --branch=true-async-stable https://github.com/true-async/php-src php-src
- name: Copy php-async extension into php-src
run: |
mkdir -p php-src/ext/async
cp -r async/* php-src/ext/async/
- name: Install build dependencies
working-directory: php-src
run: |
set -x
sudo apt-get update -y
# Standard PHP dependencies
sudo apt-get install -y \
autoconf \
bison \
build-essential \
curl \
re2c \
libxml2-dev \
libssl-dev \
pkg-config \
libargon2-dev \
libcurl4-openssl-dev \
libedit-dev \
libsodium-dev \
libsqlite3-dev \
libonig-dev \
libzip-dev \
libpng-dev \
libjpeg-dev \
libwebp-dev \
libfreetype6-dev \
libgmp-dev \
libldap2-dev \
libsasl2-dev \
libpq-dev \
libmysqlclient-dev \
libbz2-dev \
libenchant-2-dev \
libffi-dev \
libgdbm-dev \
liblmdb-dev \
libsnmp-dev \
libtidy-dev \
libxslt1-dev \
libicu-dev
# Build LibUV from source (need >= 1.45.0)
sudo apt-get install -y cmake ninja-build
# Download and build LibUV 1.48.0
wget https://github.com/libuv/libuv/archive/v1.48.0.tar.gz
tar -xzf v1.48.0.tar.gz
cd libuv-1.48.0
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
ninja
sudo ninja install
sudo ldconfig
cd ../..
# Build libcurl from source (need >= 7.87.0 for TrueAsync)
wget https://github.com/curl/curl/releases/download/curl-8_5_0/curl-8.5.0.tar.gz
tar -xzf curl-8.5.0.tar.gz
cd curl-8.5.0
./configure --prefix=/usr/local --with-openssl --enable-shared --disable-static
make -j$(nproc)
sudo make install
sudo ldconfig
cd ..
# ASAN dependencies if needed
if [ "${{ matrix.asan }}" = "true" ]; then
sudo apt-get install -y clang-14 lldb-14
fi
- name: System info
run: |
echo "::group::Show host CPU info"
lscpu
echo "::endgroup::"
echo "::group::Show installed package versions"
dpkg -l | grep -E "(libuv|clang)" || true
echo "::endgroup::"
echo "::group::Show LibUV version"
pkg-config --modversion libuv || echo "LibUV version not available via pkg-config"
echo "::endgroup::"
- name: Configure PHP
working-directory: php-src
run: |
set -x
# Set compiler flags based on matrix
CFLAGS=""
LDFLAGS=""
CC="gcc"
CXX="g++"
if [ "${{ matrix.asan }}" = "true" ]; then
CFLAGS="-fsanitize=address,undefined -fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC -DZEND_RC_DEBUG=1"
LDFLAGS="-fsanitize=address,undefined -fno-sanitize=function"
CC="clang-14"
CXX="clang++-14"
fi
./buildconf --force
# Configure with async extension
CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CC="$CC" CXX="$CXX" ./configure \
--enable-option-checking=fatal \
--prefix=/usr/local \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pgsql \
--with-pdo-pgsql \
--with-pdo-sqlite \
--without-pear \
--enable-gd \
--with-jpeg \
--with-webp \
--with-freetype \
--enable-exif \
--with-zip \
--with-zlib \
--enable-soap \
--enable-xmlreader \
--with-xsl \
--with-tidy \
--with-libxml \
--enable-sysvsem \
--enable-sysvshm \
--enable-shmop \
--enable-pcntl \
--with-readline \
--enable-mbstring \
--with-curl \
--with-gettext \
--enable-sockets \
--with-bz2 \
--with-openssl \
--with-gmp \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--with-enchant \
--enable-sysvmsg \
--with-ffi \
--enable-zend-test \
--enable-dl-test=shared \
--with-ldap \
--with-ldap-sasl \
--enable-intl \
--with-mhash \
--with-sodium \
--enable-dba \
--with-lmdb \
--with-gdbm \
--with-snmp \
--enable-werror \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--${{ matrix.debug && 'enable' || 'disable' }}-debug \
--${{ matrix.zts && 'enable' || 'disable' }}-zts \
--enable-async
- name: Build PHP
working-directory: php-src
run: |
# Use reduced parallelism for ASAN to prevent timeouts
PARALLEL_JOBS=${{ matrix.asan && '$(nproc)' || '$(nproc)' }}
make -j$PARALLEL_JOBS >/dev/null
- name: Install PHP
working-directory: php-src
run: |
sudo make install
sudo mkdir -p /etc/php.d
echo "opcache.enable_cli=1" | sudo tee /etc/php.d/opcache.ini
- name: Enable core dumps (ASAN only)
if: matrix.asan == true
run: |
sudo mkdir -p /tmp/cores
sudo chmod 1777 /tmp/cores
echo '/tmp/cores/core.%e.%p' | sudo tee /proc/sys/kernel/core_pattern
sudo sysctl -w kernel.core_uses_pid=0
ulimit -c unlimited
# Tell ASAN to abort (so glibc dumps core) instead of just exit
echo "ASAN_OPTIONS=abort_on_error=1:disable_coredump=0:unmap_shadow_on_exit=1" >> $GITHUB_ENV
- name: Run basic tests
working-directory: php-src/ext/async
continue-on-error: ${{ matrix.asan == true }}
run: |
ulimit -c unlimited
/usr/local/bin/php -v
# Configure test parameters based on ASAN
TEST_PARAMS=""
if [ "${{ matrix.asan }}" = "true" ]; then
TEST_PARAMS="--asan -x"
PARALLEL_JOBS="$(expr $(nproc) - 1)" # Leave one CPU idle for ASAN
else
PARALLEL_JOBS="$(nproc)"
fi
/usr/local/bin/php ../../run-tests.php \
$TEST_PARAMS \
-P -q -j$PARALLEL_JOBS \
-g FAIL,BORK,LEAK,XLEAK \
--no-progress \
--offline \
--show-diff \
--show-slow 4000 \
--set-timeout 120 \
.
- name: Collect core dumps + backtraces (ASAN only)
if: matrix.asan == true && always()
run: |
sudo apt-get install -y --no-install-recommends gdb
mkdir -p /tmp/bt
shopt -s nullglob
for core in /tmp/cores/core.*; do
base=$(basename "$core")
echo "=== $base ===" | tee /tmp/bt/${base}.bt.txt
sudo gdb -batch -nx \
-ex 'set pagination off' \
-ex 'set print pretty on' \
-ex 'thread apply all bt 60' \
/usr/local/bin/php "$core" >> /tmp/bt/${base}.bt.txt 2>&1 || true
done
ls -la /tmp/cores/ /tmp/bt/ || true
- name: Upload core dumps + backtraces (ASAN only)
if: matrix.asan == true && always()
uses: actions/upload-artifact@v4
with:
name: asan-cores-${{ github.run_id }}-${{ github.run_attempt }}
path: |
/tmp/cores/
/tmp/bt/
php-src/sapi/cli/php
php-src/ext/async/tests/thread_pool/*.out
php-src/ext/async/tests/thread_pool/*.diff
if-no-files-found: warn
retention-days: 7
- name: Test OpCache
working-directory: php-src/ext/async
run: |
TEST_PARAMS=""
if [ "${{ matrix.asan }}" = "true" ]; then
TEST_PARAMS="--asan -x"
PARALLEL_JOBS="$(expr $(nproc) - 1)"
else
PARALLEL_JOBS="$(nproc)"
fi
/usr/local/bin/php ../../run-tests.php \
$TEST_PARAMS \
-d opcache.enable_cli=1 \
-P -q -j$PARALLEL_JOBS \
-g FAIL,BORK,LEAK,XLEAK \
--no-progress \
--offline \
--show-diff \
--show-slow 4000 \
--set-timeout 120 \
.
- name: Test Tracing JIT
# Skip JIT with ASAN due to complexity
if: matrix.asan != true
working-directory: php-src/ext/async
run: |
/usr/local/bin/php ../../run-tests.php \
-d opcache.enable_cli=1 \
-d opcache.jit_buffer_size=64M \
-d opcache.jit=tracing \
-P -q -j$(nproc) \
-g FAIL,BORK,LEAK,XLEAK \
--no-progress \
--offline \
--show-diff \
--show-slow 4000 \
--set-timeout 120 \
.
- name: Test Function JIT
# Skip JIT with ASAN due to complexity
if: matrix.asan != true
working-directory: php-src/ext/async
run: |
/usr/local/bin/php ../../run-tests.php \
-d opcache.enable_cli=1 \
-d opcache.jit_buffer_size=64M \
-d opcache.jit=function \
-P -q -j$(nproc) \
-g FAIL,BORK,LEAK,XLEAK \
--no-progress \
--offline \
--show-diff \
--show-slow 4000 \
--set-timeout 120 \
.