ci: isolate compiler PHP extension config

master
韩天峰 3 weeks ago
parent 6fe13b9548
commit 69daefafb5
  1. 29
      .github/workflows/linux-x64.yml
  2. 33
      bin/run-integration-tests.php

@ -120,8 +120,10 @@ jobs:
shell: bash shell: bash
run: | run: |
php_ini_dir="$(php-config --ini-dir)" 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}" echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}"
php --ri phpy php --ri phpy
@ -231,8 +233,10 @@ jobs:
shell: bash shell: bash
run: | run: |
php_ini_dir="$(php-config --ini-dir)" 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}" echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}"
php --ri phpy php --ri phpy
@ -338,16 +342,19 @@ jobs:
shell: bash shell: bash
run: | run: |
php_ini_dir="$(php-config --ini-dir)" 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 "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}" echo "phpy.enable_operator_overloading=0"
php --ri phpy } | 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 - name: Run EXT/LIB integration tests
shell: bash shell: bash
run: | run: |
php -n bin/run-integration-tests.php \ php -n bin/run-integration-tests.php \
--compiler=./tpc \ --compiler=./tpc \
--compiler-ini-scan-dir="${TYPEPHP_COMPILER_INI_SCAN_DIR}" \
--php="$(command -v php)" \ --php="$(command -v php)" \
--php-fpm="${PHP_FPM}" --php-fpm="${PHP_FPM}"
@ -450,8 +457,10 @@ jobs:
shell: bash shell: bash
run: | run: |
php_ini_dir="$(php-config --ini-dir)" 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}" echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}"
php --ri phpy php --ri phpy

@ -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 function parseIntegrationOptions(array $argv): array
{ {
$options = [ $options = [
'compiler' => TYPEPHP_INTEGRATION_ROOT . '/tpc', 'compiler' => TYPEPHP_INTEGRATION_ROOT . '/tpc',
'compiler_ini_scan_dir' => '',
'php' => PHP_BINARY, 'php' => PHP_BINARY,
'php_fpm' => '', 'php_fpm' => '',
'keep' => false, 'keep' => false,
@ -38,7 +39,7 @@ function parseIntegrationOptions(array $argv): array
$options['suite'] = substr($argument, strlen('--suite=')); $options['suite'] = substr($argument, strlen('--suite='));
continue; continue;
} }
foreach (['compiler', 'php', 'php-fpm'] as $name) { foreach (['compiler', 'compiler-ini-scan-dir', 'php', 'php-fpm'] as $name) {
$prefix = '--' . $name . '='; $prefix = '--' . $name . '=';
if (str_starts_with($argument, $prefix)) { if (str_starts_with($argument, $prefix)) {
$key = str_replace('-', '_', $name); $key = str_replace('-', '_', $name);
@ -61,6 +62,16 @@ function parseIntegrationOptions(array $argv): array
$options[$name] = $path; $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['suite'] !== 'lib') {
if ($options['php_fpm'] === '') { if ($options['php_fpm'] === '') {
$prefix = integrationPhpPrefix($options['php']); $prefix = integrationPhpPrefix($options['php']);
@ -185,6 +196,18 @@ function integrationEnvironment(): array
return getenv(); return getenv();
} }
/**
* @param array{compiler_ini_scan_dir: string} $options
* @return array<string, string>
*/
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 function assertIntegrationSame(string $expected, string $actual, string $message): void
{ {
if ($expected !== $actual) { if ($expected !== $actual) {
@ -461,7 +484,7 @@ function runExtIntegration(array $options, string $temporaryRoot): void
'--build-dir', $temporaryRoot . '/ext-build-' . $name, '--build-dir', $temporaryRoot . '/ext-build-' . $name,
'--job', '1', '--job', '1',
'--no-progress', '--no-progress',
]); ], environment: integrationCompilerEnvironment($options));
assertIntegrationTrue(is_file($extension), 'Extension artifact was not generated: ' . $extension); assertIntegrationTrue(is_file($extension), 'Extension artifact was not generated: ' . $extension);
$extensions[$name] = $extension; $extensions[$name] = $extension;
} }
@ -601,7 +624,7 @@ function runLibIntegration(array $options, string $temporaryRoot): void
$options['compiler'], $providerRoot . '/project.yml', $options['compiler'], $providerRoot . '/project.yml',
'--output', $providerRoot . '/' . $target . '.' . PHP_SHLIB_SUFFIX, '--output', $providerRoot . '/' . $target . '.' . PHP_SHLIB_SUFFIX,
'--build-dir', $providerRoot . '/build', '--job', '1', '--no-progress', '--build-dir', $providerRoot . '/build', '--job', '1', '--no-progress',
]); ], environment: integrationCompilerEnvironment($options));
$library = $providerRoot . '/' . $target . '.' . PHP_SHLIB_SUFFIX; $library = $providerRoot . '/' . $target . '.' . PHP_SHLIB_SUFFIX;
$stub = $providerRoot . '/' . $target . '.stub.php'; $stub = $providerRoot . '/' . $target . '.stub.php';
@ -648,7 +671,7 @@ function runLibIntegration(array $options, string $temporaryRoot): void
'--build-dir', $consumerRoot . '/build', '--build-dir', $consumerRoot . '/build',
'--link-path', $linkRoot, '--link-path', $linkRoot,
'--job', '1', '--no-progress', '--job', '1', '--no-progress',
]); ], environment: integrationCompilerEnvironment($options));
$libraryPath = $linkRoot; $libraryPath = $linkRoot;
$environment = PHP_OS_FAMILY === 'Darwin' $environment = PHP_OS_FAMILY === 'Darwin'
? ['DYLD_LIBRARY_PATH' => $libraryPath . ':' . (getenv('DYLD_LIBRARY_PATH') ?: '')] ? ['DYLD_LIBRARY_PATH' => $libraryPath . ':' . (getenv('DYLD_LIBRARY_PATH') ?: '')]

Loading…
Cancel
Save