From 51e7a7ccc556f36a252d3048c526a23c6ad05eb8 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sat, 14 Feb 2026 11:44:49 +0000 Subject: [PATCH] Add setup-test-venv.sh for running tests without Docker [ci skip] --- CLAUDE.md | 2 +- scripts/setup-test-venv.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 scripts/setup-test-venv.sh diff --git a/CLAUDE.md b/CLAUDE.md index 2a2d908..e6847c6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -236,6 +236,6 @@ The project uses strict mypy configuration with `disallow_untyped_defs=true`. Ru - Do not include unrelated files - Use descriptive commit messages - Group related files together (e.g., tests with the code they test) -- **Always run tests before committing**: `docker compose exec -T app pytest tests/ -v --tb=short`. If Docker is not available, use the local venv fallback: `/tmp/rec-test-venv/bin/pytest tests/ -v --tb=short` (set up with `python3 -m venv /tmp/rec-test-venv && /tmp/rec-test-venv/bin/pip install pytest pytest-asyncio pytest-cov httpx fakeredis aioresponses fastapi uvicorn sqlmodel sqlalchemy alembic pyjwt cryptography celery redis click aiohttp aiohttp-socks pillow numpy pytesseract opentelemetry-api opentelemetry-sdk opentelemetry-exporter-prometheus opentelemetry-instrumentation-fastapi opentelemetry-instrumentation-sqlalchemy python-dotenv webauthn apprise tenacity prometheus-client email-validator opencv-python-headless tqdm pandas cachetools watchdog`). If neither works, warn the user. +- **Always run tests before committing**: `docker compose exec -T app pytest tests/ -v --tb=short`. If Docker is not available, use the local venv fallback: `./scripts/setup-test-venv.sh && /tmp/rec-test-venv/bin/pytest tests/ -v --tb=short`. If neither works, warn the user. - **After each meaningful change, ask the user if they want to commit and push the changes** diff --git a/scripts/setup-test-venv.sh b/scripts/setup-test-venv.sh new file mode 100755 index 0000000..2918f0e --- /dev/null +++ b/scripts/setup-test-venv.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -eu + +# Creates a lightweight Python venv for running tests locally (without Docker). +# Skips mysqlclient (needs system MySQL libs) — tests use SQLite in-memory. +# +# Usage: ./scripts/setup-test-venv.sh +# /tmp/rec-test-venv/bin/pytest tests/ -v --tb=short + +VENV_DIR="/tmp/rec-test-venv" + +if [ -x "$VENV_DIR/bin/pytest" ]; then + echo "Test venv already exists at $VENV_DIR" + echo "Run tests with: $VENV_DIR/bin/pytest tests/ -v --tb=short" + exit 0 +fi + +echo "Creating test venv at $VENV_DIR..." +python3 -m venv "$VENV_DIR" + +echo "Installing dependencies..." +"$VENV_DIR/bin/pip" install --quiet --upgrade pip + +"$VENV_DIR/bin/pip" install --quiet \ + pytest pytest-asyncio pytest-cov httpx fakeredis aioresponses \ + fastapi uvicorn sqlmodel sqlalchemy alembic pyjwt cryptography \ + celery redis click aiohttp aiohttp-socks pillow numpy pytesseract \ + opentelemetry-api opentelemetry-sdk opentelemetry-exporter-prometheus \ + opentelemetry-instrumentation-fastapi opentelemetry-instrumentation-sqlalchemy \ + python-dotenv webauthn apprise tenacity prometheus-client \ + email-validator opencv-python-headless tqdm pandas cachetools watchdog + +echo "" +echo "Done. Run tests with:" +echo " $VENV_DIR/bin/pytest tests/ -v --tb=short"