Skip to content

Commit 71ec49d

Browse files
committed
Added integration test to validate bundled PHP extension builds
1 parent 5eacb11 commit 71ec49d

3 files changed

Lines changed: 109 additions & 1 deletion

File tree

.github/workflows/continuous-integration.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,63 @@ jobs:
4242
env:
4343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4444

45+
bundled-php-extension-tests:
46+
runs-on: ${{ matrix.operating-system }}
47+
strategy:
48+
matrix:
49+
operating-system:
50+
- ubuntu-latest
51+
php-versions:
52+
- '8.1'
53+
- '8.2'
54+
- '8.3'
55+
- '8.4'
56+
#- '8.5' # @todo enable
57+
steps:
58+
- name: Install platform dependencies
59+
run: |
60+
sudo apt-get update
61+
sudo apt-get install -y --no-install-recommends \
62+
libcurl4-openssl-dev \
63+
liblmdb-dev \
64+
libdb-dev \
65+
libqdbm-dev \
66+
libenchant-2-dev \
67+
libexif-dev \
68+
libgd-dev \
69+
libpng-dev \
70+
libtiff-dev \
71+
libfreetype-dev \
72+
libfreetype6 \
73+
libfontconfig1-dev \
74+
libgmp-dev \
75+
libssl-dev \
76+
libsodium-dev \
77+
libxml2-dev \
78+
libonig-dev \
79+
libldap-dev \
80+
libedit-dev \
81+
libsnmp-dev \
82+
libtidy-dev \
83+
libxslt1-dev \
84+
libsasl2-dev \
85+
libzip-dev
86+
- name: Setup PHP
87+
uses: shivammathur/setup-php@v2
88+
with:
89+
php-version: ${{ matrix.php-versions }}
90+
extensions: none, mbstring
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
- uses: actions/checkout@v4
94+
- name: Composer Install
95+
run: composer install --ignore-platform-reqs
96+
- name: Run bundled PHP install test
97+
run: sudo php test/install-bundled-php-exts.php
98+
env:
99+
PHP_PIE_TEST_BUNDLED_PHP_EXTENSIONS: true
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
45102
behaviour-tests:
46103
runs-on: ${{ matrix.operating-system }}
47104
strategy:

src/ComposerIntegration/BundledPhpExtensionsRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ class BundledPhpExtensionsRepository extends ArrayRepository
4646
['name' => 'intl', 'version' => '>= 5.3.0'],
4747
['name' => 'ldap'],
4848
['name' => 'mbstring'],
49+
['name' => 'mysqlnd', 'version' => '>= 5.3.0'],
4950
[
5051
'name' => 'mysqli',
5152
'priority' => 90, // must load after mysqlnd
5253
],
53-
['name' => 'mysqlnd', 'version' => '>= 5.3.0'],
5454
// ['name' => 'odbc'], // build failure - cp: cannot stat '/usr/local/lib/odbclib.a': No such file or directory configure: error: ODBC header file '/usr/local/incl/sqlext.h' not found!
5555
[
5656
'name' => 'opcache',

test/install-bundled-php-exts.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Composer\Package\PackageInterface;
6+
use Php\Pie\ComposerIntegration\BundledPhpExtensionsRepository;
7+
use Php\Pie\Platform\TargetPhp\PhpBinaryPath;
8+
use Php\Pie\Platform\TargetPlatform;
9+
use Php\Pie\Util\Process;
10+
11+
require __DIR__ . '/../vendor/autoload.php';
12+
13+
$phpBinaryPath = PhpBinaryPath::fromCurrentProcess();
14+
15+
$packageNames = array_map(
16+
static fn (PackageInterface $package): string => $package->getName(),
17+
BundledPhpExtensionsRepository::forTargetPlatform(
18+
TargetPlatform::fromPhpBinaryPath(
19+
$phpBinaryPath,
20+
null,
21+
),
22+
)
23+
->getPackages(),
24+
);
25+
26+
$anyFailures = false;
27+
28+
foreach ($packageNames as $packageName) {
29+
$cmd = [
30+
'sudo',
31+
'bin/pie',
32+
'install',
33+
$packageName,
34+
'--with-php-config=' . $phpBinaryPath->phpConfigPath(),
35+
];
36+
37+
echo ' - ' . implode(' ', $cmd) . PHP_EOL;
38+
39+
try {
40+
Process::run($cmd, timeout: null);
41+
} catch (Throwable $e) {
42+
echo $e->__toString() . PHP_EOL;
43+
$anyFailures = true;
44+
}
45+
}
46+
47+
echo Process::run(['bin/pie', 'show', '--with-php-config=' . $phpBinaryPath->phpConfigPath()]);
48+
49+
if ($anyFailures) {
50+
exit(1);
51+
}

0 commit comments

Comments
 (0)