fluffychat/scripts/integration-test-swayvnc-he...

72 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
if [ -z "$HOMESERVER" ]; then
echo "Please ensure HOMESERVER environment variable is set to the IP or hostname of the homeserver."
exit 1
fi
if [ -z "$USER1_NAME" ]; then
echo "Please ensure USER1_NAME environment variable is set to first user name."
exit 1
fi
if [ -z "$USER1_PW" ]; then
echo "Please ensure USER1_PW environment variable is set to first user password."
exit 1
fi
if [ -z "$USER2_NAME" ]; then
echo "Please ensure USER2_NAME environment variable is set to second user name."
exit 1
fi
if [ -z "$USER2_PW" ]; then
echo "Please ensure USER2_PW environment variable is set to second user password."
exit 1
fi
if ( docker images swayvnc-flutter:latest | grep swayvnc-flutter ) ; then
echo "Found swayvnc-flutter:latest, skipping image build..."
else
if [ -n "$FLUTTER_VERSION" ]; then
FLUTTER_VERSION="$(flutter --no-version-check --version | grep channel | awk '{ print $2 }')"
fi
docker build integration_test/desktop -t swayvnc-flutter:latest --build-arg flutter_version="$FLUTTER_VERSION"
fi
docker rm -f swayvnc-flutter || true
echo "Starting swayvnc-flutter container..."
docker run -i --rm --name swayvnc-flutter -e XDG_RUNTIME_DIR=/tmp -v "$(pwd)":/project \
-e WLR_BACKENDS=headless \
-e WLR_LIBINPUT_NO_DEVICES=1 \
-e SWAYSOCK=/tmp/sway-ipc.sock \
-p :5910:5910 \
-p :7023:7023 \
swayvnc-flutter:latest &
killall soccat || true
if [ -f /tmp/swayip ]; then
rm /tmp/swayip
fi
echo "Opening Sway socket communication..."
sleep 10
socat UNIX-LISTEN:/tmp/swayipc,fork TCP:127.0.0.1:7023 &
echo "Starting integration test..."
SWAYSOCK=/tmp/swayipc swaymsg exec "foot sh -c \"cd /project && flutter --no-version-check pub get && flutter --no-version-check test integration_test -d linux --dart-define=HOMESERVER=$HOMESERVER --dart-define=USER1_NAME=$USER1_NAME --dart-define=USER2_NAME=$USER2_NAME --dart-define=USER1_PW=$USER1_PW --dart-define=USER2_PW=$USER2_PW || ( sleep 10 && exit 1 )\""
while [ -z "$(SWAYSOCK=/tmp/swayipc swaymsg exec \"pgrep foot\")" ]; do
sleep 10
done
if [ ! -d output ]; then
mkdir output
fi
docker run -t -e VR_VNC_HOST="$LISTEN_ADDRESS" -e VR_VNC_PORT=5910 -e VR_OUTFILE=/output/linux-integration-test.mp4 \
-v "$(pwd)/output":/output widerin/vnc-recorder &
docker stop swayvnc-flutter