Skip to content

Commit

Permalink
Merge pull request #328 from chirizxc/develop
Browse files Browse the repository at this point in the history
CI: add python 3.13 in tests
  • Loading branch information
Tishka17 authored Jan 7, 2025
2 parents fd0cf9f + 9e58ed7 commit 4446068
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 109 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/frameworks-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install . -r requirements_dev.txt
uv pip install . -r requirements_dev.txt --system
- name: Run tests
run: |
find requirements -name "*-latest.txt" -exec basename {} .txt \; | xargs -d , tox -e
nox -t latest
13 changes: 8 additions & 5 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13"

steps:
- uses: actions/checkout@v4
- name: Set up ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}


- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install . -r requirements_dev.txt
uv pip install . -r requirements_dev.txt --system
- name: Run ruff
run: |
Expand All @@ -43,9 +46,9 @@ jobs:
- name: Run tests
run: |
tox
nox -t non-latest unit real-world
- name: Build doc
run: |
pip install -r requirements_doc.txt
uv pip install -r requirements_doc.txt --system
sphinx-build -M html docs docs-build
4 changes: 2 additions & 2 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ All of them can be run using tox:

.. code-block::
tox run
nox
All integration tests are using specific versions of libraries by default. You can run them with latest version specifying it explicitly. E.g.:

.. code-block::
tox run -e fastapi-latest
nox -s aiohttp_latest
All requirement files for tests are located in ``/requirements`` dir

Expand Down
6 changes: 3 additions & 3 deletions examples/real_world/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fastapi==0.109.0
aiogram==3.3.0
uvicorn==0.27.0
fastapi==0.115.6
aiogram==3.16.0
uvicorn==0.34.0
91 changes: 91 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import sys
from collections.abc import Callable
from dataclasses import dataclass

import nox

nox.options.default_venv_backend = "uv"
nox.options.reuse_existing_virtualenvs = True

CMD = ("pytest", "--cov=dishka", "--cov-append", "--cov-report=term-missing", "-v")
INSTALL_CMD = ("pytest", "pytest-cov", "-e", ".")


@dataclass(frozen=True, slots=True)
class IntegrationEnv:
library: str
version: str
constraint: Callable[[], bool] = lambda: True

def get_req(self) -> str:
return f"requirements/{self.library.replace('_', '-')}-{self.version}.txt"

def get_tests(self) -> str:
return f"tests/integrations/{self.library}"


INTEGRATIONS = [
IntegrationEnv("aiogram", "330", lambda: sys.version_info < (3, 13)),
IntegrationEnv("aiogram", "3140"),
IntegrationEnv("aiogram", "latest"),
IntegrationEnv("aiogram_dialog", "210"),
IntegrationEnv("aiogram_dialog", "latest"),
IntegrationEnv("aiohttp", "393"),
IntegrationEnv("aiohttp", "latest"),
IntegrationEnv("arq", "0250"),
IntegrationEnv("arq", "latest"),
IntegrationEnv("click", "817"),
IntegrationEnv("click", "latest"),
IntegrationEnv("fastapi", "0096"),
IntegrationEnv("fastapi", "0109"),
IntegrationEnv("fastapi", "latest"),
IntegrationEnv("faststream", "047", lambda: sys.version_info < (3, 13)),
IntegrationEnv("faststream", "050", lambda: sys.version_info < (3, 13)),
IntegrationEnv("faststream", "0529"),
IntegrationEnv("faststream", "latest"),
IntegrationEnv("flask", "302"),
IntegrationEnv("flask", "latest"),
IntegrationEnv("grpcio", "1641", lambda: sys.version_info < (3, 13)),
IntegrationEnv("grpcio", "1680"),
IntegrationEnv("grpcio", "latest"),
IntegrationEnv("litestar", "230"),
IntegrationEnv("litestar", "latest"),
IntegrationEnv("sanic", "23121"),
IntegrationEnv("sanic", "latest"),
IntegrationEnv("starlette", "0270"),
IntegrationEnv("starlette", "latest"),
IntegrationEnv("taskiq", "0110"),
IntegrationEnv("taskiq", "latest"),
IntegrationEnv("telebot", "415"),
IntegrationEnv("telebot", "latest"),
]


for env in INTEGRATIONS:
@nox.session(
name=f"{env.library}_{env.version}",
tags=[env.library, "latest" if env.version == "latest" else "non-latest"],
)
def session(session: nox.Session, env=env) -> None:
if not env.constraint():
session.skip("Skip tests on python 3.13 due to compatibility issues")
session.install(*INSTALL_CMD, "-r", env.get_req())
session.run(*CMD, env.get_tests())


@nox.session(tags=["unit"])
def unit(session: nox.Session) -> None:
session.install(
*INSTALL_CMD,
"-r", "requirements/test.txt",
)
session.run(*CMD, "tests/unit")


@nox.session(tags=["real-world"])
def real_world(session: nox.Session) -> None:
session.install(
*INSTALL_CMD,
"-r", "examples/real_world/requirements_test.txt",
)
session.run(*CMD, "examples/real_world/tests/")
2 changes: 2 additions & 0 deletions requirements/aiogram-3140.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r test.txt
aiogram==3.14.0
5 changes: 5 additions & 0 deletions requirements/faststream-0529.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-r test.txt

faststream[nats]==0.5.29
typing-extensions==4.12.2
anyio==4.6.0
4 changes: 4 additions & 0 deletions requirements/grpcio-1680.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-r test.txt
grpcio==1.68.0
grpcio-tools==1.68.0
grpcio-testing==1.68.0
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ruff==0.6.*
tox==4.21.*
tox-uv==1.15.*
nox==2024.10.*
uv==0.5.*
mypy==1.12.*
93 changes: 0 additions & 93 deletions tox.ini

This file was deleted.

0 comments on commit 4446068

Please sign in to comment.