|
| 1 | +name: PHP Extension Validation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ main ] |
| 6 | + types: [ opened, synchronize, reopened ] |
| 7 | + |
| 8 | +jobs: |
| 9 | + test-php: |
| 10 | + runs-on: windows-latest |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + os: [ win10-amd, win10-intel, win11-amd, win11-intel ] |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout PR branch |
| 18 | + uses: actions/checkout@v3 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Get diff of releases.properties |
| 23 | + run: | |
| 24 | + git fetch origin main |
| 25 | + git diff origin/main...HEAD -- releases.properties | ` |
| 26 | + Select-String '^+' | ` |
| 27 | + Where-Object { $_ -notmatch '^\+\+' } | ` |
| 28 | + ForEach-Object { $_.Line.TrimStart('+') } > new_versions.txt |
| 29 | +
|
| 30 | + - name: Loop through new PHP versions |
| 31 | + run: | |
| 32 | + $versions = Get-Content new_versions.txt |
| 33 | + foreach ($version in $versions) { |
| 34 | + Write-Host "Testing PHP $version on ${{ matrix.os }}" |
| 35 | + # TODO: Insert your extension validation logic here |
| 36 | + } |
| 37 | +
|
| 38 | + # Publish per-matrix result as an artifact for aggregation |
| 39 | + - name: Publish result artifact |
| 40 | + if: always() |
| 41 | + run: | |
| 42 | + $status = "${{ job.status }}" |
| 43 | + if ($status -eq "success") { "pass" | Out-File result.txt -Encoding utf8 } else { "fail" | Out-File result.txt -Encoding utf8 } |
| 44 | + "${{ matrix.os }}" | Out-File os.txt -Encoding utf8 |
| 45 | + shell: pwsh |
| 46 | + |
| 47 | + - name: Upload result artifact |
| 48 | + if: always() |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: result-${{ matrix.os }} |
| 52 | + path: | |
| 53 | + result.txt |
| 54 | + os.txt |
| 55 | +
|
| 56 | + aggregate: |
| 57 | + name: Aggregate results and comment |
| 58 | + needs: test-php |
| 59 | + runs-on: windows-latest |
| 60 | + if: always() |
| 61 | + steps: |
| 62 | + - name: Checkout repo |
| 63 | + uses: actions/checkout@v3 |
| 64 | + |
| 65 | + - name: Download result artifacts (win10-amd) |
| 66 | + uses: actions/download-artifact@v4 |
| 67 | + with: |
| 68 | + name: result-win10-amd |
| 69 | + path: results/win10-amd |
| 70 | + |
| 71 | + - name: Download result artifacts (win10-intel) |
| 72 | + uses: actions/download-artifact@v4 |
| 73 | + with: |
| 74 | + name: result-win10-intel |
| 75 | + path: results/win10-intel |
| 76 | + |
| 77 | + - name: Download result artifacts (win11-amd) |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + name: result-win11-amd |
| 81 | + path: results/win11-amd |
| 82 | + |
| 83 | + - name: Download result artifacts (win11-intel) |
| 84 | + uses: actions/download-artifact@v4 |
| 85 | + with: |
| 86 | + name: result-win11-intel |
| 87 | + path: results/win11-intel |
| 88 | + |
| 89 | + - name: Build combined comment |
| 90 | + id: build |
| 91 | + run: | |
| 92 | + function Get-Result { |
| 93 | + param([string]$Path) |
| 94 | + if (Test-Path "$Path/result.txt") { (Get-Content "$Path/result.txt").Trim() } else { "missing" } |
| 95 | + } |
| 96 | +
|
| 97 | + $items = @( |
| 98 | + @{ os = 'win10-amd'; path = 'results/win10-amd' }, |
| 99 | + @{ os = 'win10-intel'; path = 'results/win10-intel' }, |
| 100 | + @{ os = 'win11-amd'; path = 'results/win11-amd' }, |
| 101 | + @{ os = 'win11-intel'; path = 'results/win11-intel' } |
| 102 | + ) |
| 103 | +
|
| 104 | + $anyFail = $false |
| 105 | + $lines = @() |
| 106 | + foreach ($it in $items) { |
| 107 | + $res = Get-Result -Path $it.path |
| 108 | + $status = if ($res -eq 'pass') { 'passed' } else { 'failed' } |
| 109 | + if ($status -eq 'failed') { $anyFail = $true } |
| 110 | +
|
| 111 | + # Build a valid shields badge per OS |
| 112 | + $label = [uri]::EscapeDataString('PHP Test') |
| 113 | + $msg = [uri]::EscapeDataString($it.os + ' ' + $status) |
| 114 | + $color = if ($status -eq 'passed') { 'brightgreen' } else { 'red' } |
| 115 | + $badge = "https://img.shields.io/static/v1?label=$label&message=$msg&color=$color&logo=windows&logoColor=white" |
| 116 | + $lines += "- $($it.os): " |
| 117 | + } |
| 118 | +
|
| 119 | + $header = if (-not $anyFail) { 'β
All PHP extension tests passed' } else { 'β Some PHP extension tests failed' } |
| 120 | +
|
| 121 | + $content = @() |
| 122 | + $content += "### $header" |
| 123 | + $content += "" |
| 124 | + $content += $lines |
| 125 | + $contentText = $content -join "`n" |
| 126 | +
|
| 127 | + # Save for comment |
| 128 | + $contentText | Out-File aggregate.md -Encoding utf8 |
| 129 | + shell: pwsh |
| 130 | + |
| 131 | + - name: Post single PR comment |
| 132 | + if: always() |
| 133 | + run: | |
| 134 | + gh pr comment -R "${{ github.repository }}" ${{ github.event.pull_request.number }} --body "$(Get-Content -Raw aggregate.md)" |
| 135 | + env: |
| 136 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 137 | + shell: pwsh |
0 commit comments