From 907d1cfb44c36d1d46040b74be6207315d7ee005 Mon Sep 17 00:00:00 2001 From: Dhruv Davda Date: Tue, 12 May 2026 00:36:58 +0530 Subject: [PATCH] ci(github-actions): add pytest workflow for unit suite 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. --- .github/workflows/ci.yml | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3f9e6a4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: CI + +# Run the pytest unit suite on every push to main and on every pull request. +# Integration and slow markers are excluded here because they require live +# services (PostgreSQL, RabbitMQ) that aren't provisioned in CI; they're meant +# to be run locally or in a dedicated integration environment. + +on: + push: + branches: [main] + pull_request: + branches: [main] + +# Cancel a running CI run for a branch when a newer commit lands on the same +# branch / PR head, so we don't pile up duplicate jobs. +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + unit-tests: + name: pytest (unit) + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + cache: pip + cache-dependency-path: | + requirements.txt + requirements-test.txt + + - name: Install test dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-test.txt + + - name: Run unit tests + run: | + # Exclude integration / slow markers (defined in pytest.ini) — those + # need live Postgres + RabbitMQ. Disable the global coverage gate + # because CI only covers the hermetic subset. + pytest -m "not integration and not slow" \ + --cov-fail-under=0 \ + -ra + + - name: Upload coverage artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ github.run_id }} + path: | + coverage.xml + htmlcov/ + if-no-files-found: ignore + retention-days: 14