From 7063932fef68625746c69edea82bd69dd0263c51 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Tue, 30 Sep 2025 21:45:01 +0530 Subject: [PATCH] Add support to run tests after build --- .github/workflows/php.yml | 41 ++++++++++++++++++- php/BuildPhp/private/Add-TestRequirements.ps1 | 22 ++++++++-- php/BuildPhp/public/Invoke-PhpTests.ps1 | 2 +- 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c3ef9497..e4780fff 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -27,7 +27,7 @@ jobs: - name: Build uses: ./php with: - php-version: ${{ github.event.inputs.php-version }} + php-version: ${{ inputs.php-version }} arch: ${{ matrix.arch }} ts: ${{ matrix.ts }} @@ -43,9 +43,46 @@ jobs: with: name: artifacts delete-merged: true + tests: + strategy: + matrix: + arch: [x64, x86] + ts: [nts, ts] + opcache: [opcache, nocache] + runs-on: windows-2022 + needs: artifacts + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v5 + id: artifacts + with: + name: artifacts + + - name: Setup MySQL + uses: ankane/setup-mysql@v1 + with: + database: test + + - name: Test PHP + shell: pwsh + run: | + Import-Module (Join-Path $(pwd).Path '\php\BuildPhp') -Force + Invoke-PhpTests -PhpVersion ${{inputs.php-version}} ` + -Arch ${{matrix.arch}} ` + -Ts ${{matrix.ts}} ` + -Opcache ${{matrix.opcache}} + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: test-results-${{matrix.arch}}-${{matrix.ts}}-${{matrix.opcache}} + path: test-${{matrix.arch}}-${{matrix.ts}}-${{matrix.opcache}}.xml upload: runs-on: ubuntu-latest - needs: artifacts + needs: tests if: ${{ github.event.inputs.upload == 'true' }} steps: - name: Upload to downloads server diff --git a/php/BuildPhp/private/Add-TestRequirements.ps1 b/php/BuildPhp/private/Add-TestRequirements.ps1 index 503f830f..57138b84 100644 --- a/php/BuildPhp/private/Add-TestRequirements.ps1 +++ b/php/BuildPhp/private/Add-TestRequirements.ps1 @@ -32,13 +32,29 @@ function Add-TestRequirements { [string] $VsVersion, [Parameter(Mandatory = $false, Position=4, HelpMessage='Tests Directory')] [ValidateLength(1, [int]::MaxValue)] - [string] $TestsDirectory + [string] $TestsDirectory, + [Parameter(Mandatory = $true, Position=5, HelpMessage='Artifacts Directory')] + [ValidateNotNull()] + [string] $ArtifactsDirectory ) begin { } process { - Get-PhpBuild -PhpVersion $PhpVersion -Arch $Arch -Ts $Ts -VsVersion $VsVersion - Get-PhpTestPack -PhpVersion $PhpVersion -TestsDirectory $TestsDirectory + $versionInUrl = $PhpVersion + if($PhpVersion -eq 'master') { + $versionInUrl = "master" + } + $tsPart = if ($Ts -eq "nts") {"nts-Win32"} else {"Win32"} + $binZipFile = "php-$versionInUrl-$tsPart-$VsVersion-$Arch.zip" + $testZipFile = "php-test-pack-$versionInUrl.zip" + if(-not(Test-Path "$ArtifactsDirectory\$binZipFile")) { + Write-Host "Downloading PHP build $binZipFile..." + Get-PhpBuild -PhpVersion $PhpVersion -Arch $Arch -Ts $Ts -VsVersion $VsVersion + } + if(-not(Test-Path "$ArtifactsDirectory\$testZipFile")) { + Write-Host "Downloading PHP test pack $testZipFile..." + Get-PhpTestPack -PhpVersion $PhpVersion -TestsDirectory $TestsDirectory + } } end { } diff --git a/php/BuildPhp/public/Invoke-PhpTests.ps1 b/php/BuildPhp/public/Invoke-PhpTests.ps1 index b8e161a4..d2ace61d 100644 --- a/php/BuildPhp/public/Invoke-PhpTests.ps1 +++ b/php/BuildPhp/public/Invoke-PhpTests.ps1 @@ -50,7 +50,7 @@ function Invoke-PhpTests { Set-Location "$buildDirectory" - Add-TestRequirements -PhpVersion $PhpVersion -Arch $Arch -Ts $Ts -VsVersion $VsData.vs -TestsDirectory $testsDirectory + Add-TestRequirements -PhpVersion $PhpVersion -Arch $Arch -Ts $Ts -VsVersion $VsData.vs -TestsDirectory $testsDirectory -ArtifactsDirectory $currentDirectory\artifacts Set-PhpIniForTests -BuildDirectory $buildDirectory -Opcache $Opcache