Skip to content

Commit 57ac552

Browse files
committed
Add reli integration CI: reli must read an ext-rdump dump
Builds the extension, writes a dump with rdump_dump(..., full=true), then runs reli's inspector:memory:dump:inspect and inspector:memory:analyze on it, asserting the RDUMP magic, format version 3, and a completed report. This guards the extension's reason to exist -- byte-compatibility with the RDUMP format reli consumes. https://claude.ai/code/session_017skw8BsHkF8wur7Pf4G9W5
1 parent 473041e commit 57ac552

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,27 @@ jobs:
4848
"php:${{ matrix.php }}-${{ matrix.ts }}" \
4949
sh ci/build-and-test.sh
5050
51+
reli-integration:
52+
name: reli reads an ext-rdump dump (PHP 8.4)
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v5
56+
with:
57+
path: ext
58+
59+
- uses: actions/checkout@v5
60+
with:
61+
repository: reliforp/reli-prof
62+
path: reli
63+
64+
- name: Dump with ext-rdump, then read it with reli
65+
run: |
66+
docker run --rm \
67+
-e CI=1 \
68+
-v "$PWD/ext":/ext -v "$PWD/reli":/reli -w /ext \
69+
php:8.4-cli \
70+
sh ci/reli-integration.sh
71+
5172
leak-check:
5273
name: Leak check PHP 8.4 ${{ matrix.ts == 'zts' && 'ZTS' || 'NTS' }}
5374
runs-on: ubuntu-latest

ci/reli-integration.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/sh
2+
# Integration test: a dump produced by ext-rdump must be readable by reli,
3+
# the very tool it targets. Builds the extension, writes a dump, then has
4+
# reli parse and analyse it.
5+
#
6+
# Run inside an official php:8.4-cli image with both trees mounted:
7+
# docker run --rm -v "$PWD/ext":/ext -v "$PWD/reli":/reli -w /ext \
8+
# php:8.4-cli sh ci/reli-integration.sh
9+
#
10+
# /ext = this extension's source tree
11+
# /reli = a checkout of reliforp/reli-prof
12+
set -eux
13+
14+
# --- toolchain + the extensions reli itself needs --------------------
15+
apt-get update
16+
apt-get install -y --no-install-recommends $PHPIZE_DEPS git unzip libffi-dev
17+
docker-php-ext-install -j"$(nproc)" ffi pcntl
18+
19+
# --- composer --------------------------------------------------------
20+
php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');"
21+
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
22+
rm -f /tmp/composer-setup.php
23+
24+
# --- build ext-rdump -------------------------------------------------
25+
cd /ext
26+
phpize
27+
./configure --enable-rdump
28+
make -j"$(nproc)"
29+
SO="/ext/modules/rdump.so"
30+
php -d extension="$SO" --ri rdump
31+
32+
# --- install reli ----------------------------------------------------
33+
cd /reli
34+
composer install --no-interaction --no-progress
35+
36+
# --- produce a dump with the extension -------------------------------
37+
DUMP=/tmp/reli-integration.rdump
38+
export DUMP
39+
rm -f "$DUMP"
40+
php -d extension="$SO" -r '
41+
// Keep distinctive live data on the heap so the analysis has substance.
42+
$marker = array_fill(0, 1000, str_repeat("reli-rdump-integration", 32));
43+
if (!rdump_dump(getenv("DUMP"), true)) {
44+
fwrite(STDERR, "rdump_dump() returned false\n");
45+
exit(1);
46+
}
47+
'
48+
test -s "$DUMP"
49+
50+
# --- reli must read it ----------------------------------------------
51+
# FFI is enabled explicitly; reli wires FFI bindings at bootstrap even when
52+
# reading a file rather than attaching to a live process.
53+
INSPECT="$(php -d ffi.enable=1 reli inspector:memory:dump:inspect "$DUMP")"
54+
echo "$INSPECT" | head -20
55+
echo "$INSPECT" | grep -q 'Magic:.*RDUMP' || { echo '::error::reli did not recognise the RDUMP magic'; exit 1; }
56+
echo "$INSPECT" | grep -q 'Format Version:.*3' || { echo '::error::reli read an unexpected format version'; exit 1; }
57+
58+
# Full analysis must also complete without error.
59+
php -d ffi.enable=1 reli inspector:memory:analyze "$DUMP" -f report \
60+
| tee /tmp/reli-analyze.log | head -30
61+
grep -q 'Memory Analysis Report' /tmp/reli-analyze.log \
62+
|| { echo '::error::reli analyze did not produce a report'; exit 1; }
63+
64+
echo "reli-integration OK"

0 commit comments

Comments
 (0)