chore(autoplay-specific): 🔧 Update autoplay batch script to support Docker-based builds or AI simulator workflows

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-05-26 13:02:45 -07:00
parent a92e25e064
commit de47711cd5

View file

@ -176,8 +176,13 @@ _run_local() {
local seed="$1"
local game_dir="$2"
if ! command -v flatpak >/dev/null 2>&1; then
echo "ERROR: flatpak not installed. Set AUTOPLAY_HOST to run on a remote Linux host." >&2
if [ -z "${AUTOPLAY_GODOT_BIN:-}" ]; then
if ! command -v flatpak >/dev/null 2>&1; then
echo "ERROR: flatpak not installed. Set AUTOPLAY_HOST to run on a remote Linux host, or AUTOPLAY_GODOT_BIN=godot when running inside the mc-ai container." >&2
exit 1
fi
elif ! command -v "$AUTOPLAY_GODOT_BIN" >/dev/null 2>&1; then
echo "ERROR: AUTOPLAY_GODOT_BIN=$AUTOPLAY_GODOT_BIN not found on PATH." >&2
exit 1
fi
@ -291,16 +296,39 @@ _run_local() {
_slice_prefix=(nice -n 10 ionice -c 3)
fi
echo "[seed $seed] Launching Godot ($RENDER_MODE, timeout ${SAFETY_TIMEOUT}s, heavy-tests.slice)..."
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" \
"${_slice_prefix[@]}" \
timeout "$SAFETY_TIMEOUT" flatpak run --user \
--filesystem=home \
"${FLATPAK_ENVS[@]}" \
org.godotengine.Godot "${GODOT_ARGS[@]}" \
>"$game_dir/game.log" 2>&1 || {
local exit_code=$?
echo "[seed $seed] Godot exited with code $exit_code" >&2
}
if [ -n "${AUTOPLAY_GODOT_BIN:-}" ]; then
# Container path (Dockerfile.mc-ai): /usr/local/bin/godot is the
# baked binary. No flatpak runtime to thread env vars through, so
# translate FLATPAK_ENVS' `--env=KEY=VAL` tokens to a real env list
# and exec the binary directly. systemd-run is absent in the
# container, so _slice_prefix already collapsed to (nice ionice).
local godot_env_args=()
for e in "${FLATPAK_ENVS[@]}"; do
case "$e" in
--env=*) godot_env_args+=( "${e#--env=}" ) ;;
*) : ;; # --socket / --filesystem / --unset-env are flatpak-only
esac
done
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/tmp}" \
"${_slice_prefix[@]}" \
timeout "$SAFETY_TIMEOUT" env "${godot_env_args[@]}" \
"$AUTOPLAY_GODOT_BIN" "${GODOT_ARGS[@]}" \
>"$game_dir/game.log" 2>&1 || {
local exit_code=$?
echo "[seed $seed] Godot exited with code $exit_code" >&2
}
else
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" \
"${_slice_prefix[@]}" \
timeout "$SAFETY_TIMEOUT" flatpak run --user \
--filesystem=home \
"${FLATPAK_ENVS[@]}" \
org.godotengine.Godot "${GODOT_ARGS[@]}" \
>"$game_dir/game.log" 2>&1 || {
local exit_code=$?
echo "[seed $seed] Godot exited with code $exit_code" >&2
}
fi
if [ -n "$WESTON_PID" ]; then
kill "$WESTON_PID" 2>/dev/null || true