Files
silk/scripts/verify.ps1
T
2026-08-14 09:03:48 +08:00

96 lines
2.3 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$script:failed = @()
function Resolve-Go {
$cmd = Get-Command go -ErrorAction SilentlyContinue
if ($cmd) {
return $cmd.Source
}
foreach ($candidate in @('C:\Program Files\Go\bin\go.exe', 'C:\Go\bin\go.exe')) {
if (Test-Path -LiteralPath $candidate) {
return $candidate
}
}
throw 'Go executable not found. Install Go 1.23 or add it to PATH.'
}
function Invoke-Check {
param(
[Parameter(Mandatory = $true)]
[string]$Name,
[Parameter(Mandatory = $true)]
[scriptblock]$Command
)
Write-Host "[$Name]"
try {
& $Command
if ($LASTEXITCODE -ne 0) {
Write-Host "FAILED: $Name (exit $LASTEXITCODE)"
$script:failed += $Name
}
} catch {
Write-Host "FAILED: $Name - $($_.Exception.Message)"
$script:failed += $Name
}
}
$goExe = Resolve-Go
Push-Location (Join-Path $root 'server-go')
try {
Invoke-Check 'server-go test' { & $goExe test ./... }
Invoke-Check 'server-go vet' { & $goExe vet ./... }
Invoke-Check 'server-go build' { & $goExe build ./... }
} finally {
Pop-Location
}
Push-Location (Join-Path $root 'web')
try {
Invoke-Check 'web test' { npm test }
Invoke-Check 'web lint' { npm run lint }
Invoke-Check 'web build' { npm run build }
} finally {
Pop-Location
}
Push-Location (Join-Path $root 'miniapp')
try {
Invoke-Check 'miniapp test' { npm test }
Invoke-Check 'miniapp typecheck' { npm run typecheck }
Invoke-Check 'miniapp build:weapp' { npm run build:weapp }
} finally {
Pop-Location
}
Push-Location (Join-Path $root 'app')
try {
Invoke-Check 'app typecheck' { npm run tsc }
Invoke-Check 'app lint' { npm run lint }
} finally {
Pop-Location
}
$aiPython = Join-Path $root 'ai-service\.venv\Scripts\python.exe'
if (-not (Test-Path -LiteralPath $aiPython)) {
$aiPython = 'python'
}
Push-Location (Join-Path $root 'ai-service')
try {
Invoke-Check 'ai-service pytest' { & $aiPython -m pytest }
} finally {
Pop-Location
}
if ($script:failed.Count -gt 0) {
Write-Error "Verification failed for: $($script:failed -join ', ')"
exit 1
}
Write-Host 'All verification checks passed.'
exit 0