fix: enforce storage and tooling invariants
This commit is contained in:
+30
-5
@@ -16,6 +16,7 @@ $OVERALL = $false
|
||||
$ERRORS = @()
|
||||
$FIXES = @()
|
||||
$OWNED_GDSCRIPT_ROOTS = @("player", "simulation", "tests", "tools", "world")
|
||||
$REQUIRED_GODOT_SERIES = "4.7"
|
||||
|
||||
# -- tool detection -----------------------------------------------------------
|
||||
function ConvertTo-ConsoleGodotPath($Path) {
|
||||
@@ -128,7 +129,10 @@ function To-ResPath($p) {
|
||||
}
|
||||
|
||||
function Invoke-GodotWithTimeout {
|
||||
param([string]$ArgumentString)
|
||||
param(
|
||||
[string]$ArgumentString,
|
||||
[int]$TimeoutSeconds = 30
|
||||
)
|
||||
$psi = New-Object Diagnostics.ProcessStartInfo
|
||||
$psi.FileName = $GODOT
|
||||
$psi.Arguments = $ArgumentString
|
||||
@@ -148,7 +152,7 @@ function Invoke-GodotWithTimeout {
|
||||
}
|
||||
$outputTask = $p.StandardOutput.ReadToEndAsync()
|
||||
$errorTask = $p.StandardError.ReadToEndAsync()
|
||||
$exited = $p.WaitForExit(30000)
|
||||
$exited = $p.WaitForExit($TimeoutSeconds * 1000)
|
||||
if (-not $exited) {
|
||||
$p.Kill()
|
||||
$p.WaitForExit()
|
||||
@@ -167,6 +171,18 @@ if (-not $GODOT) {
|
||||
Write-Host "ERROR: Godot binary not found. Set GODOT_BIN or add godot/godot4 to PATH."
|
||||
exit 1
|
||||
}
|
||||
$godotVersionOutput = @(& $GODOT --version 2>&1)
|
||||
$godotVersionExit = $LASTEXITCODE
|
||||
if ($godotVersionExit -ne 0 -or $godotVersionOutput.Count -eq 0) {
|
||||
Write-Host "ERROR: Could not query the Godot version from '$GODOT'."
|
||||
exit 1
|
||||
}
|
||||
$GODOT_VERSION = ([string]$godotVersionOutput[0]).Trim()
|
||||
$requiredVersionPattern = '^' + [regex]::Escape($REQUIRED_GODOT_SERIES) + '([.-]|$)'
|
||||
if ($GODOT_VERSION -notmatch $requiredVersionPattern) {
|
||||
Write-Host "ERROR: Godot $REQUIRED_GODOT_SERIES.x is required; found '$GODOT_VERSION'."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -- 0. Godot import bootstrap ------------------------------------------------
|
||||
$importResult = "PASS"
|
||||
@@ -182,10 +198,13 @@ $needsImport = (-not $hasProjectClasses) -or
|
||||
($changedGd.Count -gt 0)
|
||||
if ($needsImport) {
|
||||
$importArgs = "--headless --path `"$ROOT`" --import"
|
||||
$importOutput, $importExit = Invoke-GodotWithTimeout -ArgumentString $importArgs
|
||||
$importOutput, $importExit = Invoke-GodotWithTimeout -ArgumentString $importArgs -TimeoutSeconds 60
|
||||
$importOutput | Add-Content -Path "$LOG/godot-import.log" -Encoding utf8
|
||||
if ($importExit -eq $null -or $importExit -ne 0) {
|
||||
$importResult = "FAIL"
|
||||
if ($importExit -eq $null) {
|
||||
Add-Content -Path "$LOG/godot-import.log" -Value "[timed out after 60s]" -Encoding utf8
|
||||
}
|
||||
}
|
||||
}
|
||||
$hasProjectClasses = (Test-Path $classCache) -and
|
||||
@@ -210,8 +229,10 @@ $fmtResult = "PASS"
|
||||
$fmtFailed = $false
|
||||
Set-Content -Path "$LOG/gdformat.log" -Value "" -Encoding utf8
|
||||
if (-not $fmtAvail) {
|
||||
$fmtResult = "SKIPPED"
|
||||
$fmtResult = "FAIL"
|
||||
Add-Content -Path "$LOG/gdformat.log" -Value "gdformat not found -- install requirements-dev.txt (see docs/local_quality_gate.md)" -Encoding utf8
|
||||
$ERRORS += "gdformat: required formatter not found"
|
||||
$FIXES += "Install the pinned dev tools from requirements-dev.txt"
|
||||
} else {
|
||||
if ($Changed) {
|
||||
$files = Get-ChangedGd
|
||||
@@ -260,8 +281,10 @@ $lintResult = "PASS"
|
||||
$lintFailed = $false
|
||||
Set-Content -Path "$LOG/gdlint.log" -Value "" -Encoding utf8
|
||||
if (-not $lintAvail) {
|
||||
$lintResult = "SKIPPED"
|
||||
$lintResult = "FAIL"
|
||||
Add-Content -Path "$LOG/gdlint.log" -Value "gdlint not found -- install requirements-dev.txt (see docs/local_quality_gate.md)" -Encoding utf8
|
||||
$ERRORS += "gdlint: required linter not found"
|
||||
$FIXES += "Install the pinned dev tools from requirements-dev.txt"
|
||||
} else {
|
||||
if ($Changed) {
|
||||
$files = Get-ChangedGd
|
||||
@@ -393,6 +416,7 @@ if ($importResult -eq 'FAIL' -or $fmtResult -eq 'FAIL' -or $lintResult -eq 'FAIL
|
||||
|
||||
Write-Host ""
|
||||
if ($OVERALL) { Write-Host "QUALITY RESULT: FAIL" } else { Write-Host "QUALITY RESULT: PASS" }
|
||||
Write-Host "Godot: $GODOT_VERSION"
|
||||
Write-Host ""
|
||||
Write-Host " godot-import $importResult"
|
||||
Write-Host " gdformat $fmtResult"
|
||||
@@ -430,6 +454,7 @@ Write-Host ""
|
||||
if ($OVERALL) { $resultText = "FAIL" } else { $resultText = "PASS" }
|
||||
$summary = @"
|
||||
QUALITY RESULT: $resultText
|
||||
Godot: $GODOT_VERSION
|
||||
|
||||
godot-import $importResult
|
||||
gdformat $fmtResult
|
||||
|
||||
Reference in New Issue
Block a user