|
| 1 | +name: Build PHP with custom library builds from winlibs/winlib-builder |
| 2 | +run-name: Build PHP ${{ inputs.php-version }} |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + php-version: |
| 7 | + description: 'PHP version to build' |
| 8 | + required: true |
| 9 | + libs-build-runs: |
| 10 | + description: 'Comma-separated list of GitHub Actions run IDs from winlibs/winlib-builder' |
| 11 | + required: false |
| 12 | + |
| 13 | +jobs: |
| 14 | + php: |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + arch: [x64, x86] |
| 18 | + ts: [nts, ts] |
| 19 | + runs-on: windows-2022 |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v5 |
| 23 | + |
| 24 | + - name: Build |
| 25 | + uses: ./php |
| 26 | + with: |
| 27 | + php-version: ${{ inputs.php-version }} |
| 28 | + arch: ${{ matrix.arch }} |
| 29 | + ts: ${{ matrix.ts }} |
| 30 | + libs-build-runs: ${{ inputs.libs-build-runs }} |
| 31 | + env: |
| 32 | + PHP_BUILD_PROVIDER: "The PHP Group" |
| 33 | + |
| 34 | + artifacts: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + needs: php |
| 37 | + outputs: |
| 38 | + artifact-id: ${{ steps.artifacts.outputs.artifact-id }} |
| 39 | + steps: |
| 40 | + - name: Upload artifacts |
| 41 | + uses: actions/upload-artifact/merge@v5 |
| 42 | + id: artifacts |
| 43 | + with: |
| 44 | + name: artifacts |
| 45 | + delete-merged: true |
| 46 | + tests: |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + arch: [x64, x86] |
| 50 | + ts: [nts, ts] |
| 51 | + opcache: [opcache, nocache] |
| 52 | + test-type: [php, ext] |
| 53 | + runs-on: windows-2022 |
| 54 | + needs: artifacts |
| 55 | + steps: |
| 56 | + - name: Checkout |
| 57 | + uses: actions/checkout@v5 |
| 58 | + |
| 59 | + - name: Download artifacts |
| 60 | + uses: actions/download-artifact@v5 |
| 61 | + id: artifacts |
| 62 | + with: |
| 63 | + name: artifacts |
| 64 | + |
| 65 | + - name: Get Cache Key |
| 66 | + id: cache-key |
| 67 | + run: | |
| 68 | + $pv = '${{inputs.php-version}}' |
| 69 | + if('${{inputs.php-version}}' -ne 'master') { |
| 70 | + $pv = '${{inputs.php-version}}'.Split('.')[0..1] -join '.' |
| 71 | + } |
| 72 | + $vsVersion = (Get-Content -Raw -Path (Join-Path $(pwd).Path '\php\BuildPhp\config\vs.json') | ConvertFrom-Json).php.$pv |
| 73 | + $packagesListUrl = "https://downloads.php.net/~windows/php-sdk/deps/series/packages-$pv-$vsVersion-${{ matrix.arch }}-staging.txt" |
| 74 | + Invoke-WebRequest -OutFile packages.txt -Uri $packagesListUrl |
| 75 | + Add-Content -Value "cache-key=deps-$pv-${{ matrix.arch }}-${{ inputs.libs-build-runs }}" -Path $env:GITHUB_OUTPUT |
| 76 | + Add-Content -Value "cache-dir=C:\deps-$pv-${{ matrix.arch }}" -Path $env:GITHUB_OUTPUT |
| 77 | +
|
| 78 | + - name: Cache Deps |
| 79 | + id: cache-deps |
| 80 | + uses: actions/cache@v4 |
| 81 | + with: |
| 82 | + path: ${{ steps.cache-key.outputs.cache-dir }} |
| 83 | + key: ${{ steps.cache-key.outputs.cache-key }}-${{ hashFiles('packages.txt') }} |
| 84 | + |
| 85 | + - name: Test PHP |
| 86 | + shell: pwsh |
| 87 | + continue-on-error: true |
| 88 | + env: |
| 89 | + DEPS_DIR: ${{ steps.cache-key.outputs.cache-dir }} |
| 90 | + DEPS_CACHE_HIT: ${{ steps.cache-deps.outputs.cache-hit }} |
| 91 | + LIBS_BUILD_RUNS: ${{ inputs.libs-build-runs }} |
| 92 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + run: | |
| 94 | + Import-Module (Join-Path $(pwd).Path '\php\BuildPhp') -Force |
| 95 | + Invoke-PhpTests -PhpVersion ${{inputs.php-version}} ` |
| 96 | + -Arch ${{matrix.arch}} ` |
| 97 | + -Ts ${{matrix.ts}} ` |
| 98 | + -Opcache ${{matrix.opcache}} ` |
| 99 | + -TestType ${{matrix.test-type}} |
| 100 | +
|
| 101 | + - name: Upload artifacts |
| 102 | + uses: actions/upload-artifact@v5 |
| 103 | + continue-on-error: true |
| 104 | + with: |
| 105 | + name: test-results-${{matrix.arch}}-${{matrix.ts}}-${{matrix.opcache}}-${{matrix.test-type}} |
| 106 | + path: test-${{matrix.arch}}-${{matrix.ts}}-${{matrix.opcache}}-${{matrix.test-type}}.xml |
| 107 | + |
| 108 | + smoke-tests: |
| 109 | + strategy: |
| 110 | + matrix: |
| 111 | + arch: [x64, x86] |
| 112 | + ts: [nts, ts] |
| 113 | + runs-on: windows-2022 |
| 114 | + needs: [artifacts] |
| 115 | + steps: |
| 116 | + - name: Checkout |
| 117 | + uses: actions/checkout@v5 |
| 118 | + |
| 119 | + - name: Download artifacts |
| 120 | + uses: actions/download-artifact@v5 |
| 121 | + with: |
| 122 | + name: artifacts |
| 123 | + path: artifacts |
| 124 | + |
| 125 | + - name: Smoke test PHP builds |
| 126 | + shell: pwsh |
| 127 | + run: | |
| 128 | + Import-Module (Join-Path $(pwd).Path '\php\BuildPhp') -Force |
| 129 | + Invoke-PhpSmokeTests -ArtifactsDirectory (Join-Path $(pwd).Path 'artifacts') ` |
| 130 | + -Arch ${{matrix.arch}} ` |
| 131 | + -Ts ${{matrix.ts}} |
0 commit comments