|
23 | 23 | uses: crazy-max/ghaction-chocolatey@v3 |
24 | 24 | with: |
25 | 25 | args: install protoc llvm winfsp make |
| 26 | + - name: Verify Chocolatey packages and retry if needed |
| 27 | + # The chocolatey install step can partially succeed: if the |
| 28 | + # Chocolatey CDN returns a transient error (e.g. 504 Gateway |
| 29 | + # Timeout) for one package, other packages may still install |
| 30 | + # fine and the step exits successfully. This leaves the build |
| 31 | + # missing critical dependencies, causing confusing failures |
| 32 | + # later (e.g. winfsp-sys build.rs panic). This step verifies |
| 33 | + # that all required packages are actually present and retries |
| 34 | + # any that are missing. |
| 35 | + shell: pwsh |
| 36 | + run: | |
| 37 | + function Test-Packages { |
| 38 | + $missing = @() |
| 39 | + if (-not (Test-Path "C:\Program Files (x86)\WinFsp")) { |
| 40 | + $missing += "winfsp" |
| 41 | + } |
| 42 | + if (-not (Get-Command protoc -ErrorAction SilentlyContinue)) { |
| 43 | + $missing += "protoc" |
| 44 | + } |
| 45 | + if (-not (Get-Command make -ErrorAction SilentlyContinue)) { |
| 46 | + $missing += "make" |
| 47 | + } |
| 48 | + if (-not (Get-Command clang -ErrorAction SilentlyContinue)) { |
| 49 | + $missing += "llvm" |
| 50 | + } |
| 51 | + return $missing |
| 52 | + } |
| 53 | +
|
| 54 | + $missing = Test-Packages |
| 55 | + if ($missing.Count -eq 0) { |
| 56 | + Write-Host "All required packages verified successfully." |
| 57 | + exit 0 |
| 58 | + } |
| 59 | +
|
| 60 | + $maxRetries = 2 |
| 61 | + for ($attempt = 1; $attempt -le $maxRetries; $attempt++) { |
| 62 | + Write-Host "::warning::Missing packages: $($missing -join ', '). Retry attempt $attempt of $maxRetries..." |
| 63 | + Start-Sleep -Seconds 15 |
| 64 | + choco install $missing -y --allow-unofficial |
| 65 | + $missing = Test-Packages |
| 66 | + if ($missing.Count -eq 0) { |
| 67 | + Write-Host "All required packages verified successfully after retry." |
| 68 | + exit 0 |
| 69 | + } |
| 70 | + } |
| 71 | +
|
| 72 | + foreach ($pkg in $missing) { |
| 73 | + Write-Host "::error::Required package not installed after retries: $pkg" |
| 74 | + } |
| 75 | + exit 1 |
26 | 76 | - name: Install FlatBuffers Compiler |
27 | 77 | run: | |
28 | 78 | $url = "https://github.com/google/flatbuffers/releases/download/v23.5.26/Windows.flatc.binary.zip" |
|
0 commit comments