Skip to content

Commit bd34163

Browse files
committed
Resolve source workflow runner from PHP version
1 parent 8bbb180 commit bd34163

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

.github/workflows/test-php-libs-from-source.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,38 @@ on:
1414
required: false
1515

1616
jobs:
17+
resolve-runner:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
runner: ${{ steps.resolve.outputs.runner }}
21+
steps:
22+
- name: Checkout PHP source
23+
uses: actions/checkout@v6
24+
with:
25+
repository: ${{ inputs.php-src-repository }}
26+
ref: ${{ inputs.php-src-ref }}
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
path: php-src
29+
fetch-depth: 1
30+
sparse-checkout: main/php_version.h
31+
sparse-checkout-cone-mode: false
32+
33+
- name: Resolve runner
34+
id: resolve
35+
shell: bash
36+
run: |
37+
read -r major minor < <(awk '/^#define PHP_(MAJOR|MINOR)_VERSION/ { v[++i]=$3 } END { print v[1], v[2] }' php-src/main/php_version.h)
38+
runner="$([ "$major" -gt 8 ] || { [ "$major" -eq 8 ] && [ "$minor" -ge 6 ]; } && echo windows-2025-vs2026 || echo windows-2022)"
39+
echo "PHP source version: $major.$minor; runner: $runner"
40+
echo "runner=$runner" >> "$GITHUB_OUTPUT"
41+
1742
php:
43+
needs: resolve-runner
1844
strategy:
1945
matrix:
2046
arch: [x64, x86]
2147
ts: [nts, ts]
22-
runs-on: ${{ (contains(inputs.php-src-ref, 'master') || contains(inputs.php-src-ref, '8.6')) && 'windows-2025-vs2026' || 'windows-2022' }}
48+
runs-on: ${{ needs.resolve-runner.outputs.runner }}
2349
steps:
2450
- name: Configure PHP source line endings
2551
shell: pwsh
@@ -63,14 +89,14 @@ jobs:
6389
delete-merged: true
6490

6591
tests:
66-
needs: artifacts
92+
needs: [resolve-runner, artifacts]
6793
strategy:
6894
matrix:
6995
arch: [x64, x86]
7096
ts: [nts, ts]
7197
opcache: [opcache, nocache]
7298
test-type: [php, ext]
73-
runs-on: ${{ (contains(inputs.php-src-ref, 'master') || contains(inputs.php-src-ref, '8.6')) && 'windows-2025-vs2026' || 'windows-2022' }}
99+
runs-on: ${{ needs.resolve-runner.outputs.runner }}
74100
steps:
75101
- name: Checkout
76102
uses: actions/checkout@v6
@@ -138,8 +164,8 @@ jobs:
138164
matrix:
139165
arch: [x64, x86]
140166
ts: [nts, ts]
141-
runs-on: ${{ (contains(inputs.php-src-ref, 'master') || contains(inputs.php-src-ref, '8.6')) && 'windows-2025-vs2026' || 'windows-2022' }}
142-
needs: [artifacts]
167+
runs-on: ${{ needs.resolve-runner.outputs.runner }}
168+
needs: [resolve-runner, artifacts]
143169
steps:
144170
- name: Checkout
145171
uses: actions/checkout@v6

0 commit comments

Comments
 (0)