Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions .github/actions/apt-x64/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ inputs:
asan:
default: false
required: false
skipSlow:
default: false
required: false
runs:
using: composite
steps:
Expand All @@ -11,6 +14,13 @@ runs:
set -x

OPCACHE_TLS_TESTS_DEPS="gcc clang lld"
SLOW_EXTENSION_DEPS=""
if [[ "${{ inputs.skipSlow }}" == "false" ]]; then
SLOW_EXTENSION_DEPS="ldap-utils slapd libtidy-dev libenchant-2-dev libsasl2-dev"
SLOW_EXTENSION_DEPS+=" libsqlite3-mod-spatialite libpq-dev libldap2-dev libsnmp-dev"
SLOW_EXTENSION_DEPS+=" postgresql postgresql-contrib snmpd snmp-mibs-downloader"
SLOW_EXTENSION_DEPS+=" freetds-dev unixodbc-dev libsqliteodbc firebird-dev"
fi

export DEBIAN_FRONTEND=noninteractive

Expand All @@ -30,52 +40,36 @@ runs:
bison \
re2c \
locales \
ldap-utils \
openssl \
slapd \
language-pack-de \
libgmp-dev \
libicu-dev \
libtidy-dev \
libenchant-2-dev \
libbz2-dev \
libsasl2-dev \
libxpm-dev \
libzip-dev \
libsqlite3-dev \
libsqlite3-mod-spatialite \
libwebp-dev \
${{ inputs.asan == 'false' && 'libavif-dev' || '' }} \
libonig-dev \
libcurl4-openssl-dev \
libxml2-dev \
libxslt1-dev \
libpq-dev \
libedit-dev \
libldap2-dev \
libsodium-dev \
libargon2-dev \
libmm-dev \
libsnmp-dev \
postgresql \
postgresql-contrib \
snmpd \
snmp-mibs-downloader \
freetds-dev \
unixodbc-dev \
libsqliteodbc \
llvm \
clang \
dovecot-core \
dovecot-pop3d \
dovecot-imapd \
sendmail \
firebird-dev \
liblmdb-dev \
libtokyocabinet-dev \
libdb-dev \
libqdbm-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev \
$OPCACHE_TLS_TESTS_DEPS
$OPCACHE_TLS_TESTS_DEPS \
$SLOW_EXTENSION_DEPS
13 changes: 8 additions & 5 deletions .github/actions/ccache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
cxx:
required: false
default: 'g++'
save:
required: false
default: true
runs:
using: composite
steps:
Expand All @@ -21,17 +24,17 @@ runs:
major=$(cat ${{ inputs.php_directory }}/main/php_version.h | sed -En 's/^#define PHP_MAJOR_VERSION ([0-9]+)/\1/p')
minor=$(cat ${{ inputs.php_directory }}/main/php_version.h | sed -En 's/^#define PHP_MINOR_VERSION ([0-9]+)/\1/p')
release=$(cat ${{ inputs.php_directory }}/main/php_version.h | sed -En 's/^#define PHP_RELEASE_VERSION ([0-9]+)/\1/p')
week=$(date +"%Y-%W")
prefix="${{ inputs.name }}-$major.$minor.$release"
echo "key=$prefix-$week" >> $GITHUB_OUTPUT
echo "prefix=$prefix-" >> $GITHUB_OUTPUT
# GitHub cache entries are immutable, so each commit needs a new key.
echo "key=$prefix-$GITHUB_SHA" >> $GITHUB_OUTPUT
echo "prefix=$prefix" >> $GITHUB_OUTPUT
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
uses: hendrikmuhs/ccache-action@d62db5f07c26379fc4b4e0916f098a92573c3b03 # v1.2.23
with:
key: "${{ steps.cache_key.outputs.key }}"
append-timestamp: false
restore-keys: "${{ steps.cache_key.outputs.prefix }}"
save: ${{ github.event_name != 'pull_request' }}
save: ${{ inputs.save == 'true' && github.event_name != 'pull_request' }}
- name: Export CC/CXX
shell: bash
run: |
Expand Down
38 changes: 24 additions & 14 deletions .github/actions/setup-windows/action.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
name: Setup
name: Setup Windows build tools
runs:
using: composite
steps:
- name: Setup MySQL
shell: cmd
run: |
mysqld --initialize-insecure
mysqld --install
net start MySQL
mysql --port=3306 --user=root --password="" -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password12!'; FLUSH PRIVILEGES;"
- name: Setup MSSQL
- name: Install jom
shell: pwsh
run: |
choco install sql-server-express -y --no-progress --install-arguments="/SECURITYMODE=SQL /SAPWD=Password12!"
- name: Setup PostgreSQL
$jomDirectory = Join-Path $env:RUNNER_TEMP "jom"
$jomArchive = Join-Path $env:RUNNER_TEMP "jom.zip"
Invoke-WebRequest https://download.qt.io/official_releases/jom/jom_1_1_7.zip -OutFile $jomArchive
if ((Get-FileHash $jomArchive -Algorithm SHA256).Hash -ne "4C8AF345586A9A08FBFD2F613FCAC748226D91A75627AA3581B297DD513046FE") {
throw "Unexpected jom archive checksum"
}
Expand-Archive $jomArchive -DestinationPath $jomDirectory
$jomDirectory | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install sccache
if: ${{ env.CLANG_TOOLSET != '1' }}
shell: pwsh
run: |
$postgresService = if ($env:PHP_BUILD_CRT -eq "vs18") { "postgresql-x64-17" } else { "postgresql-x64-14" }
Set-Service -Name $postgresService -StartupType manual -Status Running
pwsh -Command { $env:PGPASSWORD="root"; & "$env:PGBIN\psql" -U postgres -c "ALTER USER postgres WITH PASSWORD 'Password12!';" }
$sccacheDirectory = Join-Path $env:RUNNER_TEMP "sccache-bin"
$sccacheCacheDirectory = Join-Path $env:RUNNER_TEMP "sccache"
$sccacheArchive = Join-Path $env:RUNNER_TEMP "sccache.zip"
Invoke-WebRequest https://github.com/mozilla/sccache/releases/download/v0.15.0/sccache-v0.15.0-x86_64-pc-windows-msvc.zip -OutFile $sccacheArchive
if ((Get-FileHash $sccacheArchive -Algorithm SHA256).Hash -ne "DCF489090AA5EF4C7D145E8B29F759124C803D636C3107F397BD50D425B5F341") {
throw "Unexpected sccache archive checksum"
}
Expand-Archive $sccacheArchive -DestinationPath $sccacheDirectory
(Join-Path $sccacheDirectory "sccache-v0.15.0-x86_64-pc-windows-msvc") |
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
"SCCACHE_DIR=$sccacheCacheDirectory" |
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
15 changes: 14 additions & 1 deletion .github/actions/test-alpine/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ inputs:
jitType:
default: 'disable'
required: false
testShard:
default: 1
required: false
testShards:
default: 1
required: false
runs:
using: composite
steps:
Expand All @@ -17,6 +23,12 @@ runs:
set -x
export SKIP_IO_CAPTURE_TESTS=1
export STACK_LIMIT_DEFAULTS_CHECK=1
test_shard_options=()
if [[ "${{ inputs.testShards }}" -gt 1 ]]; then
sapi/cli/php .github/scripts/generate_test_shard.php \
"${{ inputs.testShard }}" "${{ inputs.testShards }}" "$RUNNER_TEMP/php-test-shard.txt"
test_shard_options=(-r "$RUNNER_TEMP/php-test-shard.txt")
fi
sapi/cli/php run-tests.php -P -q ${{ inputs.runTestsParameters }} \
${{ inputs.enableOpcache == 'true' && '-d opcache.enable_cli=1' || '' }} \
-d opcache.jit=${{ inputs.jitType }} \
Expand All @@ -26,4 +38,5 @@ runs:
--no-progress \
--show-diff \
--show-slow 1000 \
--set-timeout 120
--set-timeout 120 \
"${test_shard_options[@]}"
15 changes: 14 additions & 1 deletion .github/actions/test-linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ inputs:
idleCpu:
default: 'false'
required: false
testShard:
default: 1
required: false
testShards:
default: 1
required: false
runs:
using: composite
steps:
Expand Down Expand Up @@ -45,6 +51,12 @@ runs:
export SKIP_IO_CAPTURE_TESTS=1
export STACK_LIMIT_DEFAULTS_CHECK=1
export RUN_RESOURCE_HEAVY_TESTS=1
test_shard_options=()
if [[ "${{ inputs.testShards }}" -gt 1 ]]; then
sapi/cli/php .github/scripts/generate_test_shard.php \
"${{ inputs.testShard }}" "${{ inputs.testShards }}" "$RUNNER_TEMP/php-test-shard.txt"
test_shard_options=(-r "$RUNNER_TEMP/php-test-shard.txt")
fi
sapi/cli/php run-tests.php -P -q ${{ inputs.runTestsParameters }} \
${{ inputs.enableOpcache == 'true' && '-d opcache.enable_cli=1' || '' }} \
-d opcache.jit=${{ inputs.jitType }} \
Expand All @@ -56,4 +68,5 @@ runs:
--offline \
--show-diff \
--show-slow 1000 \
--set-timeout 120
--set-timeout 120 \
"${test_shard_options[@]}"
24 changes: 21 additions & 3 deletions .github/matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ function get_current_version(): array {
return [$major, $minor];
}

