This commit is contained in:
Anaïs Saraiva
2026-08-25 12:20:31 +02:00
parent ccc29212cd
commit abf8736fdd
59 changed files with 4228 additions and 3008 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Build the whole project: Svelte frontend + Rust backend.
#
# Usage:
# bash scripts/build.sh # release build
# bash scripts/build.sh --debug # debug build (faster)
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
PROFILE="release"
if [[ "${1:-}" == "--debug" ]]; then
PROFILE="debug"
fi
command -v cargo >/dev/null 2>&1 || { echo "cargo (Rust) est requis." >&2; exit 1; }
command -v npm >/dev/null 2>&1 || { echo "npm (Node.js) est requis." >&2; exit 1; }
echo "==> Frontend (Svelte)"
cd "$ROOT/frontend"
if [[ ! -d node_modules ]]; then
echo " installation des dépendances..."
npm install
fi
npm run build
echo "==> Backend (Rust)"
cd "$ROOT/backend"
if [[ "$PROFILE" == "release" ]]; then
cargo build --release
else
cargo build
fi
echo
echo "Build terminé."
if [[ "$PROFILE" == "release" ]]; then
echo " binaire : $ROOT/backend/target/release/filehost"
else
echo " binaire : $ROOT/backend/target/debug/filehost"
fi
echo " frontend : $ROOT/frontend/dist"
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# End-to-end test: starts the Rust server and runs the API smoke test against it.
#
# Usage: bash scripts/e2e-test.sh (requires a built backend: cargo build in backend/)
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
PORT="${PORT:-3100}"
BASE_URL="http://127.0.0.1:${PORT}"
STORAGE="$(mktemp -d)"
SERVER_PID=""
cleanup() {
if [[ -n "${SERVER_PID}" ]]; then
kill "${SERVER_PID}" 2>/dev/null || true
fi
rm -rf "${STORAGE}"
}
trap cleanup EXIT
if [[ ! -x "${ROOT}/backend/target/debug/filehost" ]]; then
echo "backend binary not found; run 'cargo build' in backend/ first" >&2
exit 1
fi
STORAGE_DIR="${STORAGE}" STATIC_DIR="${ROOT}/frontend/dist" PORT="${PORT}" \
"${ROOT}/backend/target/debug/filehost" &
SERVER_PID=$!
# Wait for readiness.
for _ in $(seq 1 50); do
if curl -sS -f "${BASE_URL}/api/health" >/dev/null 2>&1; then
break
fi
sleep 0.1
done
# Static frontend checks.
INDEX_CT="$(curl -sS -o /dev/null -w '%{content_type}' "${BASE_URL}/")"
LOGO_CODE="$(curl -sS -o /dev/null -w '%{http_code}' "${BASE_URL}/logo.svg")"
FAVICON_CODE="$(curl -sS -o /dev/null -w '%{http_code}' "${BASE_URL}/favicon.svg")"
echo "static / -> ${INDEX_CT}"
echo "static /logo.svg -> ${LOGO_CODE}"
echo "static /favicon.svg -> ${FAVICON_CODE}"
if [[ "${INDEX_CT}" != text/html* ]]; then
echo "FAIL: static / did not return HTML (got '${INDEX_CT}')" >&2
exit 1
fi
if [[ "${LOGO_CODE}" != "200" ]]; then
echo "FAIL: static /logo.svg returned ${LOGO_CODE}" >&2
exit 1
fi
if [[ "${FAVICON_CODE}" != "200" ]]; then
echo "FAIL: static /favicon.svg returned ${FAVICON_CODE}" >&2
exit 1
fi
echo "running smoke test against ${BASE_URL}"
BASE_URL="${BASE_URL}" bash "${ROOT}/scripts/smoke-test.sh"
+4
View File
@@ -8,6 +8,10 @@
# Requires a running instance and `bun` on PATH.
set -euo pipefail
# bun colorizes booleans/numbers on stdout even when piped, which breaks the
# plain-text comparisons below (e.g. `protected` == "false").
export NO_COLOR=1
BASE="${BASE_URL:-http://127.0.0.1:3000}"
PW="hunter2"
TMP="$(mktemp -d)"