From bf9295a5d949ff6fb31bf7e2955de0a41ce288af Mon Sep 17 00:00:00 2001 From: Natalie Date: Thu, 14 May 2026 19:44:00 -0700 Subject: [PATCH] =?UTF-8?q?feat(@projects/@magic-civilization):=20?= =?UTF-8?q?=E2=9C=A8=20add=20weston-based=20civics=20proof=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- scripts/p1-56-civics-proof.sh | 83 +++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 scripts/p1-56-civics-proof.sh diff --git a/scripts/p1-56-civics-proof.sh b/scripts/p1-56-civics-proof.sh new file mode 100755 index 00000000..815b9ccb --- /dev/null +++ b/scripts/p1-56-civics-proof.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# p1-56 Civics Interactive proof renderer. +# +# Runs ON apricot. Drives flatpak Godot under a weston-headless Wayland host +# pointed at `res://engine/scenes/tests/proof_civics_interactive.tscn`. The +# scene renders the 4-panel godot-ui surface (drag-to-employ, harvest dropdown, +# GP spawn modal, throne-room layer slots) and self-captures to +# `user://screenshots/proof_civics_interactive_.png`. +# +# Env: +# SCRATCH_DIR worktree path containing src/game (required) +# LOG_FILE log destination (default /tmp/p1-56-civics-proof.log) +# TIMEOUT_SEC Godot timeout in seconds (default 90) + +set -uo pipefail + +SCRATCH_DIR="${SCRATCH_DIR:?SCRATCH_DIR is required}" +LOG_FILE="${LOG_FILE:-/tmp/p1-56-civics-proof.log}" +TIMEOUT_SEC="${TIMEOUT_SEC:-90}" + +GODOT_USERDATA="$HOME/.var/app/org.godotengine.Godot/data/godot/app_userdata/Magic Civilization" +SHOT_DIR="$GODOT_USERDATA/screenshots" + +echo "=== p1-56 Civics Interactive proof ===" +echo "SCRATCH_DIR: $SCRATCH_DIR" +echo "LOG: $LOG_FILE" +echo "Sandbox screenshot dir: $SHOT_DIR" + +mkdir -p "$SHOT_DIR" +rm -f "$SHOT_DIR"/proof_civics_interactive_*.png 2>/dev/null || true + +if ! command -v weston >/dev/null 2>&1; then + echo "ERROR: weston not installed" >&2 + exit 2 +fi + +WESTON_SOCKET="p1-56-civics-$$" +WESTON_LOG="/tmp/p1-56-civics-weston.log" +echo "Starting weston (headless, socket=$WESTON_SOCKET)..." +weston --backend=headless --no-config --socket="$WESTON_SOCKET" \ + --width=1280 --height=800 \ + >"$WESTON_LOG" 2>&1 & +WESTON_PID=$! +sleep 1.5 +if ! kill -0 "$WESTON_PID" 2>/dev/null; then + echo "ERROR: weston failed to launch — see $WESTON_LOG" >&2 + tail -20 "$WESTON_LOG" >&2 + exit 3 +fi +trap 'kill $WESTON_PID 2>/dev/null; wait $WESTON_PID 2>/dev/null' EXIT + +XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" \ +timeout "$TIMEOUT_SEC" flatpak run --user \ + --filesystem=home \ + --socket=wayland \ + --unset-env=DISPLAY \ + --env=WAYLAND_DISPLAY="$WESTON_SOCKET" \ + --filesystem=xdg-run/${WESTON_SOCKET} \ + org.godotengine.Godot \ + --path "$SCRATCH_DIR/src/game" \ + --display-driver wayland \ + --rendering-driver opengl3 \ + --rendering-method gl_compatibility \ + res://engine/scenes/tests/proof_civics_interactive.tscn \ + >"$LOG_FILE" 2>&1 +RC=$? + +echo "--- Godot exit rc=$RC ---" +echo "--- Tail of log ---" +tail -40 "$LOG_FILE" +echo "-------------------" + +SHOTS=( "$SHOT_DIR"/proof_civics_interactive_*.png ) +if [ ! -f "${SHOTS[0]}" ]; then + echo "ERROR: no proof_civics_interactive_*.png produced under $SHOT_DIR" >&2 + exit 1 +fi + +echo "Captured ${#SHOTS[@]} shot(s):" +ls -la "$SHOT_DIR"/proof_civics_interactive_*.png + +echo "=== Done ===" +exit 0