|
1 | 1 | # Post-change verification script |
2 | 2 | # All steps must pass without warnings |
3 | 3 | # Keep in sync with verify.sh |
| 4 | +# Script is relative to git repo root; search if not found |
4 | 5 | # |
5 | 6 | # Note: reloaded-code-serdesai is async-only. |
6 | 7 | # Blocking mode is validated for core and models-dev. |
7 | 8 | # reloaded-code-bubblewrap is Linux-only; all bubblewrap steps |
8 | 9 | # are skipped on non-Linux platforms. |
9 | 10 |
|
10 | | -$ErrorActionPreference = "Stop" |
| 11 | +$originalDir = Get-Location |
| 12 | +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path |
| 13 | +$projectRoot = Join-Path $scriptDir ".." |
| 14 | +$originalRustdocFlags = $env:RUSTDOCFLAGS |
| 15 | +Set-Location $projectRoot -ErrorAction Stop |
| 16 | + |
| 17 | +$script:exitCode = 0 |
| 18 | +$script:failedCommands = @() |
| 19 | + |
| 20 | +function Register-CommandFailure { |
| 21 | + param( |
| 22 | + [string]$DisplayCommand, |
| 23 | + [int]$Code, |
| 24 | + [string]$Message = "" |
| 25 | + ) |
| 26 | + |
| 27 | + Write-Host ("Command failed with exit code " + $Code + ": " + $DisplayCommand) |
| 28 | + if ($Message -ne "") { |
| 29 | + Write-Host $Message |
| 30 | + } |
| 31 | + |
| 32 | + $script:failedCommands += $DisplayCommand |
| 33 | + if ($script:exitCode -eq 0) { |
| 34 | + $script:exitCode = $Code |
| 35 | + } |
| 36 | +} |
11 | 37 |
|
12 | 38 | function Invoke-LoggedCommand { |
13 | 39 | param( |
14 | 40 | [string]$Command, |
15 | 41 | [string[]]$Arguments |
16 | 42 | ) |
17 | 43 |
|
18 | | - if ($Arguments.Count -gt 0) { |
19 | | - Write-Host ($Command + " " + ($Arguments -join " ")) |
| 44 | + $displayCommand = if ($Arguments.Count -gt 0) { |
| 45 | + $Command + " " + ($Arguments -join " ") |
20 | 46 | } else { |
21 | | - Write-Host $Command |
| 47 | + $Command |
22 | 48 | } |
23 | 49 |
|
24 | | - & $Command @Arguments |
25 | | - if ($LASTEXITCODE -ne 0) { |
26 | | - throw "Command '$Command' failed with exit code $LASTEXITCODE" |
| 50 | + Write-Host $displayCommand |
| 51 | + |
| 52 | + try { |
| 53 | + & $Command @Arguments |
| 54 | + $commandExitCode = $LASTEXITCODE |
| 55 | + } catch { |
| 56 | + Register-CommandFailure $displayCommand 1 $_.Exception.Message |
| 57 | + return |
27 | 58 | } |
28 | | -} |
29 | 59 |
|
30 | | -$originalDir = Get-Location |
31 | | -$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path |
32 | | -$projectRoot = Join-Path $scriptDir ".." |
33 | | -Set-Location $projectRoot |
| 60 | + if ($commandExitCode -ne 0) { |
| 61 | + Register-CommandFailure $displayCommand $commandExitCode |
| 62 | + } |
| 63 | +} |
34 | 64 |
|
35 | 65 | $onLinux = $IsLinux -eq $true |
36 | 66 |
|
|
67 | 97 |
|
68 | 98 | Write-Host "Docs..." |
69 | 99 | $docArgs = @("--workspace", "--document-private-items", "--no-deps", "--quiet", "--exclude", "reloaded-code-bubblewrap") |
70 | | - $originalRustdocFlags = $env:RUSTDOCFLAGS |
71 | 100 | $env:RUSTDOCFLAGS = "-D warnings" |
72 | 101 | try { |
73 | 102 | Invoke-LoggedCommand "cargo" (@("doc") + $docArgs) |
|
78 | 107 | Write-Host "Formatting..." |
79 | 108 | Invoke-LoggedCommand "cargo" @("fmt", "--all", "--quiet") |
80 | 109 |
|
| 110 | + Write-Host "Publish dry-run..." |
| 111 | + Invoke-LoggedCommand "cargo" @("publish", "--dry-run", "--allow-dirty", "--quiet", "--workspace") |
| 112 | + |
81 | 113 | Write-Host "Linux-only feature coverage..." |
82 | 114 | if ($onLinux) { |
83 | 115 | Write-Host "Building (linux async features)..." |
@@ -108,19 +140,28 @@ try { |
108 | 140 | Invoke-LoggedCommand "cargo" @("clippy", "-p", "reloaded-code-core", "--no-default-features", "--features", "blocking,linux-bubblewrap", "--quiet", "--", "-D", "warnings") |
109 | 141 |
|
110 | 142 | Write-Host "Docs (linux-only package)..." |
111 | | - $linuxRustdocFlags = $env:RUSTDOCFLAGS |
112 | 143 | $env:RUSTDOCFLAGS = "-D warnings" |
113 | 144 | try { |
114 | 145 | Invoke-LoggedCommand "cargo" @("doc", "-p", "reloaded-code-bubblewrap", "--document-private-items", "--no-deps", "--quiet") |
115 | 146 | } finally { |
116 | | - $env:RUSTDOCFLAGS = $linuxRustdocFlags |
| 147 | + $env:RUSTDOCFLAGS = $originalRustdocFlags |
117 | 148 | } |
118 | 149 | } else { |
119 | 150 | Write-Host " (skipped - not Linux)" |
120 | 151 | } |
| 152 | +} finally { |
| 153 | + $env:RUSTDOCFLAGS = $originalRustdocFlags |
| 154 | + Set-Location $originalDir |
| 155 | +} |
121 | 156 |
|
| 157 | +if ($script:exitCode -eq 0) { |
122 | 158 | Write-Host "All checks passed!" |
| 159 | +} else { |
| 160 | + Write-Host "Verification failed." |
| 161 | + Write-Host "Failed commands:" |
| 162 | + foreach ($failedCommand in $script:failedCommands) { |
| 163 | + Write-Host (" - " + $failedCommand) |
| 164 | + } |
123 | 165 | } |
124 | | -finally { |
125 | | - Set-Location $originalDir |
126 | | -} |
| 166 | + |
| 167 | +exit $script:exitCode |
0 commit comments