From 69daefafb5b7ffe7ce4f6dd104ec9ae15f0c08b4 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Mon, 21 Sep 2026 16:32:03 +0800 Subject: [PATCH] ci: isolate compiler PHP extension config --- .github/workflows/linux-x64.yml | 29 +++++++++++++++++++---------- bin/run-integration-tests.php | 33 ++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/.github/workflows/linux-x64.yml b/.github/workflows/linux-x64.yml index 6c8b7c6a..7df7e588 100644 --- a/.github/workflows/linux-x64.yml +++ b/.github/workflows/linux-x64.yml @@ -120,8 +120,10 @@ jobs: shell: bash run: | php_ini_dir="$(php-config --ini-dir)" - echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" \ - | sudo tee "${php_ini_dir}/90-phpy.ini" + { + echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" + echo "phpy.enable_operator_overloading=0" + } | sudo tee "${php_ini_dir}/90-phpy.ini" echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}" php --ri phpy @@ -231,8 +233,10 @@ jobs: shell: bash run: | php_ini_dir="$(php-config --ini-dir)" - echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" \ - | sudo tee "${php_ini_dir}/90-phpy.ini" + { + echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" + echo "phpy.enable_operator_overloading=0" + } | sudo tee "${php_ini_dir}/90-phpy.ini" echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}" php --ri phpy @@ -338,16 +342,19 @@ jobs: shell: bash run: | php_ini_dir="$(php-config --ini-dir)" - echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" \ - | sudo tee "${php_ini_dir}/90-phpy.ini" - echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}" - php --ri phpy + { + echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" + echo "phpy.enable_operator_overloading=0" + } | sudo tee "${php_ini_dir}/90-phpy.ini" + echo "TYPEPHP_COMPILER_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}" + PHP_INI_SCAN_DIR="${php_ini_dir}" php --ri phpy - name: Run EXT/LIB integration tests shell: bash run: | php -n bin/run-integration-tests.php \ --compiler=./tpc \ + --compiler-ini-scan-dir="${TYPEPHP_COMPILER_INI_SCAN_DIR}" \ --php="$(command -v php)" \ --php-fpm="${PHP_FPM}" @@ -450,8 +457,10 @@ jobs: shell: bash run: | php_ini_dir="$(php-config --ini-dir)" - echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" \ - | sudo tee "${php_ini_dir}/90-phpy.ini" + { + echo "extension=${GITHUB_WORKSPACE}/third_party/phpy/modules/phpy.so" + echo "phpy.enable_operator_overloading=0" + } | sudo tee "${php_ini_dir}/90-phpy.ini" echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}" php --ri phpy diff --git a/bin/run-integration-tests.php b/bin/run-integration-tests.php index 9892005b..5894ad1e 100755 --- a/bin/run-integration-tests.php +++ b/bin/run-integration-tests.php @@ -18,11 +18,12 @@ final class IntegrationFailure extends RuntimeException { } -/** @return array{compiler: string, php: string, php_fpm: string, keep: bool, suite: string} */ +/** @return array{compiler: string, compiler_ini_scan_dir: string, php: string, php_fpm: string, keep: bool, suite: string} */ function parseIntegrationOptions(array $argv): array { $options = [ 'compiler' => TYPEPHP_INTEGRATION_ROOT . '/tpc', + 'compiler_ini_scan_dir' => '', 'php' => PHP_BINARY, 'php_fpm' => '', 'keep' => false, @@ -38,7 +39,7 @@ function parseIntegrationOptions(array $argv): array $options['suite'] = substr($argument, strlen('--suite=')); continue; } - foreach (['compiler', 'php', 'php-fpm'] as $name) { + foreach (['compiler', 'compiler-ini-scan-dir', 'php', 'php-fpm'] as $name) { $prefix = '--' . $name . '='; if (str_starts_with($argument, $prefix)) { $key = str_replace('-', '_', $name); @@ -61,6 +62,16 @@ function parseIntegrationOptions(array $argv): array $options[$name] = $path; } + if ($options['compiler_ini_scan_dir'] !== '') { + $path = realpath($options['compiler_ini_scan_dir']); + if ($path === false || !is_dir($path)) { + throw new IntegrationFailure( + 'compiler ini scan directory does not exist: ' . $options['compiler_ini_scan_dir'], + ); + } + $options['compiler_ini_scan_dir'] = $path; + } + if ($options['suite'] !== 'lib') { if ($options['php_fpm'] === '') { $prefix = integrationPhpPrefix($options['php']); @@ -185,6 +196,18 @@ function integrationEnvironment(): array return getenv(); } +/** + * @param array{compiler_ini_scan_dir: string} $options + * @return array + */ +function integrationCompilerEnvironment(array $options): array +{ + if ($options['compiler_ini_scan_dir'] === '') { + return []; + } + return ['PHP_INI_SCAN_DIR' => $options['compiler_ini_scan_dir']]; +} + function assertIntegrationSame(string $expected, string $actual, string $message): void { if ($expected !== $actual) { @@ -461,7 +484,7 @@ function runExtIntegration(array $options, string $temporaryRoot): void '--build-dir', $temporaryRoot . '/ext-build-' . $name, '--job', '1', '--no-progress', - ]); + ], environment: integrationCompilerEnvironment($options)); assertIntegrationTrue(is_file($extension), 'Extension artifact was not generated: ' . $extension); $extensions[$name] = $extension; } @@ -601,7 +624,7 @@ function runLibIntegration(array $options, string $temporaryRoot): void $options['compiler'], $providerRoot . '/project.yml', '--output', $providerRoot . '/' . $target . '.' . PHP_SHLIB_SUFFIX, '--build-dir', $providerRoot . '/build', '--job', '1', '--no-progress', - ]); + ], environment: integrationCompilerEnvironment($options)); $library = $providerRoot . '/' . $target . '.' . PHP_SHLIB_SUFFIX; $stub = $providerRoot . '/' . $target . '.stub.php'; @@ -648,7 +671,7 @@ function runLibIntegration(array $options, string $temporaryRoot): void '--build-dir', $consumerRoot . '/build', '--link-path', $linkRoot, '--job', '1', '--no-progress', - ]); + ], environment: integrationCompilerEnvironment($options)); $libraryPath = $linkRoot; $environment = PHP_OS_FAMILY === 'Darwin' ? ['DYLD_LIBRARY_PATH' => $libraryPath . ':' . (getenv('DYLD_LIBRARY_PATH') ?: '')]