fix: harden cross-platform quality tooling

This commit is contained in:
Rijad Zuzo
2026-07-30 13:42:38 +02:00
parent e284d3774d
commit 5511c295a5
7 changed files with 370 additions and 95 deletions
+68 -12
View File
@@ -18,6 +18,13 @@ OVERALL=false
ERRORS=()
FIXES=()
OWNED_GDSCRIPT_ROOTS=(player simulation tests tools world)
CROSS_PLATFORM_PLUGIN_FILES=(
addons/terrain_3d/terrain.gdextension
addons/terrain_3d/bin/libterrain.macos.debug.framework/libterrain.macos.debug
addons/terrain_3d/bin/libterrain.macos.release.framework/libterrain.macos.release
addons/terrain_3d/bin/libterrain.windows.debug.x86_64.dll
addons/terrain_3d/bin/libterrain.windows.release.x86_64.dll
)
REQUIRED_GODOT_SERIES="4.7"
# -- tool detection -----------------------------------------------------------
@@ -48,17 +55,47 @@ find_project_godot() {
}
find_godot() {
if [[ -n "${GODOT_BIN:-}" ]]; then console_godot_path "$GODOT_BIN" && return 0; echo "$GODOT_BIN"; return 0; fi
if [[ -n "${GODOT_BIN:-}" ]]; then
if console_godot_path "$GODOT_BIN"; then return 0; fi
echo "ERROR: GODOT_BIN does not point to a Godot executable: $GODOT_BIN" >&2
return 1
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
}
has_python_module() {
local module="$1"
local python_command
for python_command in python python3; do
if command -v "$python_command" &>/dev/null &&
"$python_command" -m "$module" --help &>/dev/null 2>&1; then
return 0
fi
done
return 1
}
run_python_module() {
local module="$1"
shift
local python_command
for python_command in python python3; do
if command -v "$python_command" &>/dev/null &&
"$python_command" -m "$module" --help &>/dev/null 2>&1; then
"$python_command" -m "$module" "$@"
return $?
fi
done
return 127
}
has_gdformat() {
[[ -x "$ROOT/.venv/bin/gdformat" ]] && return 0
command -v gdformat &>/dev/null && return 0
python -m gdtoolkit.formatter --help &>/dev/null 2>&1
has_python_module gdtoolkit.formatter
}
run_gdformat() {
@@ -67,14 +104,14 @@ run_gdformat() {
elif command -v gdformat &>/dev/null; then
gdformat "$@"
else
python -m gdtoolkit.formatter "$@"
run_python_module gdtoolkit.formatter "$@"
fi
}
has_gdlint() {
[[ -x "$ROOT/.venv/bin/gdlint" ]] && return 0
command -v gdlint &>/dev/null && return 0
python -m gdtoolkit.linter --help &>/dev/null 2>&1
has_python_module gdtoolkit.linter
}
run_gdlint() {
@@ -83,7 +120,7 @@ run_gdlint() {
elif command -v gdlint &>/dev/null; then
gdlint "$@"
else
python -m gdtoolkit.linter "$@"
run_python_module gdtoolkit.linter "$@"
fi
}
@@ -161,7 +198,21 @@ case "$GODOT_VERSION" in
esac
GODOT_ENV=(env "HOME=$GODOT_PROFILE" "APPDATA=$GODOT_PROFILE" "LOCALAPPDATA=$GODOT_PROFILE")
# -- 0. Godot import bootstrap ------------------------------------------------
# -- 0. Cross-platform plugin payload -----------------------------------------
platform_assets_result="PASS"
: > "$LOG/platform-assets.log"
for plugin_file in "${CROSS_PLATFORM_PLUGIN_FILES[@]}"; do
if [[ ! -f "$plugin_file" ]]; then
platform_assets_result="FAIL"
echo "Missing $plugin_file" >> "$LOG/platform-assets.log"
ERRORS+=("platform-assets: missing res://$plugin_file")
fi
done
if [[ "$platform_assets_result" == "FAIL" ]]; then
FIXES+=("Restore the complete pinned Terrain3D 1.0.2 package")
fi
# -- 1. Godot import bootstrap ------------------------------------------------
import_result="PASS"
: > "$LOG/godot-import.log"
class_cache="$ROOT/.godot/global_script_class_cache.cfg"
@@ -195,7 +246,7 @@ if [[ "$import_result" == "FAIL" ]]; then
FIXES+=("Fix Godot import errors before running headless checks")
fi
# -- 1. gdformat --------------------------------------------------------------
# -- 2. gdformat --------------------------------------------------------------
fmt_result="PASS"
fmt_failed=false
: > "$LOG/gdformat.log"
@@ -243,7 +294,7 @@ elif $fmt_failed; then
FIXES+=("Fix the gdformat error before continuing")
fi
# -- 2. gdlint ----------------------------------------------------------------
# -- 3. gdlint ----------------------------------------------------------------
lint_result="PASS"
lint_failed=false
: > "$LOG/gdlint.log"
@@ -297,7 +348,7 @@ elif $lint_failed; then
FIXES+=("Fix the gdlint error before continuing")
fi
# -- 3. godot headless check --------------------------------------------------
# -- 4. godot headless check --------------------------------------------------
godot_result="PASS"
: > "$LOG/godot-check.log"
if run_with_timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
@@ -319,7 +370,7 @@ if [[ "$godot_result" == "FAIL" ]]; then
FIXES+=("Fix Godot parser errors")
fi
# -- 4. project scenario tests ------------------------------------------------
# -- 5. project scenario tests ------------------------------------------------
scenario_result="PASS"
: > "$LOG/scenarios.log"
for test in tests/*_test.gd; do
@@ -337,7 +388,7 @@ if [[ "$scenario_result" == "FAIL" ]]; then
FIXES+=("Fix failing project scenario tests")
fi
# -- 5. GUT -------------------------------------------------------------------
# -- 6. GUT -------------------------------------------------------------------
gut_result="PASS"
: > "$LOG/gut.log"
if [[ ! -f "addons/gut/gut_cmdln.gd" ]]; then
@@ -365,7 +416,10 @@ else
fi
# -- summary ------------------------------------------------------------------
if [[ "$import_result" == "FAIL" || "$fmt_result" == "FAIL" || "$lint_result" == "FAIL" || "$godot_result" == "FAIL" || "$scenario_result" == "FAIL" || "$gut_result" == "FAIL" ]]; then
if [[ "$platform_assets_result" == "FAIL" || "$import_result" == "FAIL" ||
"$fmt_result" == "FAIL" || "$lint_result" == "FAIL" ||
"$godot_result" == "FAIL" || "$scenario_result" == "FAIL" ||
"$gut_result" == "FAIL" ]]; then
OVERALL=true
fi
@@ -377,6 +431,7 @@ else
fi
echo "Godot: $GODOT_VERSION"
echo ""
echo " platform-assets $platform_assets_result"
echo " godot-import $import_result"
echo " gdformat $fmt_result"
echo " gdlint $lint_result"
@@ -415,6 +470,7 @@ echo ""
echo "QUALITY RESULT: $($OVERALL && echo FAIL || echo PASS)"
echo "Godot: $GODOT_VERSION"
echo ""
echo " platform-assets $platform_assets_result"
echo " godot-import $import_result"
echo " gdformat $fmt_result"
echo " gdlint $lint_result"