-
Notifications
You must be signed in to change notification settings - Fork 40
165 lines (151 loc) · 5.85 KB
/
test-php-libs-from-source.yml
File metadata and controls
165 lines (151 loc) · 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Build PHP with custom library builds from winlibs/winlib-builder (source)
run-name: Build PHP from source ${{ inputs.php-src-ref }}
on:
workflow_dispatch:
inputs:
php-src-repository:
description: 'php-src repository to source builds and tests from'
required: true
php-src-ref:
description: 'Branch, tag, or SHA in the php-src repository to source builds and tests from'
required: true
libs-build-runs:
description: 'Comma-separated list of GitHub Actions run IDs from winlibs/winlib-builder'
required: false
jobs:
php:
strategy:
matrix:
arch: [x64, x86]
ts: [nts, ts]
runs-on: windows-2022
steps:
- name: Checkout PHP source
uses: actions/checkout@v6
with:
repository: ${{ inputs.php-src-repository }}
ref: ${{ inputs.php-src-ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v6
with:
path: builder
- name: Build
uses: ./builder/php
with:
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
libs-build-runs: ${{ inputs.libs-build-runs }}
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
PHP_BUILD_PROVIDER: "The PHP Group"
artifacts:
runs-on: ubuntu-latest
needs: php
outputs:
artifact-id: ${{ steps.artifacts.outputs.artifact-id }}
steps:
- name: Upload artifacts
uses: actions/upload-artifact/merge@v7
id: artifacts
with:
name: artifacts
delete-merged: true
tests:
needs: artifacts
strategy:
matrix:
arch: [x64, x86]
ts: [nts, ts]
opcache: [opcache, nocache]
test-type: [php, ext]
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
id: artifacts
with:
name: artifacts
- name: Get Cache Key
id: cache-key
run: |
$artifactDirectory = $(pwd).Path
$zip = Get-ChildItem -Path $artifactDirectory -Filter "php-*.zip" -File |
Where-Object { $_.Name -match "^php-(.+?)-(?:nts-)?Win32-vs\d+-${{ matrix.arch }}\.zip$" } |
Select-Object -First 1
if ($null -eq $zip) {
throw "Unable to determine PHP version from build artifacts in $artifactDirectory"
}
$phpVersion = [regex]::Match($zip.Name, '^php-(.+?)-(?:nts-)?Win32-vs\d+-').Groups[1].Value
$pv = $phpVersion
if($phpVersion -ne 'master') {
$pv = $phpVersion.Split('.')[0..1] -join '.'
}
$libsBuildRunsKey = 'default'
$libsBuildRuns = @('${{ inputs.libs-build-runs }}' -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' }) -join ','
if ($libsBuildRuns) {
$libsBuildRunsKey = [System.Convert]::ToHexString(
[System.Security.Cryptography.SHA256]::HashData(
[System.Text.Encoding]::UTF8.GetBytes($libsBuildRuns)
)
).ToLowerInvariant().Substring(0, 16)
}
$vsVersion = (Get-Content -Raw -Path (Join-Path $(pwd).Path '\php\BuildPhp\config\vs.json') | ConvertFrom-Json).php.$pv
$packagesListUrl = "https://downloads.php.net/~windows/php-sdk/deps/series/packages-$pv-$vsVersion-${{ matrix.arch }}-staging.txt"
Invoke-WebRequest -OutFile packages.txt -Uri $packagesListUrl
Add-Content -Value "php-version=$phpVersion" -Path $env:GITHUB_OUTPUT
Add-Content -Value "cache-key=deps-$pv-${{ matrix.arch }}-$libsBuildRunsKey" -Path $env:GITHUB_OUTPUT
Add-Content -Value "cache-dir=C:\deps-$pv-${{ matrix.arch }}" -Path $env:GITHUB_OUTPUT
- name: Cache Deps
id: cache-deps
uses: actions/cache@v5
with:
path: ${{ steps.cache-key.outputs.cache-dir }}
key: ${{ steps.cache-key.outputs.cache-key }}-${{ hashFiles('packages.txt') }}
- name: Test PHP
shell: pwsh
continue-on-error: true
env:
DEPS_DIR: ${{ steps.cache-key.outputs.cache-dir }}
DEPS_CACHE_HIT: ${{ steps.cache-deps.outputs.cache-hit }}
LIBS_BUILD_RUNS: ${{ inputs.libs-build-runs }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Import-Module (Join-Path $(pwd).Path '\php\BuildPhp') -Force
Invoke-PhpTests -PhpVersion ${{ steps.cache-key.outputs.php-version }} `
-Arch ${{matrix.arch}} `
-Ts ${{matrix.ts}} `
-Opcache ${{matrix.opcache}} `
-TestType ${{matrix.test-type}} `
-SourceRepository '${{ inputs.php-src-repository }}' `
-SourceRef '${{ inputs.php-src-ref }}'
- name: Upload artifacts
uses: actions/upload-artifact@v7
continue-on-error: true
with:
name: test-results-${{matrix.arch}}-${{matrix.ts}}-${{matrix.opcache}}-${{matrix.test-type}}
path: test-${{matrix.arch}}-${{matrix.ts}}-${{matrix.opcache}}-${{matrix.test-type}}.xml
smoke-tests:
strategy:
matrix:
arch: [x64, x86]
ts: [nts, ts]
runs-on: windows-2022
needs: [artifacts]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
with:
name: artifacts
path: artifacts
- name: Smoke test PHP builds
shell: pwsh
run: |
Import-Module (Join-Path $(pwd).Path '\php\BuildPhp') -Force
Invoke-PhpSmokeTests -ArtifactsDirectory (Join-Path $(pwd).Path 'artifacts') `
-Arch ${{matrix.arch}} `
-Ts ${{matrix.ts}}