feat: add witnessed knowledge and wind ambience
This commit is contained in:
+107
-60
@@ -53,22 +53,43 @@ find_godot() {
|
||||
return 1
|
||||
}
|
||||
|
||||
find_gdformat() {
|
||||
if [[ -x "$ROOT/.venv/bin/gdformat" ]]; then echo "$ROOT/.venv/bin/gdformat"; return 0; fi
|
||||
if command -v gdformat &>/dev/null; then echo "gdformat"; return 0; fi
|
||||
if python -m gdtoolkit.formatter --help &>/dev/null 2>&1; then echo "python -m gdtoolkit.formatter"; return 0; fi
|
||||
return 1
|
||||
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
|
||||
}
|
||||
|
||||
find_gdlint() {
|
||||
if [[ -x "$ROOT/.venv/bin/gdlint" ]]; then echo "$ROOT/.venv/bin/gdlint"; return 0; fi
|
||||
if command -v gdlint &>/dev/null; then echo "gdlint"; return 0; fi
|
||||
if python -m gdtoolkit.linter --help &>/dev/null 2>&1; then echo "python -m gdtoolkit.linter"; return 0; fi
|
||||
return 1
|
||||
run_gdformat() {
|
||||
if [[ -x "$ROOT/.venv/bin/gdformat" ]]; then
|
||||
"$ROOT/.venv/bin/gdformat" "$@"
|
||||
elif command -v gdformat &>/dev/null; then
|
||||
gdformat "$@"
|
||||
else
|
||||
python -m 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
|
||||
}
|
||||
|
||||
run_gdlint() {
|
||||
if [[ -x "$ROOT/.venv/bin/gdlint" ]]; then
|
||||
"$ROOT/.venv/bin/gdlint" "$@"
|
||||
elif command -v gdlint &>/dev/null; then
|
||||
gdlint "$@"
|
||||
else
|
||||
python -m gdtoolkit.linter "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
changed_gd() {
|
||||
git diff --name-only HEAD -- '*.gd' 2>/dev/null || true
|
||||
{
|
||||
git diff --name-only HEAD -- '*.gd' 2>/dev/null
|
||||
git ls-files --others --exclude-standard -- '*.gd' 2>/dev/null
|
||||
} | sort -u || true
|
||||
}
|
||||
|
||||
res_path() {
|
||||
@@ -83,8 +104,38 @@ contains_element() {
|
||||
local e; for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done; return 1
|
||||
}
|
||||
|
||||
need_timeout() {
|
||||
command -v timeout &>/dev/null
|
||||
run_with_timeout() {
|
||||
local seconds="$1"
|
||||
shift
|
||||
if command -v timeout &>/dev/null; then
|
||||
timeout "$seconds" "$@"
|
||||
return $?
|
||||
fi
|
||||
|
||||
local marker="$LOG/.timeout-$$-${RANDOM}"
|
||||
: > "$marker"
|
||||
"$@" &
|
||||
local command_pid=$!
|
||||
(
|
||||
sleep "$seconds"
|
||||
if kill -0 "$command_pid" 2>/dev/null; then
|
||||
echo "timeout" > "$marker"
|
||||
kill "$command_pid" 2>/dev/null || true
|
||||
sleep 2
|
||||
kill -KILL "$command_pid" 2>/dev/null || true
|
||||
fi
|
||||
) &
|
||||
local watchdog_pid=$!
|
||||
|
||||
wait "$command_pid"
|
||||
local status=$?
|
||||
kill "$watchdog_pid" 2>/dev/null || true
|
||||
wait "$watchdog_pid" 2>/dev/null || true
|
||||
if [[ -s "$marker" ]]; then
|
||||
status=124
|
||||
fi
|
||||
rm -f "$marker"
|
||||
return "$status"
|
||||
}
|
||||
|
||||
# -- godot --------------------------------------------------------------------
|
||||
@@ -104,16 +155,15 @@ needs_import=false
|
||||
if [[ -f "addons/gut/gut_cmdln.gd" ]] && ! grep -q '"class": &"GutTest"' "$class_cache" 2>/dev/null; then
|
||||
needs_import=true
|
||||
fi
|
||||
[[ -n "$(changed_gd)" ]] && needs_import=true
|
||||
if $needs_import; then
|
||||
if need_timeout; then
|
||||
timeout 60 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --import >> "$LOG/godot-import.log" 2>&1
|
||||
import_exit=$?
|
||||
else
|
||||
"${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --import >> "$LOG/godot-import.log" 2>&1
|
||||
import_exit=$?
|
||||
fi
|
||||
run_with_timeout 60 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --import >> "$LOG/godot-import.log" 2>&1
|
||||
import_exit=$?
|
||||
if [[ $import_exit -ne 0 ]]; then
|
||||
import_result="FAIL"
|
||||
if [[ $import_exit -eq 124 ]]; then
|
||||
echo "[timed out after 60s]" >> "$LOG/godot-import.log"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ ! -f "$class_cache" ]] || ! grep -q '"class": &"SimNPC"' "$class_cache"; then
|
||||
@@ -131,10 +181,10 @@ if [[ "$import_result" == "FAIL" ]]; then
|
||||
fi
|
||||
|
||||
# -- 1. gdformat --------------------------------------------------------------
|
||||
fmt_tool=$(find_gdformat) || true
|
||||
fmt_result="PASS"
|
||||
fmt_failed=false
|
||||
: > "$LOG/gdformat.log"
|
||||
if [[ -z "$fmt_tool" ]]; then
|
||||
if ! has_gdformat; then
|
||||
fmt_result="SKIPPED"
|
||||
echo "gdformat not found — install requirements-dev.txt (see docs/local_quality_gate.md)" > "$LOG/gdformat.log"
|
||||
else
|
||||
@@ -147,32 +197,40 @@ else
|
||||
while IFS= read -r f; do
|
||||
[[ -f "$f" ]] || continue
|
||||
total=$((total+1))
|
||||
if ! $fmt_tool --check "$f" >> "$LOG/gdformat.log" 2>&1; then
|
||||
if ! run_gdformat --check "$f" >> "$LOG/gdformat.log" 2>&1; then
|
||||
bad=$((bad+1))
|
||||
fmt_failed=true
|
||||
fi
|
||||
done <<< "$files"
|
||||
echo "($bad/$total files need formatting)" >> "$LOG/gdformat.log"
|
||||
fi
|
||||
else
|
||||
$fmt_tool --check "${OWNED_GDSCRIPT_ROOTS[@]}" >> "$LOG/gdformat.log" 2>&1 || true
|
||||
if ! run_gdformat --check "${OWNED_GDSCRIPT_ROOTS[@]}" >> "$LOG/gdformat.log" 2>&1; then
|
||||
fmt_failed=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if grep -q "would reformat" "$LOG/gdformat.log" 2>/dev/null; then
|
||||
if $fmt_failed; then
|
||||
fmt_result="FAIL"
|
||||
fi
|
||||
if grep -q "would reformat" "$LOG/gdformat.log" 2>/dev/null; then
|
||||
while IFS= read -r line; do
|
||||
line="${line#would reformat }"
|
||||
rp=$(res_path "$line")
|
||||
ERRORS+=("$rp needs formatting")
|
||||
done < <(grep "would reformat" "$LOG/gdformat.log")
|
||||
FIXES+=("Run gdformat to auto-format files")
|
||||
elif $fmt_failed; then
|
||||
ERRORS+=("gdformat: formatter exited non-zero; see $LOG/gdformat.log")
|
||||
FIXES+=("Fix the gdformat error before continuing")
|
||||
fi
|
||||
|
||||
# -- 2. gdlint ----------------------------------------------------------------
|
||||
lint_tool=$(find_gdlint) || true
|
||||
lint_result="PASS"
|
||||
lint_failed=false
|
||||
: > "$LOG/gdlint.log"
|
||||
if [[ -z "$lint_tool" ]]; then
|
||||
if ! has_gdlint; then
|
||||
lint_result="SKIPPED"
|
||||
echo "gdlint not found — install requirements-dev.txt (see docs/local_quality_gate.md)" > "$LOG/gdlint.log"
|
||||
else
|
||||
@@ -183,16 +241,22 @@ else
|
||||
else
|
||||
while IFS= read -r f; do
|
||||
[[ -f "$f" ]] || continue
|
||||
$lint_tool "$f" >> "$LOG/gdlint.log" 2>&1 || true
|
||||
if ! run_gdlint "$f" >> "$LOG/gdlint.log" 2>&1; then
|
||||
lint_failed=true
|
||||
fi
|
||||
done <<< "$files"
|
||||
fi
|
||||
else
|
||||
$lint_tool "${OWNED_GDSCRIPT_ROOTS[@]}" >> "$LOG/gdlint.log" 2>&1 || true
|
||||
if ! run_gdlint "${OWNED_GDSCRIPT_ROOTS[@]}" >> "$LOG/gdlint.log" 2>&1; then
|
||||
lint_failed=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if grep -qE "^[^ ]+:[0-9]+:" "$LOG/gdlint.log" 2>/dev/null; then
|
||||
if $lint_failed; then
|
||||
lint_result="FAIL"
|
||||
fi
|
||||
if grep -qE "^[^ ]+:[0-9]+:" "$LOG/gdlint.log" 2>/dev/null; then
|
||||
while IFS= read -r line; do
|
||||
[[ "$line" =~ ^([^:]+):([0-9]+):([0-9]+):[^:]+:(.*) ]] || continue
|
||||
file="${BASH_REMATCH[1]}"
|
||||
@@ -209,28 +273,21 @@ if grep -qE "^[^ ]+:[0-9]+:" "$LOG/gdlint.log" 2>/dev/null; then
|
||||
fname=$(basename "${BASH_REMATCH[1]}")
|
||||
FIXES+=("Fix $rule in $fname")
|
||||
done < <(grep -E "^[^ ]+:[0-9]+:" "$LOG/gdlint.log")
|
||||
elif $lint_failed; then
|
||||
ERRORS+=("gdlint: linter exited non-zero; see $LOG/gdlint.log")
|
||||
FIXES+=("Fix the gdlint error before continuing")
|
||||
fi
|
||||
|
||||
# -- 3. godot headless check --------------------------------------------------
|
||||
godot_result="PASS"
|
||||
: > "$LOG/godot-check.log"
|
||||
if need_timeout; then
|
||||
if timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
|
||||
godot_result="PASS"
|
||||
else
|
||||
ec=$?
|
||||
if [[ $ec -eq 124 ]]; then
|
||||
godot_result="FAIL"
|
||||
echo "[timed out after 30s — project runs continuously]" >> "$LOG/godot-check.log"
|
||||
else
|
||||
godot_result="FAIL"
|
||||
fi
|
||||
fi
|
||||
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
|
||||
godot_result="PASS"
|
||||
else
|
||||
if "${GODOT_ENV[@]}" "$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"
|
||||
ec=$?
|
||||
godot_result="FAIL"
|
||||
if [[ $ec -eq 124 ]]; then
|
||||
echo "[timed out after 30s]" >> "$LOG/godot-check.log"
|
||||
fi
|
||||
fi
|
||||
if grep -qE "SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/godot-check.log"; then
|
||||
@@ -248,14 +305,9 @@ scenario_result="PASS"
|
||||
: > "$LOG/scenarios.log"
|
||||
for test in tests/*_test.gd; do
|
||||
echo "[RUN] $(basename "$test")" >> "$LOG/scenarios.log"
|
||||
if need_timeout; then
|
||||
if ! timeout 30 "${GODOT_ENV[@]}" "$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_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
|
||||
if ! run_with_timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
|
||||
scenario_result="FAIL"
|
||||
ERRORS+=("scenario: $(basename "$test") failed")
|
||||
ERRORS+=("scenario: $(basename "$test") failed or timed out")
|
||||
fi
|
||||
done
|
||||
if grep -qE "SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/scenarios.log"; then
|
||||
@@ -278,13 +330,8 @@ else
|
||||
"${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT"
|
||||
-s addons/gut/gut_cmdln.gd -gexit -gdisable_colors
|
||||
)
|
||||
if need_timeout; then
|
||||
timeout 30 "${gut_command[@]}" >> "$LOG/gut.log" 2>&1
|
||||
gut_exit=$?
|
||||
else
|
||||
"${gut_command[@]}" >> "$LOG/gut.log" 2>&1
|
||||
gut_exit=$?
|
||||
fi
|
||||
run_with_timeout 30 "${gut_command[@]}" >> "$LOG/gut.log" 2>&1
|
||||
gut_exit=$?
|
||||
if [[ $gut_exit -eq 0 ]]; then
|
||||
gut_result="PASS"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user