Files
TalkEdit/scripts/validate-all.sh

129 lines
2.8 KiB
Bash
Raw Normal View History

2026-04-15 16:36:21 -06:00
#!/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"
2026-04-15 17:13:56 -06:00
log "Step 1/7: frontend dependency check"
2026-04-15 16:36:21 -06:00
if [[ ! -d "frontend/node_modules" ]]; then
log "frontend/node_modules missing; install with: cd frontend && npm install"
fi
2026-04-15 17:13:56 -06:00
log "Step 2/7: frontend lint"
2026-04-15 16:36:21 -06:00
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
2026-04-15 17:13:56 -06:00
log "Step 3/7: frontend build"
2026-04-15 16:36:21 -06:00
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
2026-04-15 17:13:56 -06:00
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"
2026-04-15 16:36:21 -06:00
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
2026-04-15 17:13:56 -06:00
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
2026-04-15 16:36:21 -06:00
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
2026-04-15 17:13:56 -06:00
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"
2026-04-15 16:36:21 -06:00
if [[ -n "$PY" ]]; then
2026-04-15 17:13:56 -06:00
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'
2026-04-15 16:36:21 -06:00
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
2026-04-15 17:13:56 -06:00
fi
2026-04-15 16:36:21 -06:00
fi
log "Validation complete"