diff --git a/.github/scripts/http-e2e.sh b/.github/scripts/http-e2e.sh index ef9c500bd1d..feb8925d30d 100755 --- a/.github/scripts/http-e2e.sh +++ b/.github/scripts/http-e2e.sh @@ -26,6 +26,10 @@ server_pid='' app_tag='' server_log='' status_log='' +realtime_pid='' +realtime_tag='' +realtime_log='' +browsers_pid='' finish() { local status=$? @@ -39,6 +43,17 @@ finish() { tail -n 200 "$server_log" fi fi + if [ -n "$realtime_pid" ]; then + bash "$GITHUB_WORKSPACE/.github/scripts/stop-session.sh" "$realtime_pid" "$realtime_tag" || status=1 + wait "$realtime_pid" 2>/dev/null || true + if [ "$status" -ne 0 ]; then + tail -n 100 "$realtime_log" + fi + fi + if [ -n "$browsers_pid" ]; then + kill -- "-$browsers_pid" 2>/dev/null || true + wait "$browsers_pid" 2>/dev/null || true + fi exit "$status" } trap finish EXIT @@ -58,20 +73,39 @@ start_app() { E2E_APP="$app_tag" setsid node ../../node_modules/next/dist/bin/next dev --hostname 127.0.0.1 \ --port "$port" > "$server_log" 2>&1 & server_pid=$! + wait_ready "$server_pid" "$NEXT_PUBLIC_APP_URL/api/health" "$label app" +} +# start_realtime : the Socket.IO server the app's browser clients connect to, so pages +# render connected rather than under a "Reconnecting..." notification. Start after start_app, which +# exports the app URL the server allows as an origin; NEXT_PUBLIC_SOCKET_URL must already be set +# when the app starts. +start_realtime() { + local name=$1 port=$2 + realtime_tag="$name-realtime-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT-$$" + realtime_log="$report_dir/$name-realtime.log" + (cd ../realtime && PORT="$port" E2E_APP="$realtime_tag" exec setsid bun run start \ + > "$realtime_log" 2>&1) & + realtime_pid=$! + wait_ready "$realtime_pid" "http://127.0.0.1:$port/health" "$name realtime server" +} + +# wait_ready