Skip to content

Testing and CI

Savvas Leousis edited this page Sep 26, 2026 · 2 revisions

Testing and CI

Tests are written first, run offline by default, and run on every push and pull request.

flowchart LR
  P[push / PR] --> T[test<br/>ruff + pytest -n auto]
  P --> U[ui<br/>lint, test, build]
  P --> A[audit<br/>pip-audit, npm audit]
  P --> I[image + deploy lint]
  TAG[tag v*.*.*] --> R[release] --> D[deploy]
  M[push to main] --> DOC[docs site + wiki pages]
Loading

Run tests

uv run pytest -n auto                         # everything, in parallel on every core
uv run pytest tests/unit/test_params_spec.py -k "tunable"   # one file, by keyword
uv run ruff check .
uv run ruff format .

Console tests, from web/: npm test, npm run lint, npm run build.

Layout

Folder What
tests/unit/ Fast tests of single pieces
tests/integration/ Pieces together: lake, lab, tick, CLI, API, MCP
tests/integration/live/ Real network calls, gated
web/src/**/*.spec.ts Console unit tests (Vitest)

Live tests

  • Marked @pytest.mark.live and placed under tests/integration/live/.
  • Skipped unless STONKS_RUN_LIVE_TESTS=1.
  • Need real keys: EODHD_API_KEY; Alpaca tests also need ALPACA_API_KEY and ALPACA_SECRET_KEY.
  • The EODHD free tier returns an error for fundamentals; those tests skip, not fail.
STONKS_RUN_LIVE_TESTS=1 uv run pytest -m live

Rules

  • TDD: write a failing test first, then the code. Every new component ships with tests.
  • Hermetic: default runs use fake data sources and a fake broker connection; no network.
  • Secrets never land in git.

Workflows

Workflow When Does
ci.yml push to main, pull requests Python lint, format and tests; console client check, lint, tests and build; pip-audit and npm audit; Docker image build and smoke test; Compose, shellcheck and Terraform checks
codeql.yml push to main, pull requests, weekly CodeQL security scan
release.yml tag v*.*.* Checks the tag matches pyproject.toml, builds and pushes the image, makes a GitHub release
deploy.yml after a stable release, or by hand Deploys the tag to the server over SSH
docs.yml push to main Publishes the API docs site and copies the generated API Reference and MCP Tools pages to this wiki

Clone this wiki locally