From 9608a741e7b84ae42ad305f3ec73fd154bacab70 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 04:26:48 +0000 Subject: [PATCH] ci: restore CI with lint and test checks CI was moved to .github/workflows_disabled. Restored as-is it would fail: - `pip install -e .` fails because setup.py imports Cython, which no build dependency declares, so the runtime dependencies (pyjwt, starlette, ...) were never installed and four test modules failed to import. - An unconfigured, current ruff enables rules the code was never written against (27 findings). The new .github/workflows/ci.yml installs the runtime dependencies listed in pyproject.toml, without building the Cython extensions, and runs ruff and pytest on Python 3.10-3.13 for pushes and pull requests to main. It does not publish: the tag-triggered GHCR job stays in workflows_disabled. pyproject.toml gains a [tool.ruff] block selecting E and F, and the four unused imports it reports in tests/ are removed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016nxi4bp7DP1ancERNUUfzj --- .github/workflows/ci.yml | 45 +++++++++++++++++++++++++++++++++ pyproject.toml | 11 +++++++- tests/conftest.py | 2 +- tests/test_auth_service.py | 1 - tests/test_policy_middleware.py | 1 - tests/test_s2s_middleware.py | 1 - 6 files changed, 56 insertions(+), 5 deletions(-) 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..bebac50 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + test: + name: Lint & test (Python ${{ matrix.python-version }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + + # Install the runtime dependencies declared in pyproject.toml rather + # than the package itself: setup.py compiles the Cython extensions, + # and the tests exercise the Python sources from the repository root. + - name: Install dependencies + run: | + python -m pip install --upgrade pip tomli + python - > requirements-ci.txt <<'PY' + import tomli + with open("pyproject.toml", "rb") as f: + print("\n".join(tomli.load(f)["project"]["dependencies"])) + PY + python -m pip install -r requirements-ci.txt pytest pytest-asyncio ruff + + - name: Lint + run: ruff check . + + - name: Test + run: pytest -q diff --git a/pyproject.toml b/pyproject.toml index f1330f1..a7f63b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,4 +9,13 @@ dependencies = [ "redis", "pyjwt", "starlette" -] \ No newline at end of file +] + +[tool.ruff] +line-length = 120 +target-version = "py310" + +[tool.ruff.lint] +# pyflakes + pycodestyle errors only; the explicit selection keeps CI stable +# when a new ruff release changes its default rule set. +select = ["E", "F"] diff --git a/tests/conftest.py b/tests/conftest.py index be6fbdf..afa3cb0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,7 @@ Developer: Manish Kumar """ import pytest -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import AsyncMock, patch @pytest.fixture diff --git a/tests/test_auth_service.py b/tests/test_auth_service.py index 595c3a4..660b91c 100644 --- a/tests/test_auth_service.py +++ b/tests/test_auth_service.py @@ -6,7 +6,6 @@ Developer: Manish Kumar """ -import pytest def test_auth_service_module_importable(): diff --git a/tests/test_policy_middleware.py b/tests/test_policy_middleware.py index 0dd4e9b..10d8109 100644 --- a/tests/test_policy_middleware.py +++ b/tests/test_policy_middleware.py @@ -5,7 +5,6 @@ import sys import types import importlib -import pytest from unittest.mock import AsyncMock, MagicMock, patch from starlette.testclient import TestClient from starlette.applications import Starlette diff --git a/tests/test_s2s_middleware.py b/tests/test_s2s_middleware.py index ad6c8c9..58c6b48 100644 --- a/tests/test_s2s_middleware.py +++ b/tests/test_s2s_middleware.py @@ -6,7 +6,6 @@ import types import importlib import jwt -import pytest from starlette.testclient import TestClient from starlette.applications import Starlette from starlette.responses import JSONResponse