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
8 changes: 4 additions & 4 deletions .github/actions/ccache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ 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
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
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
33 changes: 33 additions & 0 deletions .github/scripts/windows/build_with_test_database_setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$ErrorActionPreference = "Stop"

$databaseSetup = Join-Path $PSScriptRoot "setup_test_databases.ps1"
$databaseJob = Start-Job -FilePath $databaseSetup

try {
$buildStopwatch = [System.Diagnostics.Stopwatch]::StartNew()
& (Join-Path $PSScriptRoot "build.bat")
$buildExitCode = $LASTEXITCODE
$buildStopwatch.Stop()
Write-Host "PHP build duration: $($buildStopwatch.Elapsed)"

$databaseWaitStopwatch = [System.Diagnostics.Stopwatch]::StartNew()
Wait-Job -Job $databaseJob | Out-Null
$databaseWaitStopwatch.Stop()
Write-Host "Database wait after PHP build: $($databaseWaitStopwatch.Elapsed)"

$databaseState = $databaseJob.State
$databaseError = $databaseJob.ChildJobs[0].JobStateInfo.Reason
Receive-Job -Job $databaseJob -ErrorAction Continue

if ($buildExitCode -ne 0) {
throw "PHP build exited with code $buildExitCode"
}
if ($databaseState -ne "Completed") {
throw "Test database setup failed: $databaseError"
}
} finally {
if ($databaseJob.State -eq "Running") {
Stop-Job -Job $databaseJob
}
Remove-Job -Job $databaseJob
}
57 changes: 57 additions & 0 deletions .github/scripts/windows/setup_test_databases.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
$ErrorActionPreference = "Stop"

function Invoke-NativeCommand {
param(
[string] $Description,
[string] $FilePath,
[string[]] $ArgumentList
)

& $FilePath @ArgumentList
if ($LASTEXITCODE -ne 0) {
throw "$Description exited with code $LASTEXITCODE"
}
}

$totalStopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$sqlServerStopwatch = [System.Diagnostics.Stopwatch]::StartNew()

Invoke-NativeCommand "SQL Server Express installation" "choco.exe" @(
"install",
"sql-server-express",
"--version=2022.16.0.20260305",
"-y",
"--no-progress",
"--install-arguments=/SECURITYMODE=SQL /SAPWD=Password12!"
)
$sqlServerStopwatch.Stop()
Write-Host "SQL Server Express setup duration: $($sqlServerStopwatch.Elapsed)"

$mysqlStopwatch = [System.Diagnostics.Stopwatch]::StartNew()
Invoke-NativeCommand "MySQL initialization" "mysqld.exe" @("--initialize-insecure")
Invoke-NativeCommand "MySQL service installation" "mysqld.exe" @("--install")
Invoke-NativeCommand "MySQL service startup" "net.exe" @("start", "MySQL")
Invoke-NativeCommand "MySQL root account setup" "mysql.exe" @(
"--port=3306",
"--user=root",
"-e",
"ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password12!'; FLUSH PRIVILEGES;"
)
$mysqlStopwatch.Stop()
Write-Host "MySQL setup duration: $($mysqlStopwatch.Elapsed)"

$postgresStopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$postgresService = if ($env:PHP_BUILD_CRT -eq "vs18") { "postgresql-x64-17" } else { "postgresql-x64-14" }
Set-Service -Name $postgresService -StartupType Manual -Status Running
$env:PGPASSWORD = "root"
Invoke-NativeCommand "PostgreSQL account setup" "$env:PGBIN\psql.exe" @(
"-U",
"postgres",
"-c",
"ALTER USER postgres WITH PASSWORD 'Password12!';"
)
$postgresStopwatch.Stop()
Write-Host "PostgreSQL setup duration: $($postgresStopwatch.Elapsed)"

