Skip to content

Commit 7063932

Browse files
committed
Add support to run tests after build
1 parent 916d88c commit 7063932

File tree

3 files changed

+59
-6
lines changed

3 files changed

+59
-6
lines changed

.github/workflows/php.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Build
2828
uses: ./php
2929
with:
30-
php-version: ${{ github.event.inputs.php-version }}
30+
php-version: ${{ inputs.php-version }}
3131
arch: ${{ matrix.arch }}
3232
ts: ${{ matrix.ts }}
3333

@@ -43,9 +43,46 @@ jobs:
4343
with:
4444
name: artifacts
4545
delete-merged: true
46+
tests:
47+
strategy:
48+
matrix:
49+
arch: [x64, x86]
50+
ts: [nts, ts]
51+
opcache: [opcache, nocache]
52+
runs-on: windows-2022
53+
needs: artifacts
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
58+
- name: Download artifacts
59+
uses: actions/download-artifact@v5
60+
id: artifacts
61+
with:
62+
name: artifacts
63+
64+
- name: Setup MySQL
65+
uses: ankane/setup-mysql@v1
66+
with:
67+
database: test
68+
69+
- name: Test PHP
70+
shell: pwsh
71+
run: |
72+
Import-Module (Join-Path $(pwd).Path '\php\BuildPhp') -Force
73+
Invoke-PhpTests -PhpVersion ${{inputs.php-version}} `
74+
-Arch ${{matrix.arch}} `
75+
-Ts ${{matrix.ts}} `
76+
-Opcache ${{matrix.opcache}}
77+
78+
- name: Upload artifacts
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: test-results-${{matrix.arch}}-${{matrix.ts}}-${{matrix.opcache}}
82+
path: test-${{matrix.arch}}-${{matrix.ts}}-${{matrix.opcache}}.xml
4683
upload:
4784
runs-on: ubuntu-latest
48-
needs: artifacts
85+
needs: tests
4986
if: ${{ github.event.inputs.upload == 'true' }}
5087
steps:
5188
- name: Upload to downloads server

php/BuildPhp/private/Add-TestRequirements.ps1

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,29 @@ function Add-TestRequirements {
3232
[string] $VsVersion,
3333
[Parameter(Mandatory = $false, Position=4, HelpMessage='Tests Directory')]
3434
[ValidateLength(1, [int]::MaxValue)]
35-
[string] $TestsDirectory
35+
[string] $TestsDirectory,
36+
[Parameter(Mandatory = $true, Position=5, HelpMessage='Artifacts Directory')]
37+
[ValidateNotNull()]
38+
[string] $ArtifactsDirectory
3639
)
3740
begin {
3841
}
3942
process {
40-
Get-PhpBuild -PhpVersion $PhpVersion -Arch $Arch -Ts $Ts -VsVersion $VsVersion
41-
Get-PhpTestPack -PhpVersion $PhpVersion -TestsDirectory $TestsDirectory
43+
$versionInUrl = $PhpVersion
44+
if($PhpVersion -eq 'master') {
45+
$versionInUrl = "master"
46+
}
47+
$tsPart = if ($Ts -eq "nts") {"nts-Win32"} else {"Win32"}
48+
$binZipFile = "php-$versionInUrl-$tsPart-$VsVersion-$Arch.zip"
49+
$testZipFile = "php-test-pack-$versionInUrl.zip"
50+
if(-not(Test-Path "$ArtifactsDirectory\$binZipFile")) {
51+
Write-Host "Downloading PHP build $binZipFile..."
52+
Get-PhpBuild -PhpVersion $PhpVersion -Arch $Arch -Ts $Ts -VsVersion $VsVersion
53+
}
54+
if(-not(Test-Path "$ArtifactsDirectory\$testZipFile")) {
55+
Write-Host "Downloading PHP test pack $testZipFile..."
56+
Get-PhpTestPack -PhpVersion $PhpVersion -TestsDirectory $TestsDirectory
57+
}
4258
}
4359
end {
4460
}

php/BuildPhp/public/Invoke-PhpTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function Invoke-PhpTests {
5050

5151
Set-Location "$buildDirectory"
5252

53-
Add-TestRequirements -PhpVersion $PhpVersion -Arch $Arch -Ts $Ts -VsVersion $VsData.vs -TestsDirectory $testsDirectory
53+
Add-TestRequirements -PhpVersion $PhpVersion -Arch $Arch -Ts $Ts -VsVersion $VsData.vs -TestsDirectory $testsDirectory -ArtifactsDirectory $currentDirectory\artifacts
5454

5555
Set-PhpIniForTests -BuildDirectory $buildDirectory -Opcache $Opcache
5656

0 commit comments

Comments
 (0)