<#
One-command quality gate for ek-ctp.
Runs (in order):
1. cargo fmt --check (0 output expected)
2. cargo test (default features)
3. cargo clippy --all-targets -- -D warnings
4. cargo doc --no-deps
5. scripts/check-package.ps1 (package content guard; strict unless -AllowDirty)
6. -WithNative only: cargo test/clippy --features native
Usage:
powershell -ExecutionPolicy Bypass -File scripts/gate.ps1
powershell -ExecutionPolicy Bypass -File scripts/gate.ps1 -AllowDirty
powershell -ExecutionPolicy Bypass -File scripts/gate.ps1 -WithNative
Exit code: 0 = all gates passed, 1 = at least one gate failed.
Note: formatting results are bound to the rustfmt version; the repo baseline is
rustfmt 1.8.0-stable with rustc 1.94.0 (both printed below). A different rustfmt
may report a false failure.
NOTE: ASCII-only on purpose (Windows PowerShell 5.1 decodes BOM-less .ps1 as ANSI).
#>
[CmdletBinding()]
param(
[switch]$AllowDirty,
[switch]$WithNative
)
# 'Continue' on purpose: cargo/clippy write progress to stderr, which PowerShell
# would otherwise surface as terminating errors when the preference is 'Stop'.
$ErrorActionPreference = 'Continue'
$root = Split-Path -Parent $PSScriptRoot
Push-Location $root
try {
Write-Host "toolchain:" -ForegroundColor Cyan
& rustfmt --version
& rustc --version
& cargo --version
$results = New-Object System.Collections.ArrayList
function Invoke-Gate {
param([string]$Name, [scriptblock]$Body)
Write-Host ""
Write-Host ("=== " + $Name + " ===") -ForegroundColor Cyan
& $Body
$code = $LASTEXITCODE
if ($null -eq $code) { $code = 0 }
if ($code -eq 0) {
Write-Host ("PASS " + $Name) -ForegroundColor Green
[void]$results.Add([pscustomobject]@{ Name = $Name; Ok = $true })
} else {
Write-Host ("FAIL " + $Name + " (exit " + $code + ")") -ForegroundColor Red
[void]$results.Add([pscustomobject]@{ Name = $Name; Ok = $false })
}
}
Invoke-Gate 'cargo fmt --check' { cargo fmt --check }
Invoke-Gate 'cargo test' { cargo test }
Invoke-Gate 'cargo clippy --all-targets -- -D warnings' { cargo clippy --all-targets -- -D warnings }
Invoke-Gate 'cargo doc --no-deps' { cargo doc --no-deps }
$guard = Join-Path $PSScriptRoot 'check-package.ps1'
if ($AllowDirty) {
Invoke-Gate 'scripts/check-package.ps1 -AllowDirty' { & $guard -AllowDirty }
} else {
Invoke-Gate 'scripts/check-package.ps1 (strict)' { & $guard }
}
if ($WithNative) {
Invoke-Gate 'cargo test --features native' { cargo test --features native }
Invoke-Gate 'cargo clippy --features native' { cargo clippy --all-targets --features native -- -D warnings }
}
Write-Host ""
Write-Host "===== gate summary =====" -ForegroundColor Cyan
$failed = 0
foreach ($r in $results) {
if ($r.Ok) {
Write-Host (" PASS " + $r.Name) -ForegroundColor Green
} else {
Write-Host (" FAIL " + $r.Name) -ForegroundColor Red
$failed++
}
}
if ($failed -eq 0) {
Write-Host "ALL GATES PASSED" -ForegroundColor Green
exit 0
} else {
Write-Host ("GATES FAILED: " + $failed) -ForegroundColor Red
exit 1
}
} finally {
Pop-Location
}