Build self-hosted HTTP Toolkit / build (linux-x64, ubuntu-latest, true) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / build (macos-arm64, macos-latest, true) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / build (windows-x64, windows-latest, false) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / release (push) Canceled after 0s
51 lines
1.7 KiB
Bash
Executable File
51 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Smoke test: launch the built binary and verify it actually serves the UI and
|
|
# starts the backend. Fails loudly (non-zero) if a native module won't load or
|
|
# the server never comes up - this is the main guard for the single-file build.
|
|
#
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
BIN="${1:-dist/httptoolkit}"
|
|
PORT="${PORT:-8099}"
|
|
SERVER_PORT="${SERVER_PORT:-45457}"
|
|
|
|
echo "==> --help must exit 0"
|
|
"$BIN" --help
|
|
|
|
echo "==> launching $BIN on port $PORT"
|
|
"$BIN" --port "$PORT" --server-port "$SERVER_PORT" --no-open &
|
|
PID=$!
|
|
trap 'kill "$PID" 2>/dev/null || true' EXIT
|
|
|
|
# Wait up to ~30s for the UI port to answer:
|
|
ok=0
|
|
for _ in $(seq 1 60); do
|
|
if curl -fsS "http://127.0.0.1:${PORT}/" -o /tmp/htk-index.html 2>/dev/null; then
|
|
ok=1; break
|
|
fi
|
|
if ! kill -0 "$PID" 2>/dev/null; then
|
|
echo "!! binary exited early"; exit 1
|
|
fi
|
|
sleep 0.5
|
|
done
|
|
[ "$ok" = 1 ] || { echo "!! UI never responded on :$PORT"; exit 1; }
|
|
|
|
echo "==> UI responded; checking it looks like the HTK app"
|
|
grep -qi 'httptoolkit\|<div id="app"\|<title' /tmp/htk-index.html \
|
|
|| { echo "!! served index.html doesn't look like the UI"; exit 1; }
|
|
|
|
echo "==> checking management API is listening on :$SERVER_PORT"
|
|
# corsGate rejects requests without an allowed Origin with a JSON 403 - that's a
|
|
# *successful* connection (the server is up), which is all we need to confirm.
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' \
|
|
-H 'Origin: http://localhost:'"$PORT" \
|
|
"http://127.0.0.1:${SERVER_PORT}/" || true)
|
|
echo " management API HTTP status: $code"
|
|
[ -n "$code" ] && [ "$code" != "000" ] \
|
|
|| { echo "!! management API not reachable"; exit 1; }
|
|
|
|
echo "==> SMOKE TEST PASSED"
|