From 18db16471bddfb4a61ca66fb09ed8f1a7fae7f21 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 3 May 2026 22:13:00 -0700 Subject: [PATCH] ci: keep Windows Blacksmith testbox ready --- .../workflows/windows-blacksmith-testbox.yml | 75 ++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-blacksmith-testbox.yml b/.github/workflows/windows-blacksmith-testbox.yml index ff5ae1bb654..75a6bf9c0d4 100644 --- a/.github/workflows/windows-blacksmith-testbox.yml +++ b/.github/workflows/windows-blacksmith-testbox.yml @@ -123,5 +123,78 @@ jobs: git --version - name: Run Testbox + shell: bash + run: | + set -euo pipefail + + state=/tmp/.testbox + test -d "$state" + + testbox_id="$(cat "$state/testbox_id")" + installation_model_id="$(cat "$state/installation_model_id")" + auth_token="$(cat "$state/auth_token")" + idle_timeout="$(cat "$state/idle_timeout" 2>/dev/null || true)" + idle_timeout="${idle_timeout:-10}" + api_url="$(cat "$state/api_url")" + runner_host="$(cat "$state/runner_host")" + runner_ssh_port="$(cat "$state/runner_ssh_port")" + working_directory="$(cat "$state/working_directory")" + adopted_run_id="$(cat "$state/adopted_run_id")" + + ready_body="$RUNNER_TEMP/testbox-ready.json" + cat > "$ready_body" </dev/null | grep -q ":${runner_ssh_port}"; then + last_activity="$now" + elif [ -f ~/.testbox-last-activity ]; then + file_mtime="$(stat -c %Y ~/.testbox-last-activity 2>/dev/null || stat -f %m ~/.testbox-last-activity)" + if [ "$file_mtime" -gt "$last_activity" ]; then + last_activity="$file_mtime" + fi + fi + + idle_seconds=$(( now - last_activity )) + if [ "$idle_seconds" -ge "$idle_timeout_seconds" ]; then + echo "Idle timeout reached (${idle_timeout} minutes). Shutting down." + exit 0 + fi + done + + - name: Testbox action marker + if: ${{ false }} uses: useblacksmith/run-testbox@5ca05834db1d3813554d1dd109e5f2087a8d7cbc - if: always()