From de47711cd583b68d4417350addcc24644aba184a Mon Sep 17 00:00:00 2001 From: autocommit Date: Tue, 26 May 2026 13:02:45 -0700 Subject: [PATCH] =?UTF-8?q?chore(autoplay-specific):=20=F0=9F=94=A7=20Upda?= =?UTF-8?q?te=20autoplay=20batch=20script=20to=20support=20Docker-based=20?= =?UTF-8?q?builds=20or=20AI=20simulator=20workflows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- tools/autoplay-batch.sh | 52 +++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/tools/autoplay-batch.sh b/tools/autoplay-batch.sh index afe21e95..74d2dc26 100755 --- a/tools/autoplay-batch.sh +++ b/tools/autoplay-batch.sh @@ -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