121 lines
4.1 KiB
PowerShell
121 lines
4.1 KiB
PowerShell
param(
|
|
[string]$ApiUrl = "http://192.168.3.90:8001/api/v1",
|
|
[string]$Password = "123456",
|
|
[string]$ArtifactRoot = ""
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
|
|
$timestamp = Get-Date -Format "yyyy-MM-ddTHH-mm-ss-fff"
|
|
if ([string]::IsNullOrWhiteSpace($ArtifactRoot)) {
|
|
$ArtifactRoot = Join-Path $repoRoot "project-docs\qa-artifacts\review-structured-acceptance-gate"
|
|
}
|
|
$artifactDir = Join-Path $ArtifactRoot $timestamp
|
|
$summaryPath = Join-Path $artifactDir "review-structured-acceptance-gate-wrapper-summary.json"
|
|
$summaryMd = Join-Path $artifactDir "review-structured-acceptance-gate-wrapper-summary.md"
|
|
|
|
New-Item -ItemType Directory -Force -Path $artifactDir | Out-Null
|
|
|
|
$checks = New-Object System.Collections.Generic.List[object]
|
|
|
|
function Add-Check {
|
|
param(
|
|
[string]$Label,
|
|
[ValidateSet("PASS", "FAIL", "WARN")]
|
|
[string]$Status,
|
|
[string]$Detail,
|
|
[bool]$Required = $true
|
|
)
|
|
|
|
$checks.Add([ordered]@{
|
|
label = $Label
|
|
status = $Status
|
|
detail = $Detail
|
|
required = $Required
|
|
}) | Out-Null
|
|
}
|
|
|
|
if (Test-Path "$HOME\.Codex\skills\gstack\bin") {
|
|
Add-Check -Label "gstack preflight" -Status "PASS" -Detail "GSTACK_OK"
|
|
} else {
|
|
Add-Check -Label "gstack preflight" -Status "FAIL" -Detail "GSTACK_MISSING"
|
|
}
|
|
|
|
$pythonPath = Join-Path $repoRoot "backend\.venv\Scripts\python.exe"
|
|
if (Test-Path $pythonPath) {
|
|
Add-Check -Label "backend venv python" -Status "PASS" -Detail "Backend venv python found"
|
|
} else {
|
|
Add-Check -Label "backend venv python" -Status "FAIL" -Detail "Missing backend venv python"
|
|
}
|
|
|
|
$toolPath = Join-Path $repoRoot "backend\tools\review_structured_acceptance_gate.py"
|
|
if (Test-Path $toolPath) {
|
|
Add-Check -Label "structured acceptance tool" -Status "PASS" -Detail "Tool found"
|
|
} else {
|
|
Add-Check -Label "structured acceptance tool" -Status "FAIL" -Detail "Tool missing"
|
|
}
|
|
|
|
$gitStatus = git -C $repoRoot status --short
|
|
if ($gitStatus) {
|
|
Add-Check -Label "working tree" -Status "WARN" -Detail "Working tree has uncommitted changes" -Required $false
|
|
} else {
|
|
Add-Check -Label "working tree" -Status "PASS" -Detail "Working tree is clean" -Required $false
|
|
}
|
|
|
|
$failed = @($checks | Where-Object { $_.required -and $_.status -eq "FAIL" })
|
|
if ($failed.Count -eq 0) {
|
|
$logPath = Join-Path $artifactDir "review-structured-acceptance-gate.log"
|
|
$baselineRoot = Join-Path $artifactDir "baselines"
|
|
& $pythonPath $toolPath --api-base $ApiUrl --artifact-dir $artifactDir --password $Password --baseline-root $baselineRoot 2>&1 | Tee-Object -FilePath $logPath
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Add-Check -Label "structured acceptance gate" -Status "PASS" -Detail "Structured acceptance gate passed"
|
|
} else {
|
|
Add-Check -Label "structured acceptance gate" -Status "FAIL" -Detail "Structured acceptance gate failed"
|
|
}
|
|
}
|
|
|
|
$status = "PASS"
|
|
if (@($checks | Where-Object { $_.required -and $_.status -eq "FAIL" }).Count -gt 0) {
|
|
$status = "FAIL"
|
|
} elseif (@($checks | Where-Object { $_.status -eq "WARN" }).Count -gt 0) {
|
|
$status = "WARN"
|
|
}
|
|
|
|
$summary = [ordered]@{
|
|
name = "review-structured-acceptance-gate-wrapper"
|
|
status = $status
|
|
generated_at = (Get-Date).ToUniversalTime().ToString("o")
|
|
artifact_dir = $artifactDir
|
|
api_url = $ApiUrl
|
|
checks = $checks
|
|
}
|
|
$summary | ConvertTo-Json -Depth 8 | Set-Content -Encoding UTF8 -Path $summaryPath
|
|
|
|
$lines = @(
|
|
"# Review Structured Acceptance Gate Wrapper",
|
|
"",
|
|
"- Status: $status",
|
|
"- Generated at: $($summary.generated_at)",
|
|
"- Artifact dir: $artifactDir",
|
|
"- API URL: $ApiUrl",
|
|
"",
|
|
"| Check | Required | Status | Detail |",
|
|
"|---|---:|---|---|"
|
|
)
|
|
foreach ($check in $checks) {
|
|
$lines += "| $($check.label) | $($check.required) | $($check.status) | $($check.detail) |"
|
|
}
|
|
$lines -join [Environment]::NewLine | Set-Content -Encoding UTF8 -Path $summaryMd
|
|
|
|
if ($status -eq "FAIL") {
|
|
Write-Host "REVIEW_STRUCTURED_ACCEPTANCE_GATE_FAIL $artifactDir"
|
|
throw "Review structured acceptance gate failed. See $summaryMd"
|
|
}
|
|
|
|
if ($status -eq "WARN") {
|
|
Write-Host "REVIEW_STRUCTURED_ACCEPTANCE_GATE_WARN $artifactDir"
|
|
} else {
|
|
Write-Host "REVIEW_STRUCTURED_ACCEPTANCE_GATE_PASS $artifactDir"
|
|
}
|