$totalStopwatch.Stop()
Write-Host "Total database setup duration: $($totalStopwatch.Elapsed)"
37 changes: 31 additions & 6 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ jobs:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: root
postgres:
image: postgres
image: ${{ (!matrix.asan || inputs.all_variations) && 'postgres' || '' }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
firebird:
image: jacobalberty/firebird
image: ${{ (!matrix.asan || inputs.all_variations) && 'jacobalberty/firebird' || '' }}
ports:
- 3050:3050
env:
Expand All @@ -139,11 +139,13 @@ jobs:
with:
ref: ${{ fromJson(inputs.branch).ref }}
- name: Create MSSQL container
if: ${{ !matrix.asan || inputs.all_variations }}
uses: ./.github/actions/setup-mssql
- name: apt
uses: ./.github/actions/apt-x64
with:
asan: ${{ matrix.asan && 'true' || 'false' }}
skipSlow: ${{ (matrix.asan && !inputs.all_variations) && 'true' || 'false' }}
- name: System info
run: |
echo "::group::Show host CPU info"
Expand Down Expand Up @@ -857,21 +859,43 @@ jobs:
PLATFORM: ${{ matrix.x64 && 'x64' || 'x86' }}
THREAD_SAFE: "${{ matrix.zts && '1' || '0' }}"
INTRINSICS: "${{ matrix.zts && 'AVX2' || '' }}"
PARALLEL: -j2
PARALLEL: -j4
OPCACHE: "${{ matrix.opcache && '1' || '0' }}"
ASAN: "${{ matrix.asan && '1' || '0' }}"
CLANG_TOOLSET: "${{ matrix.clang && '1' || '0' }}"
SCCACHE_CACHE_SIZE: 1G
SCCACHE_IGNORE_SERVER_IO_ERROR: "1"
SCCACHE_CACHE_KEY: windows-sccache-v2-php${{ join(fromJson(inputs.branch).version, '.') }}-${{ fromJson(inputs.branch).jobs.WINDOWS.config.vs_crt_version }}-${{ matrix.x64 && 'x64' || 'x86' }}-zts${{ matrix.zts && '1' || '0' }}-asan${{ matrix.asan && '1' || '0' }}-${{ github.sha }}
SCCACHE_CACHE_RESTORE_PREFIX: windows-sccache-v2-php${{ join(fromJson(inputs.branch).version, '.') }}-${{ fromJson(inputs.branch).jobs.WINDOWS.config.vs_crt_version }}-${{ matrix.x64 && 'x64' || 'x86' }}-zts${{ matrix.zts && '1' || '0' }}-asan${{ matrix.asan && '1' || '0' }}-
steps:
- name: git config
run: git config --global core.autocrlf false && git config --global core.eol lf
- name: git checkout
uses: actions/checkout@v6
with:
ref: ${{ fromJson(inputs.branch).ref }}
- name: Setup
- name: Setup Windows build tools
uses: ./.github/actions/setup-windows
- name: Build
run: .github/scripts/windows/build.bat
- name: Restore MSVC compiler cache
if: ${{ !matrix.clang }}
continue-on-error: true
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: ${{ runner.temp }}\sccache
key: ${{ env.SCCACHE_CACHE_KEY }}
restore-keys: ${{ env.SCCACHE_CACHE_RESTORE_PREFIX }}
- name: Build PHP while preparing test databases
shell: pwsh
run: .github/scripts/windows/build_with_test_database_setup.ps1
# Pull request caches are isolated to the PR merge ref and cannot update
# caches used by the base branch or other pull requests.
- name: Save MSVC compiler cache
if: ${{ !matrix.clang }}
continue-on-error: true
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: ${{ runner.temp }}\sccache
key: ${{ env.SCCACHE_CACHE_KEY }}
- name: Test
run: .github/scripts/windows/test.bat
FREEBSD:
Expand Down Expand Up @@ -919,6 +943,7 @@ jobs:
with:
ref: ${{ fromJson(inputs.branch).ref }}
fetch-depth: 0
filter: blob:none
# ASLR can cause a lot of noise due to missed sse opportunities for memcpy
# and other operations, so we disable it during benchmarking.
- name: Disable ASLR
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- 'main/io/**'
- 'main/php_io.h'
- 'tests/unit/**'
- '.github/actions/ccache/action.yml'
- '.github/workflows/unit-tests.yml'
branches:
- master
Expand All @@ -15,6 +16,7 @@ on:
- 'main/io/**'
- 'main/php_io.h'
- 'tests/unit/**'
- '.github/actions/ccache/action.yml'
- '.github/workflows/unit-tests.yml'
branches:
- '**'
Expand Down Expand Up @@ -57,11 +59,9 @@ jobs:
ccache

- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
uses: ./.github/actions/ccache
with:
key: "unit-tests-${{hashFiles('main/php_version.h')}}"
append-timestamp: false
save: ${{ github.event_name != 'pull_request' }}
name: UNIT_TESTS_LINUX_X64

- name: ./configure (minimal build)
uses: ./.github/actions/configure-unit-tests
Expand All @@ -76,4 +76,3 @@ jobs:
set -x
cd tests/unit
make test

Loading
Loading