fix: enforce storage and tooling invariants

This commit is contained in:
Rijad Zuzo
2026-07-30 13:00:59 +02:00
parent e3aa3440a2
commit e284d3774d
9 changed files with 283 additions and 30 deletions
+30 -5
View File
@@ -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
+25 -4
View File
@@ -18,6 +18,7 @@ OVERALL=false
ERRORS=()
FIXES=()
OWNED_GDSCRIPT_ROOTS=(player simulation tests tools world)
REQUIRED_GODOT_SERIES="4.7"
# -- tool detection -----------------------------------------------------------
console_godot_path() {
@@ -50,6 +51,7 @@ find_godot() {
if [[ -n "${GODOT_BIN:-}" ]]; then console_godot_path "$GODOT_BIN" && return 0; echo "$GODOT_BIN"; return 0; fi
find_project_godot && return 0
for c in godot godot4; do command -v "$c" &>/dev/null && echo "$c" && return 0; done
console_godot_path "/Applications/Godot.app/Contents/MacOS/Godot" && return 0
return 1
}
@@ -144,6 +146,19 @@ if [[ -z "$GODOT" ]]; then
echo "ERROR: Godot binary not found. Set GODOT_BIN or add godot/godot4 to PATH."
exit 1
fi
if ! GODOT_VERSION="$("$GODOT" --version 2>&1)"; then
echo "ERROR: Could not query the Godot version from '$GODOT'."
exit 1
fi
GODOT_VERSION="${GODOT_VERSION%%$'\n'*}"
GODOT_VERSION="${GODOT_VERSION%$'\r'}"
case "$GODOT_VERSION" in
"$REQUIRED_GODOT_SERIES"|"$REQUIRED_GODOT_SERIES".*|"$REQUIRED_GODOT_SERIES"-*) ;;
*)
echo "ERROR: Godot $REQUIRED_GODOT_SERIES.x is required; found '$GODOT_VERSION'."
exit 1
;;
esac
GODOT_ENV=(env "HOME=$GODOT_PROFILE" "APPDATA=$GODOT_PROFILE" "LOCALAPPDATA=$GODOT_PROFILE")
# -- 0. Godot import bootstrap ------------------------------------------------
@@ -185,8 +200,10 @@ fmt_result="PASS"
fmt_failed=false
: > "$LOG/gdformat.log"
if ! has_gdformat; then
fmt_result="SKIPPED"
fmt_result="FAIL"
echo "gdformat not found — install requirements-dev.txt (see docs/local_quality_gate.md)" > "$LOG/gdformat.log"
ERRORS+=("gdformat: required formatter not found")
FIXES+=("Install the pinned dev tools from requirements-dev.txt")
else
if $CHANGED; then
files=$(changed_gd)
@@ -231,8 +248,10 @@ lint_result="PASS"
lint_failed=false
: > "$LOG/gdlint.log"
if ! has_gdlint; then
lint_result="SKIPPED"
lint_result="FAIL"
echo "gdlint not found — install requirements-dev.txt (see docs/local_quality_gate.md)" > "$LOG/gdlint.log"
ERRORS+=("gdlint: required linter not found")
FIXES+=("Install the pinned dev tools from requirements-dev.txt")
else
if $CHANGED; then
files=$(changed_gd)
@@ -294,9 +313,9 @@ if grep -qE "SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/godot-check
godot_result="FAIL"
fi
if [[ "$godot_result" == "FAIL" ]]; then
grep -iE "error|warning|parse|syntax" "$LOG/godot-check.log" 2>/dev/null | head -20 | while IFS= read -r errline; do
while IFS= read -r errline; do
ERRORS+=("godot: $errline")
done
done < <(grep -iE "error|warning|parse|syntax" "$LOG/godot-check.log" 2>/dev/null | head -20)
FIXES+=("Fix Godot parser errors")
fi
@@ -356,6 +375,7 @@ if $OVERALL; then
else
echo "QUALITY RESULT: PASS"
fi
echo "Godot: $GODOT_VERSION"
echo ""
echo " godot-import $import_result"
echo " gdformat $fmt_result"
@@ -393,6 +413,7 @@ echo ""
{
echo "QUALITY RESULT: $($OVERALL && echo FAIL || echo PASS)"
echo "Godot: $GODOT_VERSION"
echo ""
echo " godot-import $import_result"
echo " gdformat $fmt_result"