#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" log() { printf '[validate-all] %s\n' "$1" } run_if_present() { local cmd="$1" if command -v ${cmd%% *} >/dev/null 2>&1; then eval "$cmd" return 0 fi return 1 } log "root: $ROOT_DIR" cd "$ROOT_DIR" log "Step 1/7: frontend dependency check" if [[ ! -d "frontend/node_modules" ]]; then log "frontend/node_modules missing; install with: cd frontend && npm install" fi log "Step 2/7: frontend lint" if [[ -f "frontend/package.json" ]]; then ( cd frontend if npm run -s lint; then log "frontend lint: OK" else log "frontend lint failed" exit 1 fi ) else log "frontend/package.json not found; skipping" fi log "Step 3/7: frontend build" if [[ -f "frontend/package.json" ]]; then ( cd frontend if npm run -s build; then log "frontend build: OK" else log "frontend build failed" exit 1 fi ) fi log "Step 4/7: frontend tests" if [[ -f "frontend/package.json" ]]; then ( cd frontend if npm run -s test; then log "frontend tests: OK" else log "frontend tests failed" exit 1 fi ) fi log "Step 5/7: backend syntax check" PY="" for p in \ "$ROOT_DIR/.venv312/bin/python3.12" \ "$ROOT_DIR/.venv312/bin/python" \ "$ROOT_DIR/.venv/bin/python3" \ "$ROOT_DIR/.venv/bin/python" \ "$ROOT_DIR/venv/bin/python3" \ "$ROOT_DIR/venv/bin/python"; do if [[ -x "$p" ]]; then PY="$p" break fi done if [[ -z "$PY" ]]; then if command -v python3 >/dev/null 2>&1; then PY="$(command -v python3)" elif command -v python >/dev/null 2>&1; then PY="$(command -v python)" fi fi if [[ -n "$PY" ]]; then log "using python: $PY" "$PY" -m py_compile "$ROOT_DIR/backend/main.py" "$ROOT_DIR/backend/routers/export.py" log "backend syntax check: OK" else log "no project python found (.venv312/.venv/venv); skipping backend syntax check" fi log "Step 6/7: backend unit tests" if [[ -n "$PY" ]]; then if find "$ROOT_DIR/backend/tests" -type f -name 'test_*.py' -print -quit 2>/dev/null | grep -q .; then PYTHONPATH="$ROOT_DIR/backend:$ROOT_DIR" "$PY" -m unittest discover -s "$ROOT_DIR/backend/tests" -p 'test_*.py' -v log "backend unit tests: OK" else log "backend unit tests: skipped (no tests found)" fi fi log "Step 7/7: backend health import smoke" if [[ -n "$PY" ]]; then if [[ "${SKIP_BACKEND_IMPORT_SMOKE:-0}" == "1" ]]; then log "backend import smoke: skipped (SKIP_BACKEND_IMPORT_SMOKE=1)" else PYTHONPATH="$ROOT_DIR/backend:$ROOT_DIR" "$PY" - <<'PYCODE' import importlib mods = [ "backend.main", "backend.routers.export", "backend.services.video_editor", ] for m in mods: importlib.import_module(m) print("backend import smoke: OK") PYCODE fi fi log "Validation complete"