From 1bd3b8ecb63d284f574fc365782f032b910c1ce1 Mon Sep 17 00:00:00 2001 From: Shroominic Date: Wed, 4 Jun 2025 14:02:23 +0200 Subject: [PATCH] add auto testing --- .github/workflows/test.yml | 50 ++++++++++++++++++++++++++++++++++++++ pyproject.toml | 24 +++++++++++++++++- pytest.ini | 17 ------------- uv.lock | 2 ++ 4 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 pytest.ini diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..e151de03 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,50 @@ +name: Run Tests + +on: + push: + branches: ["*"] # Run on all branches + pull_request: + branches: ["*"] # Run on PRs to all branches + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11", "3.12"] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Set up Python ${{ matrix.python-version }} + run: uv python install ${{ matrix.python-version }} + + - name: Install dependencies + run: | + uv sync --dev + + - name: Run linting with ruff + run: | + uv run ruff check . + + - name: Run type checking with mypy + run: | + uv run mypy . + + - name: Run tests with pytest + run: | + uv run pytest --verbose --tb=short + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-results-${{ matrix.python-version }} + path: | + pytest.xml + .coverage + retention-days: 30 diff --git a/pyproject.toml b/pyproject.toml index f2ba961a..69dccfdb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,11 +5,12 @@ description = "Payment proxy for your LLM endpoint using cashu and nostr." readme = "README.md" requires-python = ">=3.11" dependencies = [ + "fastapi[standard]>=0.115", "aiosqlite>=0.20", "sixty-nuts>=0.0.2", - "fastapi[standard]>=0.115", "sqlmodel>=0.0.24", "httpx[socks]>=0.25.2", + "greenlet>=3.2.1", ] [dependency-groups] @@ -21,3 +22,24 @@ dev = [ "pytest-asyncio>=0.24.0", "httpx>=0.25.2", ] + +[tool.pytest.ini_options] +testpaths = ["tests"] +python_files = "test_*.py" +python_classes = "Test*" +python_functions = "test_*" +asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "function" +addopts = [ + "-v", + "--tb=short", + "--strict-markers", + "--disable-warnings", + "-p", + "no:warnings", +] +markers = [ + "asyncio: marks tests as async (deselect with '-m \"not asyncio\"')", + "integration: marks tests as integration tests", + "unit: marks tests as unit tests", +] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 094801d8..00000000 --- a/pytest.ini +++ /dev/null @@ -1,17 +0,0 @@ -[tool:pytest] -testpaths = tests -python_files = test_*.py -python_classes = Test* -python_functions = test_* -asyncio_mode = auto -asyncio_default_fixture_loop_scope = function -addopts = - -v - --tb=short - --strict-markers - --disable-warnings - -p no:warnings -markers = - asyncio: marks tests as async (deselect with '-m "not asyncio"') - integration: marks tests as integration tests - unit: marks tests as unit tests \ No newline at end of file diff --git a/uv.lock b/uv.lock index e82f6d36..0ffe1979 100644 --- a/uv.lock +++ b/uv.lock @@ -797,6 +797,7 @@ source = { virtual = "." } dependencies = [ { name = "aiosqlite" }, { name = "fastapi", extra = ["standard"] }, + { name = "greenlet" }, { name = "httpx", extra = ["socks"] }, { name = "sixty-nuts" }, { name = "sqlmodel" }, @@ -816,6 +817,7 @@ dev = [ requires-dist = [ { name = "aiosqlite", specifier = ">=0.20" }, { name = "fastapi", extras = ["standard"], specifier = ">=0.115" }, + { name = "greenlet", specifier = ">=3.2.1" }, { name = "httpx", extras = ["socks"], specifier = ">=0.25.2" }, { name = "sixty-nuts", specifier = ">=0.0.2" }, { name = "sqlmodel", specifier = ">=0.0.24" },