From 82cc69ea454056d426c2f559a0b8a83a28e6b8b7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 19 Nov 2026 21:19:50 +0100 Subject: [PATCH 1/2] Add Windows build workflow for phpyaz Build and test PHP 8.4 extensions for x64 in both ZTS and non-ZTS modes. Compile YAZ once with VS 2022 and share it between matrix jobs, enabling libxml2 and libxslt without ICU or libstemmer. Verify the extension loads before running tests, cache dependency builds, and upload build artifacts. --- .github/workflows/build-phpyaz-windows.yaml | 201 ++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 .github/workflows/build-phpyaz-windows.yaml diff --git a/.github/workflows/build-phpyaz-windows.yaml b/.github/workflows/build-phpyaz-windows.yaml new file mode 100644 index 0000000..16038cd --- /dev/null +++ b/.github/workflows/build-phpyaz-windows.yaml @@ -0,0 +1,201 @@ +# Build YAZ once with VS 2022, then reuse it for PHP's TS and NTS builds. +name: Build phpyaz on Windows + +on: + push: + branches: [master] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + build-yaz: + name: Build YAZ (VS 2022, x64) + runs-on: windows-2022 + timeout-minutes: 90 + defaults: + run: + shell: pwsh + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 1 + + - name: Checkout YAZ + uses: actions/checkout@v6 + with: + repository: IndexData/yaz + ref: master + path: yaz + fetch-depth: 1 + submodules: recursive + + - name: Set up build tools + run: | + choco install winflexbison3 --yes --no-progress + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + # Locate the Tcl interpreter bundled with Git for Windows. + $gitExecPath = git --exec-path + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + $gitRuntime = Split-Path (Split-Path $gitExecPath -Parent) -Parent + $tclBin = Join-Path $gitRuntime 'bin' + $tcl = Get-ChildItem -LiteralPath $tclBin -Filter 'tclsh*.exe' -File | + Sort-Object Name | Select-Object -First 1 + if (!$tcl) { + throw "Git for Windows Tcl interpreter not found in $tclBin" + } + 'puts [info patchlevel]; exit 0' | & $tcl.FullName + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + $tclBin >> $env:GITHUB_PATH + "YAZ_TCL=$($tcl.Name)" >> $env:GITHUB_ENV + + - name: Set up MSVC x64 + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + vsversion: '2022' + + - name: Configure dependency cache + id: vcpkg + run: | + $revision = git -C $env:VCPKG_INSTALLATION_ROOT rev-parse HEAD + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + "revision=$revision" >> $env:GITHUB_OUTPUT + $cache = Join-Path $env:RUNNER_TEMP 'vcpkg-cache' + New-Item -ItemType Directory -Force $cache | Out-Null + "VCPKG_BINARY_SOURCES=clear;files,$cache,readwrite" >> $env:GITHUB_ENV + + - name: Cache dependency builds + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/vcpkg-cache + key: windows-2022-x64-vcpkg-${{ steps.vcpkg.outputs.revision }}-${{ hashFiles('.github/workflows/build-phpyaz-windows.yaml') }} + restore-keys: | + windows-2022-x64-vcpkg-${{ steps.vcpkg.outputs.revision }}- + + - name: Install libraries + run: | + & "$env:VCPKG_INSTALLATION_ROOT\vcpkg.exe" install --triplet x64-windows libxml2 libxslt libiconv + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + + - name: Build YAZ with NMAKE + working-directory: yaz/win + run: | + $prefix = Join-Path $env:VCPKG_INSTALLATION_ROOT 'installed\x64-windows' + & nmake /nologo /f makefile BARCH=x64 DEBUG=0 CPP=cl "TCL=$env:YAZ_TCL" ` + HAVE_ICU=0 HAVE_LIBXML2=1 HAVE_LIBXSLT=1 HAVE_ICONV=1 ` + "ICONV_DIR=$prefix" "LIBXML2_DIR=$prefix" "LIBXSLT_DIR=$prefix" dll | + Tee-Object -FilePath nmake-build.log + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + + - name: Stage YAZ SDK and runtime libraries + run: | + $prefix = Join-Path $env:VCPKG_INSTALLATION_ROOT 'installed\x64-windows' + New-Item -ItemType Directory -Force yaz-sdk\include\yaz, yaz-sdk\lib, yaz-sdk\bin | Out-Null + Copy-Item "$prefix\include\*" yaz-sdk\include -Recurse + Copy-Item yaz\src\yaz\*.h yaz-sdk\include\yaz + Copy-Item yaz\lib\yaz5.lib yaz-sdk\lib + Copy-Item yaz\bin\yaz5.dll yaz-sdk\bin + # Include transitive DLL dependencies without assuming their filenames. + Copy-Item "$prefix\bin\*.dll" yaz-sdk\bin + Copy-Item yaz\LICENSE yaz-sdk + Copy-Item "$prefix\share" yaz-sdk\share -Recurse + + - name: Upload YAZ SDK + uses: actions/upload-artifact@v4 + with: + name: yaz-vs2022-x64 + path: yaz-sdk/ + if-no-files-found: error + + - name: Show YAZ build failures + if: failure() + run: | + if (Test-Path yaz\win\nmake-build.log) { + Get-Content yaz\win\nmake-build.log + } + + build-phpyaz: + name: Build phpyaz (PHP ${{ matrix.php }}, ${{ matrix.ts }}, x64) + needs: build-yaz + runs-on: windows-2022 + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + php: ['8.4'] + ts: [ts, nts] + defaults: + run: + shell: pwsh + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 1 + + - name: Download YAZ SDK + uses: actions/download-artifact@v4 + with: + name: yaz-vs2022-x64 + path: ${{ runner.temp }}/yaz-sdk + + - name: Set up YAZ runtime libraries + run: | + "$env:RUNNER_TEMP\yaz-sdk\bin" >> $env:GITHUB_PATH + + - name: Build PHP extension + uses: php/php-windows-builder/extension@v1 + env: + auto-detect-libs: 'false' + artifact-naming-scheme: pecl + with: + php-version: ${{ matrix.php }} + ts: ${{ matrix.ts }} + arch: x64 + build-directory: ${{ runner.temp }}/phpyaz-build + args: >- + --with-yaz + --with-extra-includes="${{ runner.temp }}\yaz-sdk\include" + --with-extra-libs="${{ runner.temp }}\yaz-sdk\lib" + run-tests: 'false' + + - name: Check extension loads and run tests + env: + NO_INTERACTION: 1 + REPORT_EXIT_STATUS: 1 + run: | + $builds = Join-Path $env:RUNNER_TEMP 'phpyaz-build' + $php = @(Get-ChildItem $builds -Recurse -Filter php.exe -File | + Where-Object { $_.Directory.Name -eq 'php-bin' }) + $extension = @(Get-ChildItem $builds -Recurse -Filter php_yaz.dll -File | + Where-Object { $_.Directory.Name -in 'Release', 'Release_TS' }) + if ($php.Count -ne 1 -or $extension.Count -ne 1) { + throw 'Expected one PHP executable and one built YAZ extension' + } + $php = $php[0].FullName + $extension = $extension[0].FullName + & $php -n -d "extension=$extension" -r 'exit(extension_loaded("yaz") ? 0 : 1);' + if ($LASTEXITCODE -ne 0) { throw 'The YAZ extension could not be loaded' } + $env:TEST_PHP_EXECUTABLE = $php + Set-Location (Split-Path (Split-Path $php -Parent) -Parent) + & $php -n run-tests.php -n -d "extension=$extension" --show-diff tests + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + + - name: Show build and test failures + if: failure() + run: | + $builds = Join-Path $env:RUNNER_TEMP 'phpyaz-build' + if (Test-Path $builds) { + Get-ChildItem $builds -Recurse -File -Include build-*.txt, *.log, *.diff | + ForEach-Object { + Write-Output "::group::$($_.FullName)" + Get-Content $_.FullName + Write-Output '::endgroup::' + } + } From 9b42f1e4f28bbce5ab755111ae8abec39d722486 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 19 Nov 2026 21:44:54 +0100 Subject: [PATCH 2/2] Add PHP 8.6 and Visual Studio 2026 to Windows CI Build PHP 8.6 in ZTS and non-ZTS modes on windows-2025-vs2026, alongside the existing PHP 8.4 builds on VS 2022. Build YAZ once per compiler and use separate SDK artifacts and dependency caches for each toolchain. --- .github/workflows/build-phpyaz-windows.yaml | 53 ++++++++++++++++----- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-phpyaz-windows.yaml b/.github/workflows/build-phpyaz-windows.yaml index 16038cd..3c41cbb 100644 --- a/.github/workflows/build-phpyaz-windows.yaml +++ b/.github/workflows/build-phpyaz-windows.yaml @@ -1,4 +1,4 @@ -# Build YAZ once with VS 2022, then reuse it for PHP's TS and NTS builds. +# Build YAZ once per compiler, then reuse it for PHP's TS and NTS builds. name: Build phpyaz on Windows on: @@ -16,9 +16,19 @@ concurrency: jobs: build-yaz: - name: Build YAZ (VS 2022, x64) - runs-on: windows-2022 + name: Build YAZ (VS ${{ matrix.vs }}, x64) + runs-on: ${{ matrix.os }} timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + include: + - vs: '2022' + vs-major: '17' + os: windows-2022 + - vs: '2026' + vs-major: '18' + os: windows-2025-vs2026 defaults: run: shell: pwsh @@ -59,11 +69,24 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 with: arch: x64 - vsversion: '2022' + # Discover the latest installation: vsversion caps minor versions at 9. + + - name: Verify MSVC version + env: + EXPECTED_VS_MAJOR: ${{ matrix.vs-major }} + run: | + if (!$env:VisualStudioVersion -or + ($env:VisualStudioVersion.Split('.')[0] -ne $env:EXPECTED_VS_MAJOR)) { + throw "Expected Visual Studio $env:EXPECTED_VS_MAJOR.x, found '$env:VisualStudioVersion'" + } + Write-Output "Visual Studio $env:VisualStudioVersion" + Write-Output "Compiler: $((Get-Command cl.exe).Source)" - name: Configure dependency cache id: vcpkg run: | + # MSVC setup points VCPKG_ROOT at Visual Studio's bundled copy. + "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" >> $env:GITHUB_ENV $revision = git -C $env:VCPKG_INSTALLATION_ROOT rev-parse HEAD if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } "revision=$revision" >> $env:GITHUB_OUTPUT @@ -75,9 +98,10 @@ jobs: uses: actions/cache@v4 with: path: ${{ runner.temp }}/vcpkg-cache - key: windows-2022-x64-vcpkg-${{ steps.vcpkg.outputs.revision }}-${{ hashFiles('.github/workflows/build-phpyaz-windows.yaml') }} + key: >- + ${{ matrix.os }}-x64-vcpkg-${{ steps.vcpkg.outputs.revision }}-${{ hashFiles('.github/workflows/build-phpyaz-windows.yaml') }} restore-keys: | - windows-2022-x64-vcpkg-${{ steps.vcpkg.outputs.revision }}- + ${{ matrix.os }}-x64-vcpkg-${{ steps.vcpkg.outputs.revision }}- - name: Install libraries run: | @@ -110,7 +134,7 @@ jobs: - name: Upload YAZ SDK uses: actions/upload-artifact@v4 with: - name: yaz-vs2022-x64 + name: yaz-vs${{ matrix.vs }}-x64 path: yaz-sdk/ if-no-files-found: error @@ -122,15 +146,22 @@ jobs: } build-phpyaz: - name: Build phpyaz (PHP ${{ matrix.php }}, ${{ matrix.ts }}, x64) + name: Build phpyaz (PHP ${{ matrix.php }}, ${{ matrix.ts }}, VS ${{ matrix.vs }}, x64) needs: build-yaz - runs-on: windows-2022 + runs-on: ${{ matrix.os }} timeout-minutes: 60 strategy: fail-fast: false matrix: - php: ['8.4'] + php: ['8.4', '8.6'] ts: [ts, nts] + include: + - php: '8.4' + vs: '2022' + os: windows-2022 + - php: '8.6' + vs: '2026' + os: windows-2025-vs2026 defaults: run: shell: pwsh @@ -142,7 +173,7 @@ jobs: - name: Download YAZ SDK uses: actions/download-artifact@v4 with: - name: yaz-vs2022-x64 + name: yaz-vs${{ matrix.vs }}-x64 path: ${{ runner.temp }}/yaz-sdk - name: Set up YAZ runtime libraries