2.9 KiB
2.9 KiB
Development Process — Test-Develop-Debug
Local Environment
- Python 3.12 via NixOS, virtualenv at
.venv/ - Always use
.venv/bin/pythonor activate withsource .venv/bin/activatebefore running Python commands - For tools not available in
.venv/(ruff, gh, etc.), usenix-shell -p <pkg> --run "<cmd>" - Node.js 24 for frontend;
frontend/has its ownnode_modules/ - Frontend tests:
cd frontend && npx vitest --run - Python tests:
nix-shell -p ruff --run "ruff check services/"thenpython -m pytest tests/ -x --tb=short -q
Workflow
- Write or update tests for the target behavior
- Implement the minimal code to pass
- Debug failures, fix, re-run
- Commit and push — CI builds images automatically
- Deploy:
helm upgrade --install stonks-oracle infra/helm/stonks-oracle -n stonks-oracle - Restart changed services:
kubectl rollout restart deployment/<name> -n stonks-oracle
Testing
- Python:
pytestwithpytest-asynciofor async code, tests intests/ - Frontend: Vitest + MSW (Mock Service Worker) for deterministic API mocking, tests in
frontend/src/test/ - Run Python tests:
python -m pytest tests/ -x --tb=short -q - Run frontend tests:
cd frontend && npx vitest --run - Lint Python:
nix-shell -p ruff --run "ruff check services/"
CI/CD — GitHub Actions
- Workflow:
.github/workflows/build.yml - Triggers on push to
mainand PRs - Jobs:
lint-and-test: ruff lint + pytest + frontend vitest (Node 24)build-services: matrix build of all Python services → GHCRbuild-dashboard: frontend/Dockerfile → GHCRbuild-superset: docker/Dockerfile.superset → GHCR
- CI handles all image builds and pushes — do NOT manually docker push
- Check CI:
nix-shell -p gh --run "gh run list -L 3" - Re-run failed:
nix-shell -p gh --run "gh run rerun <id> --failed"
Deploy
- Full deploy/redeploy:
~/sources/kube/stonks-oracle/runmefirst.sh - Full teardown:
~/sources/kube/stonks-oracle/runmelast.sh - Quick Helm upgrade:
helm upgrade --install stonks-oracle infra/helm/stonks-oracle -n stonks-oracle - Restart single service:
kubectl rollout restart deployment/<name> -n stonks-oracle - Check pods:
kubectl get pods -n stonks-oracle
Git Conventions
- Commit after each completed phase task
- Commit message format:
phase N: short description - Push to
maintriggers CI
Code Style
- Python 3.12, type hints everywhere
- Pydantic for data validation
- FastAPI for HTTP services
- asyncio + asyncpg/aioredis for async I/O
- Minimal dependencies, prefer stdlib where possible
- Frontend: React 19, TypeScript strict mode, Tailwind CSS, TanStack Router/Query
- UUID fields from asyncpg must be converted to str via
_row_dict()helpers
Documentation
- Do NOT create large summary/success markdown files after each step
- Keep notes short, concise, and organized under
docs/notes/ - If a note isn't useful for future reference, don't write it