#!/bin/bash # Build what Create's end-to-end test needs, and run it. # # wai/wai-app/e2e/run.sh [--only create,built,refused,own,agent] # # 1. wai-relay and wai-room (crates joule-moq-relay and joule-moq-room; native, release), and `wai` with its features # `quickstart` (the receipts its writes leave, and `wai verify`) and `app` (wai/wai-rs, in a target directory of its # own: two workspaces build wai-rs differently); # 2. the WebAssembly packages, through wasm-bindgen's web target, each with its own --out-name, # into the runtime directory: joule-moq-web (room/moq/pkg/wai_room_moq), wai-live-web # (room/live/pkg/wai_room_live) and wai-app with its feature `web` (create/pkg/wai_app); # 3. the runtime laid out as the site serves it (web/runtime.mjs): create/ and room/; and the # room client `wai dev` serves at /room/ (wai/quickstart/build-web.sh); # 4. the page modules' unit tests (node --test web/web.test.mjs); # 5. the browser-automation package from e2e/package-lock.json (`npm ci --ignore-scripts`), # outside the tree unless PLAYWRIGHT_HOST names one installed; # 6. e2e/create.e2e.mjs in the browser BROWSER_BIN names (the host's installed one), else the # package's own. # # Environment: CARGO_TARGET_DIR (one target directory for every workspace), BROWSER_BIN, # PLAYWRIGHT_HOST, CREATE_E2E_OUT (where the runtime and the results go), CARGO_LOCKED # (default --locked). Nothing listens beyond loopback. set -euo pipefail HERE=$(cd "$(dirname "$0")" && pwd) UI=$(cd "$HERE/.." && pwd) ROOT=$(cd "$UI/../.." && pwd) JC="$ROOT/joule-code/joule-code-rs" WLW="$ROOT/wai/wai-live-web" LOCKED=${CARGO_LOCKED---locked} TARGET=${CARGO_TARGET_DIR:-$UI/target} export CARGO_TARGET_DIR="$TARGET" OUT=${CREATE_E2E_OUT:-${TMPDIR:-/tmp}/wai-create-e2e} RT="$OUT/runtime" rm -rf "$OUT/results" "$RT" "$OUT/web" mkdir -p "$OUT/results" "$RT" step() { echo "== $*"; } step "native: wai-relay, wai-room, wai (feature app)" (cd "$JC" && cargo build $LOCKED --release -p joule-moq-relay --bin wai-relay) (cd "$JC/crates/joule-moq-room" && cargo build $LOCKED --release --bin wai-room) WAI_TARGET="$TARGET/wai-app-cli" (cd "$ROOT/wai/wai-rs" && CARGO_TARGET_DIR="$WAI_TARGET" cargo build $LOCKED --release --no-default-features --features quickstart,app --bin wai) step "wasm: joule-moq-web, wai-live-web, wai-app" command -v wasm-bindgen >/dev/null || { echo "the wasm-bindgen CLI 0.2.127 is needed"; exit 2; } wasm-bindgen --version | grep -q ' 0\.2\.127$' || { echo "the wasm-bindgen CLI must be 0.2.127, the version the crates pin"; exit 2; } (cd "$JC" && cargo build $LOCKED --release -p joule-moq-web --lib --target wasm32-unknown-unknown) wasm-bindgen --target web --no-typescript --out-dir "$RT/room/moq/pkg" --out-name wai_app_room_moq "$TARGET/wasm32-unknown-unknown/release/joule_moq_web.wasm" (cd "$WLW" && cargo build $LOCKED --release --lib --target wasm32-unknown-unknown) wasm-bindgen --target web --no-typescript --out-dir "$RT/room/live/pkg" --out-name wai_app_room_live "$TARGET/wasm32-unknown-unknown/release/wai_live_web.wasm" (cd "$UI" && cargo build $LOCKED --release --lib --target wasm32-unknown-unknown --no-default-features --features web) wasm-bindgen --target web --no-typescript --out-dir "$RT/create/pkg" --out-name wai_app "$TARGET/wasm32-unknown-unknown/release/wai_app.wasm" ls -l "$RT"/create/pkg/*.wasm "$RT"/room/*/pkg/*.wasm step "the runtime, as the site serves it" node "$UI/web/runtime.mjs" "$RT" step "the room client wai dev serves" bash "$ROOT/wai/quickstart/build-web.sh" "$OUT/web" step "unit tests of the page's modules" node --test "$UI/web/web.test.mjs" step "browser automation" if [ -z "${PLAYWRIGHT_HOST:-}" ]; then PW="$OUT/pw" mkdir -p "$PW" cp "$HERE/package.json" "$HERE/package-lock.json" "$PW/" (cd "$PW" && npm ci --ignore-scripts --no-audit --no-fund) export PLAYWRIGHT_HOST="$PW/node_modules" fi browser=() [ -n "${BROWSER_BIN:-}" ] && browser=(--browser "$BROWSER_BIN") step "end-to-end" node "$HERE/create.e2e.mjs" \ --rt "$RT" \ --relay "$TARGET/release/wai-relay" \ --room "$TARGET/release/wai-room" \ --wai "$WAI_TARGET/release/wai" \ --web "$OUT/web" \ --out "$OUT/results" \ ${browser[@]+"${browser[@]}"} \ "$@"