mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Add extension configure tests
This commit is contained in:
parent
64258e3513
commit
45bdb6a66b
137
.github/workflows/ext-configure-tests.yml
vendored
Normal file
137
.github/workflows/ext-configure-tests.yml
vendored
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
name: "Extension configure tests"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/ext-matrix-tests.yml'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})"
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
extension:
|
||||||
|
- apcu
|
||||||
|
- bcmath
|
||||||
|
- bz2
|
||||||
|
- calendar
|
||||||
|
- ctype
|
||||||
|
- curl
|
||||||
|
- dba
|
||||||
|
- dom
|
||||||
|
- exif
|
||||||
|
- fileinfo
|
||||||
|
- filter
|
||||||
|
- ftp
|
||||||
|
- gd
|
||||||
|
- gmp
|
||||||
|
- gettext
|
||||||
|
- iconv
|
||||||
|
- igbinary
|
||||||
|
- imagick
|
||||||
|
- intl
|
||||||
|
- ldap
|
||||||
|
- mbregex
|
||||||
|
- mbstring
|
||||||
|
- mysqli
|
||||||
|
- mysqlnd
|
||||||
|
- opcache
|
||||||
|
- openssl
|
||||||
|
- parallel
|
||||||
|
- pcntl
|
||||||
|
- pdo
|
||||||
|
- pdo_mysql
|
||||||
|
- pdo_pgsql
|
||||||
|
- pdo_sqlite
|
||||||
|
- pgsql
|
||||||
|
- phar
|
||||||
|
- posix
|
||||||
|
- protobuf
|
||||||
|
- readline
|
||||||
|
- redis
|
||||||
|
- session
|
||||||
|
- shmop
|
||||||
|
- simplexml
|
||||||
|
- soap
|
||||||
|
- sockets
|
||||||
|
- sodium
|
||||||
|
- sqlite3
|
||||||
|
- ssh2
|
||||||
|
- sysvmsg
|
||||||
|
- sysvsem
|
||||||
|
- sysvshm
|
||||||
|
- tidy
|
||||||
|
- tokenizer
|
||||||
|
- xlswriter
|
||||||
|
- xml
|
||||||
|
- xmlreader
|
||||||
|
- xmlwriter
|
||||||
|
- zip
|
||||||
|
- zlib
|
||||||
|
- yaml
|
||||||
|
- zstd
|
||||||
|
php-version:
|
||||||
|
- "8.4"
|
||||||
|
operating-system:
|
||||||
|
- "ubuntu-latest"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: "Checkout"
|
||||||
|
uses: "actions/checkout@v4"
|
||||||
|
|
||||||
|
- name: OS type
|
||||||
|
id: os-type
|
||||||
|
run: |
|
||||||
|
OS=""
|
||||||
|
if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then
|
||||||
|
OS="linux-x86_64"
|
||||||
|
elif [ "${{ matrix.operating-system }}" = "macos-13" ]; then
|
||||||
|
OS="macos-x86_64"
|
||||||
|
elif [ "${{ matrix.operating-system }}" = "debian-arm64-self-hosted" ]; then
|
||||||
|
OS="linux-aarch64"
|
||||||
|
elif [ "${{ matrix.operating-system }}" = "macos-14" ]; then
|
||||||
|
OS="macos-aarch64"
|
||||||
|
fi
|
||||||
|
echo "OS=$OS" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: "Setup PHP"
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: 8.2
|
||||||
|
tools: pecl, composer
|
||||||
|
extensions: curl, openssl, mbstring
|
||||||
|
ini-values: memory_limit=-1
|
||||||
|
env:
|
||||||
|
phpts: nts
|
||||||
|
|
||||||
|
- name: "Install Dependencies"
|
||||||
|
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
|
||||||
|
|
||||||
|
- id: cache-download
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: downloads
|
||||||
|
key: php-${{ matrix.php-version }}-dependencies-for-tests
|
||||||
|
|
||||||
|
# If there's no dependencies cache, fetch sources
|
||||||
|
- name: "Download sources"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: ./bin/spc download --with-php=${{ matrix.php-version }} --for-extensions=${{ matrix.extension }} --debug --ignore-cache-sources=php-src
|
||||||
|
|
||||||
|
- name: "Build library: ${{ matrix.library }}"
|
||||||
|
run: |
|
||||||
|
SPC_USE_SUDO=yes ./bin/spc doctor --auto-fix
|
||||||
|
if [ "${{ env.OS }}" = "linux-x86_64" ]; then
|
||||||
|
./bin/spc install-pkg upx
|
||||||
|
UPX=--with-upx-pack
|
||||||
|
elif [ "${{ env.OS }}" = "linux-aarch64" ]; then
|
||||||
|
./bin/spc install-pkg upx
|
||||||
|
UPX=--with-upx-pack
|
||||||
|
fi
|
||||||
|
|
||||||
|
./bin/spc build --build-cli --build-micro ${{ matrix.extension }} -P tests/configure.php
|
||||||
@ -6,6 +6,7 @@ namespace SPC\builder;
|
|||||||
|
|
||||||
use SPC\exception\ExceptionHandler;
|
use SPC\exception\ExceptionHandler;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\InterruptException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\store\Config;
|
use SPC\store\Config;
|
||||||
@ -407,6 +408,13 @@ abstract class BuilderBase
|
|||||||
}
|
}
|
||||||
logger()->debug('Running additional patch script: ' . $patch);
|
logger()->debug('Running additional patch script: ' . $patch);
|
||||||
require $patch;
|
require $patch;
|
||||||
|
} catch (InterruptException $e) {
|
||||||
|
if ($e->getCode() === 0) {
|
||||||
|
logger()->notice('Patch script ' . $patch . ' interrupted' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.'));
|
||||||
|
} else {
|
||||||
|
logger()->error('Patch script ' . $patch . ' interrupted with error code [' . $e->getCode() . ']' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.'));
|
||||||
|
}
|
||||||
|
exit($e->getCode());
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
logger()->critical('Patch script ' . $patch . ' failed to run.');
|
logger()->critical('Patch script ' . $patch . ' failed to run.');
|
||||||
if ($this->getOption('debug')) {
|
if ($this->getOption('debug')) {
|
||||||
@ -414,6 +422,7 @@ abstract class BuilderBase
|
|||||||
} else {
|
} else {
|
||||||
logger()->critical('Please check with --debug option to see more details.');
|
logger()->critical('Please check with --debug option to see more details.');
|
||||||
}
|
}
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/SPC/exception/InterruptException.php
Normal file
7
src/SPC/exception/InterruptException.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\exception;
|
||||||
|
|
||||||
|
class InterruptException extends \Exception {}
|
||||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use SPC\builder\BuilderBase;
|
use SPC\builder\BuilderBase;
|
||||||
use SPC\builder\BuilderProvider;
|
use SPC\builder\BuilderProvider;
|
||||||
|
use SPC\exception\InterruptException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\exception\WrongUsageException;
|
use SPC\exception\WrongUsageException;
|
||||||
use SPC\util\UnixShell;
|
use SPC\util\UnixShell;
|
||||||
@ -125,6 +126,11 @@ function patch_point(): string
|
|||||||
return BuilderProvider::getBuilder()->getPatchPoint();
|
return BuilderProvider::getBuilder()->getPatchPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function patch_point_interrupt(int $retcode, string $msg = ''): InterruptException
|
||||||
|
{
|
||||||
|
return new InterruptException(message: $msg, code: $retcode);
|
||||||
|
}
|
||||||
|
|
||||||
// ------- function f_* part -------
|
// ------- function f_* part -------
|
||||||
// f_ means standard function wrapper
|
// f_ means standard function wrapper
|
||||||
|
|
||||||
|
|||||||
13
tests/configure.php
Normal file
13
tests/configure.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (patch_point() === 'before-php-make') {
|
||||||
|
// get config.status file
|
||||||
|
$config_status = file_get_contents(SOURCE_PATH . '/php-src/config.status');
|
||||||
|
if ($config_status === false) {
|
||||||
|
throw patch_point_interrupt(1, 'Failed to read config.status');
|
||||||
|
}
|
||||||
|
if (str_contains($config_status, 'S["PHP_VERSION"]=""')) {
|
||||||
|
throw patch_point_interrupt(1, 'Cannot find valid PHP_VERSION in config.status');
|
||||||
|
}
|
||||||
|
throw patch_point_interrupt(0);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user