From b0bad6c467f7227562b9cb30ff4f43e888a29647 Mon Sep 17 00:00:00 2001 From: Rijad Zuzo Date: Tue, 7 Jul 2026 15:48:22 +0200 Subject: [PATCH] fix: stabilize godot 4.7 headless validation --- tools/quality.ps1 | 37 +++++++++++++++++++++++++-- tools/quality.sh | 41 +++++++++++++++++++++++++----- world/activity/ActivitySite.gd | 2 +- world/activity/ActivitySite.gd.uid | 1 + world/storage/StorageNode.gd | 2 +- 5 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 world/activity/ActivitySite.gd.uid diff --git a/tools/quality.ps1 b/tools/quality.ps1 index fa75ac2..d0e9b92 100644 --- a/tools/quality.ps1 +++ b/tools/quality.ps1 @@ -9,6 +9,8 @@ Set-Location $ROOT $LOG = "logs/quality/latest" New-Item -ItemType Directory -Path $LOG -Force | Out-Null +$GODOT_PROFILE = Join-Path $ROOT "logs/quality/godot_profile" +New-Item -ItemType Directory -Path $GODOT_PROFILE -Force | Out-Null $OVERALL = $false $ERRORS = @() @@ -16,8 +18,30 @@ $FIXES = @() $OWNED_GDSCRIPT_ROOTS = @("player", "simulation", "tests", "tools", "world") # -- tool detection ----------------------------------------------------------- +function ConvertTo-ConsoleGodotPath($Path) { + if (-not $Path) { return $null } + $normalized = $Path.Replace('/', '\').Trim('"') + if ($normalized.EndsWith(".exe")) { + $consolePath = $normalized -replace '\.exe$', '_console.exe' + if (Test-Path $consolePath) { return $consolePath } + } + if (Test-Path $normalized) { return $normalized } + return $null +} + +function Find-ProjectGodot { + $metadata = Join-Path $ROOT ".godot/editor/project_metadata.cfg" + if (-not (Test-Path $metadata)) { return $null } + $line = Select-String -Path $metadata -Pattern '^executable_path=' | Select-Object -First 1 + if (-not $line) { return $null } + $rawPath = ($line.Line -replace '^executable_path=', '').Trim().Trim('"') + return ConvertTo-ConsoleGodotPath $rawPath +} + function Find-Godot { - if ($env:GODOT_BIN) { return $env:GODOT_BIN } + if ($env:GODOT_BIN) { return (ConvertTo-ConsoleGodotPath $env:GODOT_BIN) } + $projectGodot = Find-ProjectGodot + if ($projectGodot) { return $projectGodot } try { return (Get-Command godot -ErrorAction Stop).Source } catch {} try { return (Get-Command godot4 -ErrorAction Stop).Source } catch {} $common = @( @@ -99,7 +123,16 @@ function Invoke-GodotWithTimeout { $psi.RedirectStandardError = $true $psi.UseShellExecute = $false $psi.CreateNoWindow = $true - $p = [Diagnostics.Process]::Start($psi) + $previousAppData = $env:APPDATA + $previousLocalAppData = $env:LOCALAPPDATA + $env:APPDATA = $GODOT_PROFILE + $env:LOCALAPPDATA = $GODOT_PROFILE + try { + $p = [Diagnostics.Process]::Start($psi) + } finally { + $env:APPDATA = $previousAppData + $env:LOCALAPPDATA = $previousLocalAppData + } $outputTask = $p.StandardOutput.ReadToEndAsync() $errorTask = $p.StandardError.ReadToEndAsync() $exited = $p.WaitForExit(30000) diff --git a/tools/quality.sh b/tools/quality.sh index 4917903..ae8ab2d 100644 --- a/tools/quality.sh +++ b/tools/quality.sh @@ -9,6 +9,8 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" || exit 1 LOG="logs/quality/latest" mkdir -p "$LOG" +GODOT_PROFILE="$ROOT/logs/quality/godot_profile" +mkdir -p "$GODOT_PROFILE" CHANGED=false [[ "${1:-}" == "--changed" ]] && CHANGED=true @@ -18,8 +20,35 @@ FIXES=() OWNED_GDSCRIPT_ROOTS=(player simulation tests tools world) # -- tool detection ----------------------------------------------------------- +console_godot_path() { + local candidate="${1:-}" + [[ -z "$candidate" ]] && return 1 + candidate="${candidate%\"}" + candidate="${candidate#\"}" + candidate="${candidate//\\//}" + if [[ "$candidate" == *.exe ]]; then + local console_candidate="${candidate%.exe}_console.exe" + if [[ -f "$console_candidate" ]]; then echo "$console_candidate"; return 0; fi + fi + if [[ -f "$candidate" ]]; then echo "$candidate"; return 0; fi + return 1 +} + +find_project_godot() { + local metadata="$ROOT/.godot/editor/project_metadata.cfg" + [[ -f "$metadata" ]] || return 1 + local line path + line="$(grep -m 1 '^executable_path=' "$metadata" 2>/dev/null || true)" + [[ -n "$line" ]] || return 1 + path="${line#executable_path=}" + path="${path%\"}" + path="${path#\"}" + console_godot_path "$path" +} + find_godot() { - if [[ -n "${GODOT_BIN:-}" ]]; then echo "$GODOT_BIN"; return 0; fi + 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 return 1 } @@ -148,7 +177,7 @@ fi godot_result="PASS" : > "$LOG/godot-check.log" if need_timeout; then - if timeout 30 "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then + if APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" timeout 30 "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then godot_result="PASS" else ec=$? @@ -160,7 +189,7 @@ if need_timeout; then fi fi else - if "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then + if APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then godot_result="PASS" else godot_result="FAIL" @@ -179,11 +208,11 @@ scenario_result="PASS" for test in tests/*_test.gd; do echo "[RUN] $(basename "$test")" >> "$LOG/scenarios.log" if need_timeout; then - if ! timeout 30 "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then + if ! APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" timeout 30 "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then scenario_result="FAIL" ERRORS+=("scenario: $(basename "$test") failed or timed out") fi - elif ! "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then + elif ! APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then scenario_result="FAIL" ERRORS+=("scenario: $(basename "$test") failed") fi @@ -196,7 +225,7 @@ fi gut_result="SKIPPED" : > "$LOG/gut.log" if [[ -f "addons/gut/gut_cmdln.gd" ]]; then - if $GODOT --headless --path "$ROOT" -s addons/gut/gut_cmdln.gd >> "$LOG/gut.log" 2>&1; then + if APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" "$GODOT" --headless --path "$ROOT" -s addons/gut/gut_cmdln.gd >> "$LOG/gut.log" 2>&1; then gut_result="PASS" else gut_result="FAIL" diff --git a/world/activity/ActivitySite.gd b/world/activity/ActivitySite.gd index 5bc70c9..52964fa 100644 --- a/world/activity/ActivitySite.gd +++ b/world/activity/ActivitySite.gd @@ -19,7 +19,7 @@ func _ready() -> void: push_error("ActivitySite at %s has empty site_id" % get_path()) _update_presentation() return - var existing := get_by_id(site_id) + var existing: ActivitySite = get_by_id(site_id) as ActivitySite if existing != null: push_error( ( diff --git a/world/activity/ActivitySite.gd.uid b/world/activity/ActivitySite.gd.uid new file mode 100644 index 0000000..66cccc4 --- /dev/null +++ b/world/activity/ActivitySite.gd.uid @@ -0,0 +1 @@ +uid://bly1hd36boprk diff --git a/world/storage/StorageNode.gd b/world/storage/StorageNode.gd index 5fa4846..6fe9c6c 100644 --- a/world/storage/StorageNode.gd +++ b/world/storage/StorageNode.gd @@ -21,7 +21,7 @@ func _ready() -> void: push_error("StorageNode at %s has empty storage_id" % get_path()) _update_presentation() return - var existing := get_by_id(storage_id) + var existing: StorageNode = get_by_id(storage_id) as StorageNode if existing != null: push_error( (