Files
rehearshalhub/Taskfile.yml

209 lines
6.6 KiB
YAML

version: "3"
vars:
COMPOSE: docker compose
DEV_FLAGS: -f docker-compose.yml -f docker-compose.dev.yml
DEV_SERVICES: db redis api audio-worker nc-watcher
# ── Production ────────────────────────────────────────────────────────────────
tasks:
up:
desc: Start all services (production)
cmds:
- "{{.COMPOSE}} up -d"
down:
desc: Stop all services
cmds:
- "{{.COMPOSE}} down"
build:
desc: Build all images
deps: [check]
cmds:
- "{{.COMPOSE}} build"
logs:
desc: Follow logs for all services (pass SERVICE= to filter)
cmds:
- "{{.COMPOSE}} logs -f {{.SERVICE}}"
restart:
desc: Restart a service without rebuilding (e.g. task restart SERVICE=api)
cmds:
- "{{.COMPOSE}} restart {{.SERVICE}}"
# ── Dev / Debug ───────────────────────────────────────────────────────────────
dev:
desc: Start backend in dev mode (hot reload, source mounts)
cmds:
- "{{.COMPOSE}} {{.DEV_FLAGS}} up {{.DEV_SERVICES}}"
dev:detach:
desc: Start backend in dev mode, detached
cmds:
- "{{.COMPOSE}} {{.DEV_FLAGS}} up -d {{.DEV_SERVICES}}"
dev:web:
desc: Start Vite dev server (proxies /api to localhost:8000)
dir: web
cmds:
- npm run dev
dev:full:
desc: Start complete development server (backend + frontend) with follow logs
cmds:
- echo "Starting development environment..."
- "{{.COMPOSE}} {{.DEV_FLAGS}} up -d {{.DEV_SERVICES}}"
- echo "Starting frontend development server..."
- cd web && npm run dev &
- echo "Following backend logs... (Ctrl+C to stop)"
- "{{.COMPOSE}} {{.DEV_FLAGS}} logs -f api audio-worker nc-watcher"
dev:logs:
desc: Follow logs in dev mode
cmds:
- "{{.COMPOSE}} {{.DEV_FLAGS}} logs -f {{.SERVICE}}"
dev:restart:
desc: Restart a service in dev mode (e.g. task dev:restart SERVICE=audio-worker)
cmds:
- "{{.COMPOSE}} {{.DEV_FLAGS}} restart {{.SERVICE}}"
# ── Database ──────────────────────────────────────────────────────────────────
migrate:
desc: Run Alembic migrations
cmds:
- "{{.COMPOSE}} exec api alembic upgrade head"
migrate:auto:
desc: Autogenerate a migration (e.g. task migrate:auto M="add users table")
cmds:
- "{{.COMPOSE}} exec api alembic revision --autogenerate -m '{{.M}}'"
# ── Setup ─────────────────────────────────────────────────────────────────────
setup:
desc: First-time setup — start services, configure Nextcloud, seed data
cmds:
- task: up
- echo "Waiting for Nextcloud to initialize (~60s)..."
- sleep 60
- bash scripts/nc-setup.sh
- bash scripts/seed.sh
# ── Testing ───────────────────────────────────────────────────────────────────
# Run this after every feature branch — fast, no external services required.
test:feature:
desc: "Post-feature pipeline: typecheck + frontend tests + backend unit tests (no services needed)"
cmds:
- task: typecheck:web
- task: test:web
- task: test:api:unit
- task: test:worker
- task: test:watcher
# Full CI pipeline — runs everything including integration tests.
# Requires: services up (task dev:detach), DB migrated.
ci:
desc: "Full CI pipeline: lint + typecheck + all tests (requires services running)"
cmds:
- task: lint
- task: typecheck:web
- task: test:web
- task: test:api
- task: test:worker
- task: test:watcher
test:
desc: Run all backend tests (unit + integration)
deps: [test:api, test:worker, test:watcher]
test:web:
desc: Run frontend unit tests (via podman — no local Node required)
dir: web
cmds:
- podman run --rm -v "$(pwd)":/app:Z -w /app node:20-alpine
sh -c "npm install --legacy-peer-deps --silent && npm run test"
test:api:
desc: Run all API tests with coverage (unit + integration)
dir: api
cmds:
- uv run pytest tests/ -v --cov=src/rehearsalhub --cov-report=term-missing
test:api:unit:
desc: Run API unit tests only (no database or external services required)
dir: api
cmds:
- uv run pytest tests/unit/ -v -m "not integration"
test:worker:
desc: Run worker tests with coverage
dir: worker
cmds:
- uv run pytest tests/ -v --cov=src/worker --cov-report=term-missing
test:watcher:
desc: Run watcher tests with coverage
dir: watcher
cmds:
- uv run pytest tests/ -v --cov=src/watcher --cov-report=term-missing
test:integration:
desc: Run integration tests (requires services running)
dir: api
cmds:
- uv run pytest tests/integration/ -v -m integration
# ── Linting & type checking ───────────────────────────────────────────────────
check:
desc: Run all linters and type checkers
deps: [lint, typecheck:web]
lint:
desc: Lint all services
cmds:
- cd api && uv run ruff check src/ tests/ && uv run mypy src/
- cd worker && uv run ruff check src/ tests/
- cd watcher && uv run ruff check src/ tests/
- cd web && npm run lint
typecheck:web:
desc: TypeScript type check
dir: web
cmds:
- npm run typecheck
format:
desc: Auto-format Python source
cmds:
- cd api && uv run ruff format src/ tests/
- cd worker && uv run ruff format src/ tests/
- cd watcher && uv run ruff format src/ tests/
# ── Shells ────────────────────────────────────────────────────────────────────
shell:api:
desc: Shell into the API container
interactive: true
cmds:
- "{{.COMPOSE}} exec api bash"
shell:db:
desc: psql shell
interactive: true
cmds:
- "{{.COMPOSE}} exec db psql -U $POSTGRES_USER -d $POSTGRES_DB"
shell:redis:
desc: redis-cli shell
interactive: true
cmds:
- "{{.COMPOSE}} exec redis redis-cli"