Skip to content

ci(github-actions): add pytest workflow for unit suite#2

Open
Dhruv-Davda wants to merge 1 commit into
theapprenticeproject:mainfrom
Dhruv-Davda:ci/add-github-actions-pytest-workflow
Open

ci(github-actions): add pytest workflow for unit suite#2
Dhruv-Davda wants to merge 1 commit into
theapprenticeproject:mainfrom
Dhruv-Davda:ci/add-github-actions-pytest-workflow

Conversation

@Dhruv-Davda
Copy link
Copy Markdown

Summary

Adds a GitHub Actions workflow that runs the pytest unit suite on every push to main and every pull request, so contributors get fast feedback without spinning up the full Docker stack locally. The repo already has 384 pytest tests and a well-configured pytest.ini with unit / integration / slow markers - this change wires those into automated CI.

What's in the box

File Purpose
.github/workflows/ci.yml One job (unit-tests) that runs pytest -m "not integration and not slow" on Python 3.11 with pip caching, uploads coverage artifacts, and uses concurrency.cancel-in-progress to drop stale runs.

Zero existing files modified.

Design notes

  • Hermetic by default. Integration and slow markers (documented in pytest.ini as requiring Postgres + RabbitMQ) are excluded from CI. A future job can run them against a Docker-Compose-spun-up service matrix on a dedicated trigger.
  • Coverage gate disabled in CI runs. pytest.ini enforces --cov-fail-under=80, but that threshold reflects the full-suite surface. The hermetic CI subset doesn't exercise the same code paths, so the workflow uses --cov-fail-under=0 and still uploads coverage as artifacts. The global gate stays useful for local full-suite runs.
  • Dependency caching. actions/setup-python caches pip based on requirements.txt + requirements-test.txt, so subsequent runs install in seconds.
  • Concurrency control. Newer commits on a branch / PR cancel in-flight CI for the previous commit, saving Actions minutes.

Out of scope (deliberate follow-ups)

  • A separate lint job (ruff check, ruff format --check) and a type-check job (mypy). Both tools are already pinned in requirements-test.txt. Splitting them off keeps this PR small and focused; happy to add either in a follow-up.
  • An integration-test job against Compose-spun Postgres + RabbitMQ. Worth doing but needs decisions about secrets / runner sizing that are better discussed separately.
  • Codecov / Coveralls upload. Currently coverage stays as an Actions artifact; promoting it to a hosted service is a one-line change once the maintainer decides on a provider.

Verification

The workflow itself runs on this PR - once opened, GitHub Actions will execute it against the head commit. If the unit subset surfaces any environment-specific failures we couldn't reproduce locally, happy to iterate.


Posting this alongside an application to DMP 2026 / theapprenticeproject/C4GT_2026#2 (the cost-efficient VLM evaluator project for TAP Buddy). Engaging with tap_plg first because its CLIP-based image-embedding stack is the closest analogue to the vision-model work the DMP project targets.

The repo ships with 384 pytest tests (per the README) and a configured
pytest.ini with markers (unit, integration, slow) but no GitHub Actions
workflow to enforce green tests on pull requests. This change adds the
minimal CI surface so contributors get fast feedback without having to
spin up the full Docker stack locally.

Workflow design:
- Triggers on push to main and on PRs targeting main.
- Sets up Python 3.11 with pip dependency caching keyed on
  requirements.txt + requirements-test.txt.
- Installs requirements-test.txt (which transitively pulls
  requirements.txt) and runs pytest with -m "not integration and not
  slow", excluding the markers documented in pytest.ini that need live
  Postgres + RabbitMQ.
- Disables the global --cov-fail-under=80 gate in CI runs because the
  hermetic subset covers a smaller surface than the full suite; teams
  can re-enable it in a dedicated integration-test job once services
  are provisioned in CI.
- Uploads coverage.xml and htmlcov/ as artifacts (14-day retention).
- Uses concurrency.cancel-in-progress so stale runs on the same branch
  get cancelled when a newer commit lands.

Zero existing files modified; pure addition of a single workflow file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant