add a single verification gate for all four checks
This commit is contained in:
+82
@@ -0,0 +1,82 @@
|
|||||||
|
# ByteSize verification gate.
|
||||||
|
#
|
||||||
|
# Runs the four checks that have to be green before a change is done:
|
||||||
|
# the frontend type gate, then the Rust check, lint and test passes.
|
||||||
|
#
|
||||||
|
# Run it from the repo root:
|
||||||
|
#
|
||||||
|
# powershell -File verify.ps1
|
||||||
|
#
|
||||||
|
# Exit code 0 means everything passed. Any failure stops the run and names the
|
||||||
|
# failing step, because a later step's output is noise once an earlier one broke.
|
||||||
|
|
||||||
|
$root = $PSScriptRoot
|
||||||
|
$failures = @()
|
||||||
|
$passed = @()
|
||||||
|
|
||||||
|
function Invoke-Step {
|
||||||
|
param(
|
||||||
|
[string]$Name,
|
||||||
|
[scriptblock]$Body
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "=== $Name ===" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
# npm and cargo both write progress banners to stderr. Under
|
||||||
|
# ErrorActionPreference=Stop that becomes a terminating NativeCommandError
|
||||||
|
# in PowerShell 5.1, so relax it for the duration of the call and judge the
|
||||||
|
# step on its exit code instead.
|
||||||
|
$previous = $ErrorActionPreference
|
||||||
|
$ErrorActionPreference = 'Continue'
|
||||||
|
try {
|
||||||
|
$output = & $Body 2>&1 | ForEach-Object { "$_" }
|
||||||
|
$code = $LASTEXITCODE
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
$ErrorActionPreference = $previous
|
||||||
|
}
|
||||||
|
|
||||||
|
$output | ForEach-Object { Write-Host $_ }
|
||||||
|
|
||||||
|
if ($code -ne 0) {
|
||||||
|
$script:failures += "$Name (exit $code)"
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "ok: $Name" -ForegroundColor Green
|
||||||
|
$script:passed += $Name
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Path (Join-Path $root 'node_modules'))) {
|
||||||
|
Write-Host "node_modules is missing - the frontend gate cannot run." -ForegroundColor Yellow
|
||||||
|
Write-Host "Install it with the per-command override, because the user-level"
|
||||||
|
Write-Host "allow-scripts setting belongs to another project and npm 12 rejects it:"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " `$env:npm_config_allow_scripts = ''; npm ci --no-audit --no-fund"
|
||||||
|
Write-Host ""
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Push-Location $root
|
||||||
|
try {
|
||||||
|
$null = Invoke-Step 'svelte-check (frontend types)' { npm run check }
|
||||||
|
if ($failures.Count -eq 0) { $null = Invoke-Step 'cargo check' { cargo check --manifest-path src-tauri/Cargo.toml } }
|
||||||
|
if ($failures.Count -eq 0) { $null = Invoke-Step 'cargo clippy' { cargo clippy --manifest-path src-tauri/Cargo.toml } }
|
||||||
|
if ($failures.Count -eq 0) { $null = Invoke-Step 'cargo test' { cargo test --manifest-path src-tauri/Cargo.toml } }
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
if ($failures.Count -gt 0) {
|
||||||
|
Write-Host "FAILED:" -ForegroundColor Red
|
||||||
|
$failures | ForEach-Object { Write-Host " - $_" -ForegroundColor Red }
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "All $($passed.Count) checks passed:" -ForegroundColor Green
|
||||||
|
$passed | ForEach-Object { Write-Host " - $_" -ForegroundColor Green }
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user