Skip to content

Commit 694c842

Browse files
authored
PHPC-2721: Test PECL package installation on Alpine Linux (#2024)
Test PECL package installation on Alpine Linux
1 parent a71cc80 commit 694c842

4 files changed

Lines changed: 43 additions & 4 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM php:alpine
2+
3+
RUN apk add --no-cache \
4+
autoconf \
5+
build-base \
6+
openssl-dev
7+
8+
COPY mongodb-*.tgz /tmp/mongodb.tgz
9+
10+
# Install from the PECL package (fresh configure+build in a temp directory,
11+
# same as a real user install, but without zstd available)
12+
RUN pecl install --nodeps /tmp/mongodb.tgz < /dev/null
13+
14+
# Verify the extension loads correctly
15+
RUN php -n -d extension=mongodb.so --ri mongodb

.github/workflows/tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ jobs:
130130
- name: "Install release archive to verify correctness"
131131
run: sudo pecl install ${{ env.PACKAGE_FILE }}
132132

133+
- name: "Install on Alpine Linux"
134+
run: |
135+
cp "${{ env.PACKAGE_FILE }}" .github/docker/
136+
docker build .github/docker/ -f .github/docker/Dockerfile.pecl-alpine
137+
133138
windows-test:
134139
name: "Windows Tests"
135140
runs-on: "${{ matrix.os }}"

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ will report `phpinfo()` output for the extension:
2828
$ php --ri mongodb
2929
```
3030

31+
## Testing the PECL package on Alpine Linux
32+
33+
Alpine Linux uses musl libc instead of glibc and does not include zstd by default. It is
34+
a popular base image for PHP Docker containers and represents a distinct build environment
35+
from RHEL/Debian. Testing PECL installation on Alpine catches issues that would not appear
36+
on glibc-based systems, such as missing POSIX extensions (e.g. `GLOB_BRACE`) or generated
37+
config headers that are incorrectly bundled in the package.
38+
39+
First generate the PECL package, then test installation on Alpine:
40+
41+
```
42+
make package.xml RELEASE_NOTES_FILE=/dev/null
43+
make package
44+
cp mongodb-*.tgz .github/docker/
45+
docker build .github/docker/ -f .github/docker/Dockerfile.pecl-alpine
46+
```
47+
3148
## Generating arginfo from stub files
3249

3350
Arginfo structures are generated from stub files using the `gen_stub.php`

bin/prep-release.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?php
2+
if (!defined('GLOB_BRACE')) {
3+
echo "Error: GLOB_BRACE is not available on this system\n";
4+
exit(1);
5+
}
6+
27
function verify_stability($stability) {
38
$stabilities = array(
49
"snapshot",
@@ -74,8 +79,6 @@ function get_files() {
7479
"src/libmongocrypt/kms-message/src/kms_message/*.{c,h}",
7580
),
7681
'test' => array(
77-
"Vagrantfile",
78-
7982
"scripts/*/*.{sh}",
8083
"scripts/*.{json,php,py,sh}",
8184
"tests/utils/*.{inc,json.gz,php}",
@@ -92,7 +95,7 @@ function get_files() {
9295
$files = array();
9396
foreach($dirs as $role => $patterns) {
9497
foreach ($patterns as $pattern) {
95-
foreach (glob($pattern, GLOB_BRACE) as $file) {
98+
foreach (glob($pattern, GLOB_BRACE) ?: [] as $file) {
9699
$files[$file] = $role;
97100
}
98101
}
@@ -215,4 +218,3 @@ function usage() {
215218

216219
file_put_contents(__DIR__ . "/../package.xml", $contents);
217220
echo "Wrote package.xml\n";
218-

0 commit comments

Comments
 (0)