Skip to content

Testing and CI

Sergey Gerasimov edited this page Oct 23, 2026 · 7 revisions

Testing & CI

DerivLab is verified locally and on GitHub Actions.


Test suite

pytest -q
ruff check .

The suite contains 248 tests and passes on:

  • Python 3.12 (local development)
  • Python 3.11 (CI and Dev Container)

All tests are offline. tests/conftest.py forces the local LLM provider so a developer's .env key never triggers paid API calls during tests.

Coverage

  • CI runs --cov=derivlab --cov-fail-under=80.
  • The measured total is 85%.
  • coverage.json feeds docs/badges/coverage.svg; CI verifies the badge is not stale.
  • The full report is uploaded as a workflow artifact.

Coverage groups

Area What is covered
Option math Black-Scholes, Greeks, intrinsic value
Strategies Plans, legs, credit/debit signs, condor wings
Backtest engine NAV, drawdown, metrics, fees, assignment, deterministic runs
Game Scenario slicing, alerts, actions, completion, scoring, errors
AI agents Policies, regime changes, JSON parsing, HTTP clients, retries, fallbacks, reports, news, bridge, arena
UI Streamlit AppTest across all six screens, AI Arena run, game flow, low-capital warnings
Repository Compose restart policy, Dockerfile, Dev Container, seed, screenshots, demo media, secrets hygiene

GitHub Actions

CI

.github/workflows/ci.yml

  • Python 3.11 · lint + tests — installs pinned dependencies, runs Ruff and the full pytest suite.
  • Docker image and health — builds the image, starts the container, polls /_stcore/health, and reports the restart policy.

Docs

.github/workflows/docs.yml

  • Docs · links + ADR checks local links, ADR structure, versioning, the social preview, and the coverage badge.
  • Lychee checks external links with rate-limit tolerance.
  • It runs on push, pull request, and manual dispatch.

CodeQL

.github/workflows/codeql.yml

  • Python analysis with build-mode: none.
  • Runs on push, pull request, a weekly schedule, and manual dispatch.
  • Uploads results to Code Scanning.

Required status checks

main is protected by the Protect Main repository ruleset. A pull request must pass:

  • Python 3.11 · lint + tests
  • Docker image and health
  • Analyze Python
  • Docs · links + ADR

Strict mode requires the branch to be up to date. Force pushes and branch deletion are disabled. Conversation resolution is required. The ruleset has no bypass actors, so the checks apply to administrators too.

The first CodeQL analysis completed with 0 alerts.


Pull request verification

Pull Request #1 verified the protected-branch flow:

  1. Both workflows triggered on pull_request.
  2. All required checks reported success.
  3. The branch protection rule accepted the squash merge.
  4. The merged main commit re-ran CI and CodeQL.

Local browser smoke test

The demo was verified with Playwright against the Docker container:

  • AI Arena with live OpenAI critic/news.
  • Leaderboard, three-section report, NewsWire, Model stack.
  • Existing Strategy Deck, Backtest Lab, Hold the Position, Data Vault, Field Guide.
  • No console or page errors.

Clone this wiki locally