weavesignal/tests/chat/run-stack.sh
The WeaveSignal contributors 0a3596480b WeaveSignal 1.0.1
What was built after 1.0.0; CHANGELOG.md has the detail, and deploy/cloudron/CHANGELOG.md the
package's.

- Fixed: the desktop studio app on Linux could not send anything with a body (its content
  security policy blocked Tauri's IPC), so invitations failed. Update the app.
- Browser cameras reach the desk: a Chromium browser's AV1 camera is unpacked, sent at one
  picture size, survives packet loss, and has a jitter buffer of its own (300 ms).
- The one-key DJ handover, a show's presenter and takedown contact, Icecast out and RTMP out
  (Rumble, Odysee, PeerTube, any RTMP server), video in the Cloudron package.
- Two MP3 streams for the listener to choose from, the Opus rate as a setting, chat hours.
- Avatars, pictures and documents in the chat, each approved by staff first.
- Install wizards on the website and a setup page on the station with its own look.
- A Night theme in the studio app.
- Fixes from the public tracker: issues 2-7, 10, 13 and 14.
2026-11-12 10:20:19 +00:00

112 lines
5.2 KiB
Shell
Executable file

#!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-only
# SPDX-FileCopyrightText: 2026 The WeaveSignal contributors
#
# The chat's browser stack (M6) on loopback, ports 37xxx: a throwaway PostgreSQL 18, the
# control plane (no desk: the chat follows its studio view for the modes), the chat with its
# email codes written to tests/chat/run/outbox, the player page and the studio app on Vite.
# Then it runs tests/chat/chat.mjs (PLAYWRIGHT_CORE must name a playwright-core with Chromium),
# or, with WAIT=1, waits for Ctrl+C. Screenshots go to OUT (default tests/chat/run/shots).
# TEST=avatars runs tests/chat/avatars.mjs instead (ADR-0235): choosing an avatar, the crop step,
# the screener's queue with approve, refuse and remove, at 1,440 and 2,560 wide in both themes.
# TEST=followups runs tests/chat/followups.mjs (ADR-0257, 0259, 0260): the uploads switch on an open
# page, Report this picture through to Remove, and H then C through to Delete now.
# TEST=attachments runs tests/chat/attachments.mjs (ADR-0262): the studio's switch, a trusted
# chatter attaching a screenshot and a PDF, the waiting state, approving in the screener, the
# thumbnail and the full picture, the download's headers, and Report this through to Remove.
set -euo pipefail
root=$(cd "$(dirname "$0")/../.." && pwd)
run="$root/tests/chat/run"
prefix=${WEAVESIGNAL_TEST_PREFIX:-weavesignal-chat}
PG_PORT=${WEAVESIGNAL_TEST_PG_PORT:-37432}
CONTROL_PORT=${CONTROL_PORT:-37310}
CHAT_PORT=${CHAT_PORT:-37311}
STUDIO_PORT=${STUDIO_PORT:-37420}
WEB_PORT=${WEB_PORT:-37430}
ADMIN_TOKEN=chat-browser-admin-only
STATION=6a1f3c2e-8f43-4c9b-9a51-1d2f0b7e4c11
taken() { ss -H -ln "$1" "sport = :$2" | grep -q .; }
for p in "$PG_PORT" "$CONTROL_PORT" "$CHAT_PORT" "$STUDIO_PORT" "$WEB_PORT"; do
taken -t "$p" && { echo "port $p/tcp is in use; set another" >&2; exit 1; }
done
rm -rf "$run/outbox" "$run/avatars" "$run/attachments"
mkdir -p "$run/outbox"
cargo build -p weavesignal-control -p weavesignal-chat --manifest-path "$root/Cargo.toml" >/dev/null
pids=()
cleanup() {
for pid in "${pids[@]}"; do kill "$pid" 2>/dev/null || true; done
for pid in "${pids[@]}"; do wait "$pid" 2>/dev/null || true; done
podman rm -f "$prefix-browser-pg" >/dev/null 2>&1 || true
}
trap cleanup EXIT
trap 'exit 130' INT TERM
podman rm -f "$prefix-browser-pg" >/dev/null 2>&1 || true
podman run -d --rm --name "$prefix-browser-pg" -p "127.0.0.1:$PG_PORT:5432" -e POSTGRES_PASSWORD=test-only -e POSTGRES_DB=weavesignal docker.io/library/postgres:18 >/dev/null
for _ in $(seq 1 60); do podman exec "$prefix-browser-pg" pg_isready -h 127.0.0.1 -U postgres -d weavesignal >/dev/null 2>&1 && break; sleep 0.5; done
DB="postgres://postgres:test-only@127.0.0.1:$PG_PORT/weavesignal"
cat > "$run/control.toml" <<TOML
[station]
id = "$STATION"
name = "Kettle FM"
[ports]
control = $CONTROL_PORT
chat = $CHAT_PORT
[studio]
show = "The Kettle Phone-In"
[log]
format = "pretty"
filter = "warn"
TOML
cat > "$run/chat.toml" <<TOML
[station]
id = "$STATION"
name = "Kettle FM"
[listen]
port = $CHAT_PORT
[control]
url = "http://127.0.0.1:$CONTROL_PORT"
[mail]
mode = "outbox"
from = "chat@kettle.example"
outbox_dir = "$run/outbox"
[avatars]
dir = "$run/avatars"
[attachments]
dir = "$run/attachments"
[defaults]
terms = "Be kind to the callers and to each other. No abuse, no spam, nothing unlawful. The moderators' word is final for tonight; ask for a review afterwards."
accountable_person = "Elspeth Gordon, station manager"
contact = "chat@kettle.example"
[log]
format = "pretty"
filter = "info"
TOML
WEAVESIGNAL_CONTROL_ADMIN_TOKEN=$ADMIN_TOKEN "$root/target/debug/weavesignal-control" --config "$run/control.toml" > "$run/control.log" 2>&1 &
pids+=($!)
WEAVESIGNAL_DATABASE_URL=$DB WEAVESIGNAL_CONTROL_ADMIN_TOKEN=$ADMIN_TOKEN WEAVESIGNAL_CHAT_EMAIL_KEY=chat-browser-email-key-0123456789abcdef "$root/target/debug/weavesignal-chat" --config "$run/chat.toml" > "$run/chat.log" 2>&1 &
pids+=($!)
for _ in $(seq 1 100); do curl -sf "http://127.0.0.1:$CHAT_PORT/health" >/dev/null && break; sleep 0.1; done
(cd "$root/apps/studio" && WEAVESIGNAL_CONTROL_URL="http://127.0.0.1:$CONTROL_PORT" WEAVESIGNAL_CHAT_URL="http://127.0.0.1:$CHAT_PORT" \
WEAVESIGNAL_CONTROL_TOKEN=$ADMIN_TOKEN WEAVESIGNAL_STUDIO_PORT=$STUDIO_PORT exec pnpm exec vite --logLevel warn) > "$run/studio-vite.log" 2>&1 &
pids+=($!)
(cd "$root/apps/web" && WEAVESIGNAL_CONTROL_URL="http://127.0.0.1:$CONTROL_PORT" WEAVESIGNAL_CHAT_URL="http://127.0.0.1:$CHAT_PORT" \
WEAVESIGNAL_WEB_PORT=$WEB_PORT exec pnpm exec vite --logLevel warn) > "$run/web-vite.log" 2>&1 &
pids+=($!)
for _ in $(seq 1 100); do curl -sf "http://127.0.0.1:$WEB_PORT/" >/dev/null && curl -sf "http://127.0.0.1:$STUDIO_PORT/" >/dev/null && break; sleep 0.2; done
echo "player http://127.0.0.1:$WEB_PORT/ studio http://127.0.0.1:$STUDIO_PORT/ chat :$CHAT_PORT control :$CONTROL_PORT"
if [[ -n "${WAIT:-}" ]]; then
wait
else
WEB="http://127.0.0.1:$WEB_PORT" STUDIO="http://127.0.0.1:$STUDIO_PORT/" CONTROL="http://127.0.0.1:$CONTROL_PORT" \
CHAT="http://127.0.0.1:$CHAT_PORT" ADMIN_TOKEN=$ADMIN_TOKEN OUTBOX="$run/outbox" PG="$prefix-browser-pg" \
AVATARS="$run/avatars" ATTACHMENTS="$run/attachments" OUT="${OUT:-$run/shots}" node "$root/tests/chat/${TEST:-chat}.mjs"
fi