function with_test_shards(array $configuration, int $shards): array {
$configurations = [];
for ($shard = 1; $shard <= $shards; $shard++) {
$configurations[] = $configuration + [
'test_shard' => $shard,
'test_shards' => $shards,
];
}
return $configurations;
}

function select_jobs($repository, $trigger, $nightly, $labels, $php_version, $ref, $all_variations) {
$no_jobs = in_array('CI: No jobs', $labels, true);
$all_jobs = in_array('CI: All jobs', $labels, true) || $nightly;
Expand All @@ -66,7 +77,7 @@ function select_jobs($repository, $trigger, $nightly, $labels, $php_version, $re

$jobs = [];
if (version_compare($php_version, '8.4', '>=') && ($all_jobs || !$no_jobs || $test_alpine)) {
$jobs['ALPINE'] = true;
$jobs['ALPINE']['matrix']['include'] = with_test_shards([], $all_variations ? 1 : 3);
}
if (version_compare($php_version, '8.4', '>=')
&& !$nightly
Expand Down Expand Up @@ -113,8 +124,9 @@ function select_jobs($repository, $trigger, $nightly, $labels, $php_version, $re
],
]
: ['include' => [
['name' => '', 'asan' => false, 'debug' => false, 'repeat' => false, 'variation' => false, 'zts' => false],
['name' => '_ASAN', 'asan' => true, 'debug' => true, 'repeat' => false, 'variation' => false, 'zts' => true],
...with_test_shards(['name' => '', 'asan' => false, 'debug' => false, 'repeat' => false, 'test_mode' => 'normal', 'variation' => false, 'zts' => false], 1),
...with_test_shards(['name' => '', 'asan' => false, 'debug' => false, 'repeat' => false, 'test_mode' => 'function-jit', 'variation' => false, 'zts' => false], 1),
...with_test_shards(['name' => '_ASAN', 'asan' => true, 'debug' => true, 'repeat' => false, 'test_mode' => 'normal', 'variation' => false, 'zts' => true], 3),
]];
$jobs['LINUX_X64']['config']['variation_enable_zend_max_execution_timers'] = version_compare($php_version, '8.3', '>=');
}
Expand Down Expand Up @@ -147,7 +159,13 @@ function select_jobs($repository, $trigger, $nightly, $labels, $php_version, $re
if (version_compare($php_version, '8.6', '>=')) {
$matrix[] = ['asan' => false, 'opcache' => true, 'x64' => true, 'zts' => true, 'clang' => true];
}
} else {
$matrix = with_test_shards($matrix[0], 2);
}
foreach ($matrix as &$configuration) {
$configuration += ['test_shard' => 1, 'test_shards' => 1];
}
unset($configuration);
$jobs['WINDOWS']['matrix'] = ['include' => $matrix];
$jobs['WINDOWS']['config'] = match (true) {
version_compare($php_version, '8.6', '>=') => ['vs_crt_version' => 'vs18', 'runs_on' => 'windows-2025-vs2026'],
Expand Down
82 changes: 82 additions & 0 deletions .github/scripts/generate_test_shard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

if ($argc !== 4) {
fwrite(STDERR, "Usage: php generate_test_shard.php <shard> <shards> <output>\n");
exit(1);
}

$shard = filter_var($argv[1], FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
$shards = filter_var($argv[2], FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
if ($shard === false || $shards === false || $shard > $shards) {
fwrite(STDERR, "The shard must be between 1 and the total number of shards.\n");
exit(1);
}

$root = dirname(__DIR__, 2);
$extensions = get_loaded_extensions();
$extensionDir = ini_get('extension_dir');
if (is_dir($extensionDir)) {
foreach (scandir($extensionDir) as $file) {
if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.' . preg_quote(PHP_SHLIB_SUFFIX, '/') . '$/', $file, $matches)) {
$extensions[] = $matches[1];
}
}
}
$extensions = array_map(
static fn(string $extension): string => $extension === 'Zend OPcache' ? 'opcache' : strtolower($extension),
$extensions,
);
$extensions = array_fill_keys($extensions, true);
unset($extensions['core']);

$tests = [];
$collectTests = static function (string $directory) use (&$tests): void {
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS),
);
foreach ($iterator as $file) {
if ($file->isFile() && $file->getExtension() === 'phpt' && $file->getFilename()[0] !== '.') {
$tests[] = $file->getRealPath();
}
}
};

foreach (['Zend', 'tests', 'sapi'] as $directory) {
if (is_dir("$root/$directory")) {
$collectTests("$root/$directory");
}
}
foreach (new DirectoryIterator("$root/ext") as $extensionDirectory) {
if ($extensionDirectory->isDir()
&& !$extensionDirectory->isDot()
&& isset($extensions[strtolower($extensionDirectory->getFilename())])
) {
$collectTests($extensionDirectory->getPathname());
}
}

sort($tests, SORT_STRING);
$testShards = array_fill(0, $shards, []);
foreach ($tests as $index => $test) {
$testShards[$index % $shards][] = $test;
}
$partitionedTests = array_merge(...$testShards);
if (count($partitionedTests) !== count($tests)
|| count(array_unique($partitionedTests)) !== count($tests)
) {
fwrite(STDERR, "Test shard partition is incomplete or contains duplicates.\n");
exit(1);
}
$selectedTests = $testShards[$shard - 1];
if ($selectedTests === []) {
fwrite(STDERR, "Shard $shard of $shards contains no tests.\n");
exit(1);
}

$output = $argv[3];
if (file_put_contents($output, implode(PHP_EOL, $selectedTests) . PHP_EOL) === false) {
fwrite(STDERR, "Failed to write test shard to $output.\n");
exit(1);
}

printf("Selected %d of %d tests for shard %d of %d.\n", count($selectedTests), count($tests), $shard, $shards);
19 changes: 17 additions & 2 deletions .github/scripts/windows/build_task.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if "%CLANG_TOOLSET%" equ "1" (

cmd /c configure.bat ^
--enable-snapshot-build ^
--enable-parallel-build ^
--disable-debug-pack ^
--without-analyzer ^
--enable-object-out-dir=%PHP_BUILD_OBJ_DIR% ^
Expand All @@ -49,9 +50,23 @@ cmd /c configure.bat ^
--disable-test-ini
if %errorlevel% neq 0 exit /b 3

nmake /NOLOGO
if "%CLANG_TOOLSET%" equ "1" goto build_clang

sccache --zero-stats
jom /NOLOGO CC="sccache cl.exe"
if %errorlevel% neq 0 exit /b 3
jom /NOLOGO CC="sccache cl.exe" comtest.dll
if %errorlevel% neq 0 exit /b 3
nmake /NOLOGO comtest.dll
sccache --show-stats
sccache --stop-server
goto build_complete

:build_clang
jom /NOLOGO
if %errorlevel% neq 0 exit /b 3
jom /NOLOGO comtest.dll
if %errorlevel% neq 0 exit /b 3

:build_complete

exit /b 0
Loading
Loading