Skip to content

Commit 69daefa

Browse files
committed
ci: isolate compiler PHP extension config
1 parent 6fe13b9 commit 69daefa

2 files changed

Lines changed: 47 additions & 15 deletions

File tree

.github/workflows/linux-x64.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ jobs:
120120
shell: bash
121121
run: |
122122
php_ini_dir="$(php-config --ini-dir)"
123-
echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" \
124-
| sudo tee "${php_ini_dir}/90-phpy.ini"
123+
{
124+
echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so"
125+
echo "phpy.enable_operator_overloading=0"
126+
} | sudo tee "${php_ini_dir}/90-phpy.ini"
125127
echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}"
126128
php --ri phpy
127129
@@ -231,8 +233,10 @@ jobs:
231233
shell: bash
232234
run: |
233235
php_ini_dir="$(php-config --ini-dir)"
234-
echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" \
235-
| sudo tee "${php_ini_dir}/90-phpy.ini"
236+
{
237+
echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so"
238+
echo "phpy.enable_operator_overloading=0"
239+
} | sudo tee "${php_ini_dir}/90-phpy.ini"
236240
echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}"
237241
php --ri phpy
238242
@@ -338,16 +342,19 @@ jobs:
338342
shell: bash
339343
run: |
340344
php_ini_dir="$(php-config --ini-dir)"
341-
echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" \
342-
| sudo tee "${php_ini_dir}/90-phpy.ini"
343-
echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}"
344-
php --ri phpy
345+
{
346+
echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so"
347+
echo "phpy.enable_operator_overloading=0"
348+
} | sudo tee "${php_ini_dir}/90-phpy.ini"
349+
echo "TYPEPHP_COMPILER_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}"
350+
PHP_INI_SCAN_DIR="${php_ini_dir}" php --ri phpy
345351
346352
- name: Run EXT/LIB integration tests
347353
shell: bash
348354
run: |
349355
php -n bin/run-integration-tests.php \
350356
--compiler=./tpc \
357+
--compiler-ini-scan-dir="${TYPEPHP_COMPILER_INI_SCAN_DIR}" \
351358
--php="$(command -v php)" \
352359
--php-fpm="${PHP_FPM}"
353360
@@ -450,8 +457,10 @@ jobs:
450457
shell: bash
451458
run: |
452459
php_ini_dir="$(php-config --ini-dir)"
453-
echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" \
454-
| sudo tee "${php_ini_dir}/90-phpy.ini"
460+
{
461+
echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so"
462+
echo "phpy.enable_operator_overloading=0"
463+
} | sudo tee "${php_ini_dir}/90-phpy.ini"
455464
echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}"
456465
php --ri phpy
457466

bin/run-integration-tests.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ final class IntegrationFailure extends RuntimeException
1818
{
1919
}
2020

21-
/** @return array{compiler: string, php: string, php_fpm: string, keep: bool, suite: string} */
21+
/** @return array{compiler: string, compiler_ini_scan_dir: string, php: string, php_fpm: string, keep: bool, suite: string} */
2222
function parseIntegrationOptions(array $argv): array
2323
{
2424
$options = [
2525
'compiler' => TYPEPHP_INTEGRATION_ROOT . '/tpc',
26+
'compiler_ini_scan_dir' => '',
2627
'php' => PHP_BINARY,
2728
'php_fpm' => '',
2829
'keep' => false,
@@ -38,7 +39,7 @@ function parseIntegrationOptions(array $argv): array
3839
$options['suite'] = substr($argument, strlen('--suite='));
3940
continue;
4041
}
41-
foreach (['compiler', 'php', 'php-fpm'] as $name) {
42+
foreach (['compiler', 'compiler-ini-scan-dir', 'php', 'php-fpm'] as $name) {
4243
$prefix = '--' . $name . '=';
4344
if (str_starts_with($argument, $prefix)) {
4445
$key = str_replace('-', '_', $name);
@@ -61,6 +62,16 @@ function parseIntegrationOptions(array $argv): array
6162
$options[$name] = $path;
6263
}
6364

65+
if ($options['compiler_ini_scan_dir'] !== '') {
66+
$path = realpath($options['compiler_ini_scan_dir']);
67+
if ($path === false || !is_dir($path)) {
68+
throw new IntegrationFailure(
69+
'compiler ini scan directory does not exist: ' . $options['compiler_ini_scan_dir'],
70+
);
71+
}
72+
$options['compiler_ini_scan_dir'] = $path;
73+
}
74+
6475
if ($options['suite'] !== 'lib') {
6576
if ($options['php_fpm'] === '') {
6677
$prefix = integrationPhpPrefix($options['php']);
@@ -185,6 +196,18 @@ function integrationEnvironment(): array
185196
return getenv();
186197
}
187198

199+
/**
200+
* @param array{compiler_ini_scan_dir: string} $options
201+
* @return array<string, string>
202+
*/
203+
function integrationCompilerEnvironment(array $options): array
204+
{
205+
if ($options['compiler_ini_scan_dir'] === '') {
206+
return [];
207+
}
208+
return ['PHP_INI_SCAN_DIR' => $options['compiler_ini_scan_dir']];
209+
}
210+
188211
function assertIntegrationSame(string $expected, string $actual, string $message): void
189212
{
190213
if ($expected !== $actual) {
@@ -461,7 +484,7 @@ function runExtIntegration(array $options, string $temporaryRoot): void
461484
'--build-dir', $temporaryRoot . '/ext-build-' . $name,
462485
'--job', '1',
463486
'--no-progress',
464-
]);
487+
], environment: integrationCompilerEnvironment($options));
465488
assertIntegrationTrue(is_file($extension), 'Extension artifact was not generated: ' . $extension);
466489
$extensions[$name] = $extension;
467490
}
@@ -601,7 +624,7 @@ function runLibIntegration(array $options, string $temporaryRoot): void
601624
$options['compiler'], $providerRoot . '/project.yml',
602625
'--output', $providerRoot . '/' . $target . '.' . PHP_SHLIB_SUFFIX,
603626
'--build-dir', $providerRoot . '/build', '--job', '1', '--no-progress',
604-
]);
627+
], environment: integrationCompilerEnvironment($options));
605628

606629
$library = $providerRoot . '/' . $target . '.' . PHP_SHLIB_SUFFIX;
607630
$stub = $providerRoot . '/' . $target . '.stub.php';
@@ -648,7 +671,7 @@ function runLibIntegration(array $options, string $temporaryRoot): void
648671
'--build-dir', $consumerRoot . '/build',
649672
'--link-path', $linkRoot,
650673
'--job', '1', '--no-progress',
651-
]);
674+
], environment: integrationCompilerEnvironment($options));
652675
$libraryPath = $linkRoot;
653676
$environment = PHP_OS_FAMILY === 'Darwin'
654677
? ['DYLD_LIBRARY_PATH' => $libraryPath . ':' . (getenv('DYLD_LIBRARY_PATH') ?: '')]

0 commit comments

Comments
 (0)