From 3cd8f8272905c5dda37a9651d8f3c4c94d683a25 Mon Sep 17 00:00:00 2001 From: chiri Date: Mon, 30 Dec 2024 22:58:52 +0300 Subject: [PATCH 1/9] CI: add python 3.13 in tests --- .github/workflows/setup.yml | 1 + examples/real_world/requirements.txt | 6 +++--- requirements/aiogram-3140.txt | 2 ++ requirements/aiogram-330.txt | 2 +- requirements/faststream-047.txt | 6 +++--- requirements/faststream-050.txt | 6 +++--- requirements/faststream-0526.txt | 5 +++++ requirements/grpcio-1641.txt | 6 +++--- requirements/grpcio-1680.txt | 4 ++++ tox.ini | 24 +++++++++++------------- 10 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 requirements/aiogram-3140.txt create mode 100644 requirements/faststream-0526.txt create mode 100644 requirements/grpcio-1680.txt diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index f7b69d47..13993f77 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -20,6 +20,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@v4 diff --git a/examples/real_world/requirements.txt b/examples/real_world/requirements.txt index 011955a3..4cf73042 100644 --- a/examples/real_world/requirements.txt +++ b/examples/real_world/requirements.txt @@ -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 \ No newline at end of file diff --git a/requirements/aiogram-3140.txt b/requirements/aiogram-3140.txt new file mode 100644 index 00000000..8856c13a --- /dev/null +++ b/requirements/aiogram-3140.txt @@ -0,0 +1,2 @@ +-r test.txt +aiogram==3.14.0 \ No newline at end of file diff --git a/requirements/aiogram-330.txt b/requirements/aiogram-330.txt index 67aabf91..a2694e08 100644 --- a/requirements/aiogram-330.txt +++ b/requirements/aiogram-330.txt @@ -1,2 +1,2 @@ -r test.txt -aiogram==3.3.0 \ No newline at end of file +aiogram==3.3.0; python_version <= "3.12" \ No newline at end of file diff --git a/requirements/faststream-047.txt b/requirements/faststream-047.txt index 998b3291..676bd453 100644 --- a/requirements/faststream-047.txt +++ b/requirements/faststream-047.txt @@ -1,5 +1,5 @@ -r test.txt -faststream[nats]==0.4.7 -typing-extensions==4.11.0 -anyio==4.6.2 +faststream[nats]==0.4.7; python_version <= "3.12" +typing-extensions==4.11.0; python_version <= "3.12" +anyio==4.6.2; python_version <= "3.12" diff --git a/requirements/faststream-050.txt b/requirements/faststream-050.txt index 7a2b11ed..23bd67c9 100644 --- a/requirements/faststream-050.txt +++ b/requirements/faststream-050.txt @@ -1,5 +1,5 @@ -r test.txt -faststream[nats]==0.5.0rc2 -typing-extensions==4.11.0 -anyio==4.6.2 +faststream[nats]==0.5.0rc2; python_version <= "3.12" +typing-extensions==4.11.0; python_version <= "3.12" +anyio==4.6.2; python_version <= "3.12" diff --git a/requirements/faststream-0526.txt b/requirements/faststream-0526.txt new file mode 100644 index 00000000..7a248668 --- /dev/null +++ b/requirements/faststream-0526.txt @@ -0,0 +1,5 @@ +-r test.txt + +faststream[nats]==0.5.26 +typing-extensions==4.12.2 +anyio==4.7.0 \ No newline at end of file diff --git a/requirements/grpcio-1641.txt b/requirements/grpcio-1641.txt index c9d93ba0..471a8620 100644 --- a/requirements/grpcio-1641.txt +++ b/requirements/grpcio-1641.txt @@ -1,4 +1,4 @@ -r test.txt -grpcio==1.64.1 -grpcio-tools==1.64.1 -grpcio-testing==1.64.1 \ No newline at end of file +grpcio==1.64.1; python_version <= "3.12" +grpcio-tools==1.64.1; python_version <= "3.12" +grpcio-testing==1.64.1; python_version <= "3.12" \ No newline at end of file diff --git a/requirements/grpcio-1680.txt b/requirements/grpcio-1680.txt new file mode 100644 index 00000000..f5a92a0f --- /dev/null +++ b/requirements/grpcio-1680.txt @@ -0,0 +1,4 @@ +-r test.txt +grpcio==1.68.0 +grpcio-tools==1.68.0 +grpcio-testing==1.68.0 \ No newline at end of file diff --git a/tox.ini b/tox.ini index cfaa0bbd..ec4e5d5d 100644 --- a/tox.ini +++ b/tox.ini @@ -9,11 +9,10 @@ env_list = aiohttp-393, flask-302, litestar-230, - aiogram-330, + aiogram-{330,3140}, telebot-415, starlette-0270, - faststream-047, - faststream-050, + faststream-{047,050,0526}, arq-0250, taskiq-0110, sanic-23121, @@ -34,6 +33,7 @@ deps = fastapi-0109: -r requirements/fastapi-0109.txt aiogram-latest: -r requirements/aiogram-latest.txt aiogram-330: -r requirements/aiogram-330.txt + aiogram-3140: -r requirements/aiogram-3140.txt telebot-latest: -r requirements/telebot-latest.txt telebot-415: -r requirements/telebot-415.txt flask-latest: -r requirements/flask-latest.txt @@ -45,6 +45,7 @@ deps = faststream-latest: -r requirements/faststream-latest.txt faststream-047: -r requirements/faststream-047.txt faststream-050: -r requirements/faststream-050.txt + faststream-0526: -r requirements/faststream-0526.txt arq-latest: -r requirements/arq-latest.txt arq-0250: -r requirements/arq-0250.txt taskiq-latest: -r requirements/taskiq-latest.txt @@ -54,6 +55,7 @@ deps = aiogram-dialog-210: -r requirements/aiogram-dialog-210.txt aiogram-dialog-latest: -r requirements/aiogram-dialog-latest.txt grpcio-1641: -r requirements/grpcio-1641.txt + grpcio-1680: -r requirements/grpcio-1680.txt grpcio-latest: -r requirements/grpcio-latest.txt click-817: -r requirements/click-817.txt click-latest: -r requirements/click-latest.txt @@ -62,32 +64,28 @@ commands = integrations-base: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/base aiohttp: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/aiohttp fastapi: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/fastapi - aiogram: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/aiogram + aiogram: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations telebot: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/telebot flask: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/flask litestar: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/litestar starlette: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/starlette - faststream: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/faststream + faststream: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations arq: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/arq taskiq: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/taskiq sanic: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/sanic aiogram-dialog: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/aiogram_dialog - grpcio: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/grpcio + grpcio: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations click: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/click allowlist_externals = pytest [testenv:unit] -deps = - pytest - pytest-cov +deps = -r requirements/test.txt commands = pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/unit [testenv:real_world_example] -deps = - pytest - pytest-cov +deps = -r examples/real_world/requirements_test.txt -commands = pytest --cov=dishka --cov-append --cov-report=term-missing -v examples/real_world/tests/ +commands = pytest --cov=dishka --cov-append --cov-report=term-missing -v examples/real_world/tests/ \ No newline at end of file From 165785786a9942192ecf5034e1c3af0c643f88c4 Mon Sep 17 00:00:00 2001 From: chiri Date: Wed, 1 Jan 2025 22:00:43 +0300 Subject: [PATCH 2/9] tests: drop `tox`, add `nox` --- .github/workflows/setup.yml | 12 +- noxfile.py | 270 ++++++++++++++++++ requirements/aiogram-330.txt | 2 +- requirements/faststream-047.txt | 6 +- requirements/faststream-050.txt | 6 +- ...aststream-0526.txt => faststream-0529.txt} | 4 +- requirements/grpcio-1641.txt | 6 +- requirements_dev.txt | 4 +- tox.ini | 91 ------ 9 files changed, 291 insertions(+), 110 deletions(-) create mode 100644 noxfile.py rename requirements/{faststream-0526.txt => faststream-0529.txt} (51%) delete mode 100644 tox.ini diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index 13993f77..d628432b 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -28,11 +28,13 @@ jobs: 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: | @@ -44,9 +46,9 @@ jobs: - name: Run tests run: | - tox + nox -db uv - 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 diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 00000000..5c08af33 --- /dev/null +++ b/noxfile.py @@ -0,0 +1,270 @@ +import sys + +import nox + +PYTHON_3_13 = sys.version_info.minor == 13 +CMD = ("pytest", "--cov=dishka", "--cov-append", "--cov-report=term-missing", "-v") +PATH = { + "aiogram_330": "requirements/aiogram-330.txt", + "aiogram_3140": "requirements/aiogram-3140.txt", + "aiogram_latest": "requirements/aiogram-latest.txt", + "aiogram_dialog_210": "requirements/aiogram-dialog-210.txt", + "aiogram_dialog_latest": "requirements/aiogram-dialog-latest.txt", + "aiohttp_393": "requirements/aiohttp-393.txt", + "aiohttp_latest": "requirements/aiohttp-latest.txt", + "arq_0250": "requirements/arq-0250.txt", + "arq_latest": "requirements/arq-latest.txt", + "click_817": "requirements/click-817.txt", + "click_latest": "requirements/click-latest.txt", + "fastapi_0096": "requirements/fastapi-0096.txt", + "fastapi_0109": "requirements/fastapi-0109.txt", + "fastapi_latest": "requirements/fastapi-latest.txt", + "faststream_047": "requirements/faststream-047.txt", + "faststream_050": "requirements/faststream-050.txt", + "faststream_0529": "requirements/faststream-0529.txt", + "faststream_latest": "requirements/faststream-latest.txt", + "flask_302": "requirements/flask-302.txt", + "flask_latest": "requirements/flask-latest.txt", + "grpcio_1641": "requirements/grpcio-1641.txt", + "grpcio_1680": "requirements/grpcio-1680.txt", + "grpcio_latest": "requirements/grpcio-latest.txt", + "litestar_230": "requirements/litestar-230.txt", + "litestar_latest": "requirements/litestar-latest.txt", + "sanic_23121": "requirements/sanic-23121.txt", + "sanic_latest": "requirements/sanic-latest.txt", + "starlette_0270": "requirements/starlette-0270.txt", + "starlette_latest": "requirements/starlette-latest.txt", + "taskiq_0110": "requirements/taskiq-0110.txt", + "taskiq_latest": "requirements/taskiq-latest.txt", + "telebot_415": "requirements/telebot-415.txt", + "telebot_latest": "requirements/telebot-latest.txt", + "unit": "requirements/test.txt", + "real_world_example": "examples/real_world/requirements_test.txt", +} + + +def install_requirements(session: nox.Session) -> None: + session.install("pytest", "pytest-cov", "-e", ".") + session.install("-r", PATH[session.name]) + + +def run_tests(session: nox.Session, path: str) -> None: + session.run(*CMD, path) + + +@nox.session(reuse_venv=True) +def aiogram_330(session: nox.Session) -> None: + if PYTHON_3_13: + session.skip("Skip tests on 3.13") + install_requirements(session) + run_tests(session, "tests/integrations/aiogram") + + +@nox.session(reuse_venv=True) +def aiogram_3140(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/aiogram") + + +@nox.session(reuse_venv=True) +def aiogram_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/aiogram") + + +@nox.session(reuse_venv=True) +def aiogram_dialog_210(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/aiogram_dialog") + + +@nox.session(reuse_venv=True) +def aiogram_dialog_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/aiogram_dialog") + + +@nox.session(reuse_venv=True) +def aiohttp_393(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/aiohttp") + + +@nox.session(reuse_venv=True) +def aiohttp_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/aiohttp") + + +@nox.session(reuse_venv=True) +def arq_0250(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/arq") + + +@nox.session(reuse_venv=True) +def arq_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/arq") + + +@nox.session(reuse_venv=True) +def click_817(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/click") + + +@nox.session(reuse_venv=True) +def click_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/click") + + +@nox.session(reuse_venv=True) +def fastapi_0096(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/fastapi") + + +@nox.session(reuse_venv=True) +def fastapi_0109(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/fastapi") + + +@nox.session(reuse_venv=True) +def fastapi_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/fastapi") + + +@nox.session(reuse_venv=True) +def faststream_047(session: nox.Session) -> None: + if PYTHON_3_13: + session.skip("Skip tests on 3.13") + install_requirements(session) + run_tests(session, "tests/integrations/faststream") + + +@nox.session(reuse_venv=True) +def faststream_050(session: nox.Session) -> None: + if PYTHON_3_13: + session.skip("Skip tests on 3.13") + install_requirements(session) + run_tests(session, "tests/integrations/faststream") + + +@nox.session(reuse_venv=True) +def faststream_0529(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/faststream") + + +@nox.session(reuse_venv=True) +def faststream_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/faststream") + + +@nox.session(reuse_venv=True) +def flask_302(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/flask") + + +@nox.session(reuse_venv=True) +def flask_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/flask") + + +@nox.session(reuse_venv=True) +def grpcio_1641(session: nox.Session) -> None: + if PYTHON_3_13: + session.skip("Skip tests on 3.13") + install_requirements(session) + run_tests(session, "tests/integrations/grpcio") + + +@nox.session(reuse_venv=True) +def grpcio_1680(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/grpcio") + + +@nox.session(reuse_venv=True) +def grpcio_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/grpcio") + + +@nox.session(reuse_venv=True) +def litestar_230(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/litestar") + + +@nox.session(reuse_venv=True) +def litestar_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/litestar") + + +@nox.session(reuse_venv=True) +def sanic_23121(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/sanic") + + +@nox.session(reuse_venv=True) +def sanic_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/sanic") + + +@nox.session(reuse_venv=True) +def starlette_0270(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/starlette") + + +@nox.session(reuse_venv=True) +def starlette_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/starlette") + + +@nox.session(reuse_venv=True) +def taskiq_0110(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/taskiq") + + +@nox.session(reuse_venv=True) +def taskiq_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/taskiq") + + +@nox.session(reuse_venv=True) +def telebot_415(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/telebot") + + +@nox.session(reuse_venv=True) +def telebot_latest(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/integrations/telebot") + + +@nox.session(reuse_venv=True) +def unit(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "tests/unit") + + +@nox.session(reuse_venv=True) +def real_world_example(session: nox.Session) -> None: + install_requirements(session) + run_tests(session, "examples/real_world/tests/") diff --git a/requirements/aiogram-330.txt b/requirements/aiogram-330.txt index a2694e08..67aabf91 100644 --- a/requirements/aiogram-330.txt +++ b/requirements/aiogram-330.txt @@ -1,2 +1,2 @@ -r test.txt -aiogram==3.3.0; python_version <= "3.12" \ No newline at end of file +aiogram==3.3.0 \ No newline at end of file diff --git a/requirements/faststream-047.txt b/requirements/faststream-047.txt index 676bd453..998b3291 100644 --- a/requirements/faststream-047.txt +++ b/requirements/faststream-047.txt @@ -1,5 +1,5 @@ -r test.txt -faststream[nats]==0.4.7; python_version <= "3.12" -typing-extensions==4.11.0; python_version <= "3.12" -anyio==4.6.2; python_version <= "3.12" +faststream[nats]==0.4.7 +typing-extensions==4.11.0 +anyio==4.6.2 diff --git a/requirements/faststream-050.txt b/requirements/faststream-050.txt index 23bd67c9..7a2b11ed 100644 --- a/requirements/faststream-050.txt +++ b/requirements/faststream-050.txt @@ -1,5 +1,5 @@ -r test.txt -faststream[nats]==0.5.0rc2; python_version <= "3.12" -typing-extensions==4.11.0; python_version <= "3.12" -anyio==4.6.2; python_version <= "3.12" +faststream[nats]==0.5.0rc2 +typing-extensions==4.11.0 +anyio==4.6.2 diff --git a/requirements/faststream-0526.txt b/requirements/faststream-0529.txt similarity index 51% rename from requirements/faststream-0526.txt rename to requirements/faststream-0529.txt index 7a248668..061fb56c 100644 --- a/requirements/faststream-0526.txt +++ b/requirements/faststream-0529.txt @@ -1,5 +1,5 @@ -r test.txt -faststream[nats]==0.5.26 +faststream[nats]==0.5.29 typing-extensions==4.12.2 -anyio==4.7.0 \ No newline at end of file +anyio==4.6.0 \ No newline at end of file diff --git a/requirements/grpcio-1641.txt b/requirements/grpcio-1641.txt index 471a8620..c9d93ba0 100644 --- a/requirements/grpcio-1641.txt +++ b/requirements/grpcio-1641.txt @@ -1,4 +1,4 @@ -r test.txt -grpcio==1.64.1; python_version <= "3.12" -grpcio-tools==1.64.1; python_version <= "3.12" -grpcio-testing==1.64.1; python_version <= "3.12" \ No newline at end of file +grpcio==1.64.1 +grpcio-tools==1.64.1 +grpcio-testing==1.64.1 \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt index 1965d3a6..994d81d0 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,4 +1,4 @@ ruff==0.6.* -tox==4.21.* -tox-uv==1.15.* +nox==2024.10.* +uv==0.5.* mypy==1.12.* diff --git a/tox.ini b/tox.ini deleted file mode 100644 index ec4e5d5d..00000000 --- a/tox.ini +++ /dev/null @@ -1,91 +0,0 @@ -[tox] -requires = - tox>=4 -env_list = - unit, - real_world_example, - integrations-base, - fastapi-{0096,0109}, - aiohttp-393, - flask-302, - litestar-230, - aiogram-{330,3140}, - telebot-415, - starlette-0270, - faststream-{047,050,0526}, - arq-0250, - taskiq-0110, - sanic-23121, - aiogram-dialog-210, - grpcio-1641, - click-817 - -[testenv] -use_develop = true -deps = - pytest - pytest-cov - integrations-base: -r requirements/test.txt - aiohttp-393: -r requirements/aiohttp-393.txt - aiohttp-latest: -r requirements/aiohttp-latest.txt - fastapi-latest: -r requirements/fastapi-latest.txt - fastapi-0096: -r requirements/fastapi-0096.txt - fastapi-0109: -r requirements/fastapi-0109.txt - aiogram-latest: -r requirements/aiogram-latest.txt - aiogram-330: -r requirements/aiogram-330.txt - aiogram-3140: -r requirements/aiogram-3140.txt - telebot-latest: -r requirements/telebot-latest.txt - telebot-415: -r requirements/telebot-415.txt - flask-latest: -r requirements/flask-latest.txt - flask-302: -r requirements/flask-302.txt - litestar-latest: -r requirements/litestar-latest.txt - litestar-230: -r requirements/litestar-230.txt - starlette-latest: -r requirements/starlette-latest.txt - starlette-0270: -r requirements/starlette-0270.txt - faststream-latest: -r requirements/faststream-latest.txt - faststream-047: -r requirements/faststream-047.txt - faststream-050: -r requirements/faststream-050.txt - faststream-0526: -r requirements/faststream-0526.txt - arq-latest: -r requirements/arq-latest.txt - arq-0250: -r requirements/arq-0250.txt - taskiq-latest: -r requirements/taskiq-latest.txt - taskiq-0110: -r requirements/taskiq-0110.txt - sanic-latest: -r requirements/sanic-latest.txt - sanic-23121: -r requirements/sanic-23121.txt - aiogram-dialog-210: -r requirements/aiogram-dialog-210.txt - aiogram-dialog-latest: -r requirements/aiogram-dialog-latest.txt - grpcio-1641: -r requirements/grpcio-1641.txt - grpcio-1680: -r requirements/grpcio-1680.txt - grpcio-latest: -r requirements/grpcio-latest.txt - click-817: -r requirements/click-817.txt - click-latest: -r requirements/click-latest.txt - -commands = - integrations-base: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/base - aiohttp: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/aiohttp - fastapi: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/fastapi - aiogram: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations - telebot: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/telebot - flask: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/flask - litestar: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/litestar - starlette: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/starlette - faststream: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations - arq: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/arq - taskiq: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/taskiq - sanic: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/sanic - aiogram-dialog: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/aiogram_dialog - grpcio: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations - click: pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/integrations/click - -allowlist_externals = - pytest - -[testenv:unit] -deps = - -r requirements/test.txt -commands = pytest --cov=dishka --cov-append --cov-report=term-missing -v tests/unit - -[testenv:real_world_example] -deps = - -r examples/real_world/requirements_test.txt -commands = pytest --cov=dishka --cov-append --cov-report=term-missing -v examples/real_world/tests/ \ No newline at end of file From b53a9b919f16c4beb3e24c012b17e6e19f3e5098 Mon Sep 17 00:00:00 2001 From: chiri Date: Thu, 2 Jan 2025 14:43:20 +0300 Subject: [PATCH 3/9] continue drop `tox` --- .github/workflows/frameworks-latest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frameworks-latest.yml b/.github/workflows/frameworks-latest.yml index 50da0a80..2bc6bf39 100644 --- a/.github/workflows/frameworks-latest.yml +++ b/.github/workflows/frameworks-latest.yml @@ -34,5 +34,5 @@ jobs: - name: Run tests run: | - find requirements -name "*-latest.txt" -exec basename {} .txt \; | xargs -d , tox -e + find requirements -name "*-latest.txt" -exec basename {} .txt \; | sed "s/-/_/g" | xargs -d , nox -db uv -e From 6df7f2707bb0e3634efd237bf329e315bfd1d8f6 Mon Sep 17 00:00:00 2001 From: chiri Date: Thu, 2 Jan 2025 14:58:10 +0300 Subject: [PATCH 4/9] fix `frameworks-latest` workflow --- .github/workflows/frameworks-latest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frameworks-latest.yml b/.github/workflows/frameworks-latest.yml index 2bc6bf39..63ee8f6a 100644 --- a/.github/workflows/frameworks-latest.yml +++ b/.github/workflows/frameworks-latest.yml @@ -34,5 +34,5 @@ jobs: - name: Run tests run: | - find requirements -name "*-latest.txt" -exec basename {} .txt \; | sed "s/-/_/g" | xargs -d , nox -db uv -e + find requirements -name "*-latest.txt" -exec basename {} .txt \; | sed "s/-/_/g" | xargs nox -db uv -e From 1d8858ed0ca25d919c349b7d85b4d6549baf2f20 Mon Sep 17 00:00:00 2001 From: chiri Date: Tue, 7 Jan 2025 16:02:59 +0300 Subject: [PATCH 5/9] tests: add tags for `nox`: `latest` and `non-latest`, generate `nox` sessions --- .github/workflows/frameworks-latest.yml | 3 +- noxfile.py | 342 ++++++------------------ 2 files changed, 89 insertions(+), 256 deletions(-) diff --git a/.github/workflows/frameworks-latest.yml b/.github/workflows/frameworks-latest.yml index 63ee8f6a..4cb065b3 100644 --- a/.github/workflows/frameworks-latest.yml +++ b/.github/workflows/frameworks-latest.yml @@ -34,5 +34,4 @@ jobs: - name: Run tests run: | - find requirements -name "*-latest.txt" -exec basename {} .txt \; | sed "s/-/_/g" | xargs nox -db uv -e - + nox -db uv -s latest diff --git a/noxfile.py b/noxfile.py index 5c08af33..4b3b2a0a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,270 +1,104 @@ import sys +from collections.abc import Callable +from dataclasses import dataclass import nox PYTHON_3_13 = sys.version_info.minor == 13 CMD = ("pytest", "--cov=dishka", "--cov-append", "--cov-report=term-missing", "-v") -PATH = { - "aiogram_330": "requirements/aiogram-330.txt", - "aiogram_3140": "requirements/aiogram-3140.txt", - "aiogram_latest": "requirements/aiogram-latest.txt", - "aiogram_dialog_210": "requirements/aiogram-dialog-210.txt", - "aiogram_dialog_latest": "requirements/aiogram-dialog-latest.txt", - "aiohttp_393": "requirements/aiohttp-393.txt", - "aiohttp_latest": "requirements/aiohttp-latest.txt", - "arq_0250": "requirements/arq-0250.txt", - "arq_latest": "requirements/arq-latest.txt", - "click_817": "requirements/click-817.txt", - "click_latest": "requirements/click-latest.txt", - "fastapi_0096": "requirements/fastapi-0096.txt", - "fastapi_0109": "requirements/fastapi-0109.txt", - "fastapi_latest": "requirements/fastapi-latest.txt", - "faststream_047": "requirements/faststream-047.txt", - "faststream_050": "requirements/faststream-050.txt", - "faststream_0529": "requirements/faststream-0529.txt", - "faststream_latest": "requirements/faststream-latest.txt", - "flask_302": "requirements/flask-302.txt", - "flask_latest": "requirements/flask-latest.txt", - "grpcio_1641": "requirements/grpcio-1641.txt", - "grpcio_1680": "requirements/grpcio-1680.txt", - "grpcio_latest": "requirements/grpcio-latest.txt", - "litestar_230": "requirements/litestar-230.txt", - "litestar_latest": "requirements/litestar-latest.txt", - "sanic_23121": "requirements/sanic-23121.txt", - "sanic_latest": "requirements/sanic-latest.txt", - "starlette_0270": "requirements/starlette-0270.txt", - "starlette_latest": "requirements/starlette-latest.txt", - "taskiq_0110": "requirements/taskiq-0110.txt", - "taskiq_latest": "requirements/taskiq-latest.txt", - "telebot_415": "requirements/telebot-415.txt", - "telebot_latest": "requirements/telebot-latest.txt", - "unit": "requirements/test.txt", - "real_world_example": "examples/real_world/requirements_test.txt", -} - - -def install_requirements(session: nox.Session) -> None: - session.install("pytest", "pytest-cov", "-e", ".") - session.install("-r", PATH[session.name]) - - -def run_tests(session: nox.Session, path: str) -> None: - session.run(*CMD, path) - - -@nox.session(reuse_venv=True) -def aiogram_330(session: nox.Session) -> None: - if PYTHON_3_13: - session.skip("Skip tests on 3.13") - install_requirements(session) - run_tests(session, "tests/integrations/aiogram") - - -@nox.session(reuse_venv=True) -def aiogram_3140(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/aiogram") - - -@nox.session(reuse_venv=True) -def aiogram_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/aiogram") +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}" + + +INTEGRATION_ENVS = [ + IntegrationEnv("aiogram", "330", lambda: not PYTHON_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: not PYTHON_3_13), + IntegrationEnv("faststream", "050", lambda: not PYTHON_3_13), + IntegrationEnv("faststream", "0529"), + IntegrationEnv("faststream", "latest"), + IntegrationEnv("flask", "302"), + IntegrationEnv("flask", "latest"), + IntegrationEnv("grpcio", "1641", lambda: not PYTHON_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 INTEGRATION_ENVS: + @nox.session( + reuse_venv=True, + 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(reuse_venv=True) -def aiogram_dialog_210(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/aiogram_dialog") - - -@nox.session(reuse_venv=True) -def aiogram_dialog_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/aiogram_dialog") - - -@nox.session(reuse_venv=True) -def aiohttp_393(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/aiohttp") - - -@nox.session(reuse_venv=True) -def aiohttp_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/aiohttp") - - -@nox.session(reuse_venv=True) -def arq_0250(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/arq") - - -@nox.session(reuse_venv=True) -def arq_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/arq") - - -@nox.session(reuse_venv=True) -def click_817(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/click") - - -@nox.session(reuse_venv=True) -def click_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/click") - - -@nox.session(reuse_venv=True) -def fastapi_0096(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/fastapi") - - -@nox.session(reuse_venv=True) -def fastapi_0109(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/fastapi") - - -@nox.session(reuse_venv=True) -def fastapi_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/fastapi") - - -@nox.session(reuse_venv=True) -def faststream_047(session: nox.Session) -> None: - if PYTHON_3_13: - session.skip("Skip tests on 3.13") - install_requirements(session) - run_tests(session, "tests/integrations/faststream") - - -@nox.session(reuse_venv=True) -def faststream_050(session: nox.Session) -> None: - if PYTHON_3_13: - session.skip("Skip tests on 3.13") - install_requirements(session) - run_tests(session, "tests/integrations/faststream") - - -@nox.session(reuse_venv=True) -def faststream_0529(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/faststream") - - -@nox.session(reuse_venv=True) -def faststream_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/faststream") - - -@nox.session(reuse_venv=True) -def flask_302(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/flask") - - -@nox.session(reuse_venv=True) -def flask_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/flask") - - -@nox.session(reuse_venv=True) -def grpcio_1641(session: nox.Session) -> None: - if PYTHON_3_13: - session.skip("Skip tests on 3.13") - install_requirements(session) - run_tests(session, "tests/integrations/grpcio") - - -@nox.session(reuse_venv=True) -def grpcio_1680(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/grpcio") - - -@nox.session(reuse_venv=True) -def grpcio_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/grpcio") - - -@nox.session(reuse_venv=True) -def litestar_230(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/litestar") - - -@nox.session(reuse_venv=True) -def litestar_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/litestar") - - -@nox.session(reuse_venv=True) -def sanic_23121(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/sanic") - - -@nox.session(reuse_venv=True) -def sanic_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/sanic") - - -@nox.session(reuse_venv=True) -def starlette_0270(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/starlette") - - -@nox.session(reuse_venv=True) -def starlette_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/starlette") - - -@nox.session(reuse_venv=True) -def taskiq_0110(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/taskiq") - - -@nox.session(reuse_venv=True) -def taskiq_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/taskiq") - - -@nox.session(reuse_venv=True) -def telebot_415(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/telebot") +def unit(session: nox.Session) -> None: + session.install( + *INSTALL_CMD, + "-r", "requirements/test.txt", + ) + session.run(*CMD, "tests/unit") @nox.session(reuse_venv=True) -def telebot_latest(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/integrations/telebot") +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/") -@nox.session(reuse_venv=True) -def unit(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "tests/unit") +@nox.session(tags=["latest"]) +def latest(session: nox.Session) -> None: + for env in INTEGRATION_ENVS: + if env.version == "latest": + session.notify(f"{env.library}_{env.version}") -@nox.session(reuse_venv=True) -def real_world_example(session: nox.Session) -> None: - install_requirements(session) - run_tests(session, "examples/real_world/tests/") +@nox.session(tags=["non-latest"], name="non-latest") +def not_latest(session: nox.Session) -> None: + for env in INTEGRATION_ENVS: + if env.version != "latest": + session.notify(f"{env.library}_{env.version}") From 2aa6010de12c811639eb0043138146d1ecf49586 Mon Sep 17 00:00:00 2001 From: chiri Date: Tue, 7 Jan 2025 17:19:32 +0300 Subject: [PATCH 6/9] tests: add `nox` options, add tags for `unit`, `real_world` --- .github/workflows/frameworks-latest.yml | 2 +- .github/workflows/setup.yml | 2 +- noxfile.py | 26 +++++++------------------ 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/frameworks-latest.yml b/.github/workflows/frameworks-latest.yml index 4cb065b3..8fc6953c 100644 --- a/.github/workflows/frameworks-latest.yml +++ b/.github/workflows/frameworks-latest.yml @@ -34,4 +34,4 @@ jobs: - name: Run tests run: | - nox -db uv -s latest + nox -t latest diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index d628432b..5d005deb 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -46,7 +46,7 @@ jobs: - name: Run tests run: | - nox -db uv + nox -t non-latest unit real-world - name: Build doc run: | diff --git a/noxfile.py b/noxfile.py index 4b3b2a0a..c5453f02 100644 --- a/noxfile.py +++ b/noxfile.py @@ -4,6 +4,9 @@ import nox +nox.options.default_venv_backend = "uv" +nox.options.reuse_existing_virtualenvs = True + PYTHON_3_13 = sys.version_info.minor == 13 CMD = ("pytest", "--cov=dishka", "--cov-append", "--cov-report=term-missing", "-v") INSTALL_CMD = ("pytest", "pytest-cov", "-e", ".") @@ -22,7 +25,7 @@ def get_tests(self) -> str: return f"tests/integrations/{self.library}" -INTEGRATION_ENVS = [ +INTEGRATIONS = [ IntegrationEnv("aiogram", "330", lambda: not PYTHON_3_13), IntegrationEnv("aiogram", "3140"), IntegrationEnv("aiogram", "latest"), @@ -59,9 +62,8 @@ def get_tests(self) -> str: ] -for env in INTEGRATION_ENVS: +for env in INTEGRATIONS: @nox.session( - reuse_venv=True, name=f"{env.library}_{env.version}", tags=[env.library, "latest" if env.version == "latest" else "non-latest"], ) @@ -72,7 +74,7 @@ def session(session: nox.Session, env=env) -> None: session.run(*CMD, env.get_tests()) -@nox.session(reuse_venv=True) +@nox.session(tags=["unit"]) def unit(session: nox.Session) -> None: session.install( *INSTALL_CMD, @@ -81,24 +83,10 @@ def unit(session: nox.Session) -> None: session.run(*CMD, "tests/unit") -@nox.session(reuse_venv=True) +@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/") - - -@nox.session(tags=["latest"]) -def latest(session: nox.Session) -> None: - for env in INTEGRATION_ENVS: - if env.version == "latest": - session.notify(f"{env.library}_{env.version}") - - -@nox.session(tags=["non-latest"], name="non-latest") -def not_latest(session: nox.Session) -> None: - for env in INTEGRATION_ENVS: - if env.version != "latest": - session.notify(f"{env.library}_{env.version}") From 1ced7f87caecd49fd0b3b954186395e3fcbe1b59 Mon Sep 17 00:00:00 2001 From: chiri Date: Tue, 7 Jan 2025 17:26:55 +0300 Subject: [PATCH 7/9] docs: replace `tox` with `nox` on contributing page --- docs/contributing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index d3c9d178..6b161e58 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -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 From 624ce69552f27b47842a459e5e922e46382b79c6 Mon Sep 17 00:00:00 2001 From: chiri Date: Tue, 7 Jan 2025 17:44:10 +0300 Subject: [PATCH 8/9] CI: add `uv` in frameworks-latest workflow --- .github/workflows/frameworks-latest.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/frameworks-latest.yml b/.github/workflows/frameworks-latest.yml index 8fc6953c..7ca94e83 100644 --- a/.github/workflows/frameworks-latest.yml +++ b/.github/workflows/frameworks-latest.yml @@ -27,10 +27,12 @@ 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: | From 9e58ed78acaf2a3285617d7541eab57292b00dac Mon Sep 17 00:00:00 2001 From: chiri Date: Tue, 7 Jan 2025 18:46:25 +0300 Subject: [PATCH 9/9] tests: fix version check to exclude Python 3.13+ --- noxfile.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/noxfile.py b/noxfile.py index c5453f02..d2d1b7ba 100644 --- a/noxfile.py +++ b/noxfile.py @@ -7,7 +7,6 @@ nox.options.default_venv_backend = "uv" nox.options.reuse_existing_virtualenvs = True -PYTHON_3_13 = sys.version_info.minor == 13 CMD = ("pytest", "--cov=dishka", "--cov-append", "--cov-report=term-missing", "-v") INSTALL_CMD = ("pytest", "pytest-cov", "-e", ".") @@ -26,7 +25,7 @@ def get_tests(self) -> str: INTEGRATIONS = [ - IntegrationEnv("aiogram", "330", lambda: not PYTHON_3_13), + IntegrationEnv("aiogram", "330", lambda: sys.version_info < (3, 13)), IntegrationEnv("aiogram", "3140"), IntegrationEnv("aiogram", "latest"), IntegrationEnv("aiogram_dialog", "210"), @@ -40,13 +39,13 @@ def get_tests(self) -> str: IntegrationEnv("fastapi", "0096"), IntegrationEnv("fastapi", "0109"), IntegrationEnv("fastapi", "latest"), - IntegrationEnv("faststream", "047", lambda: not PYTHON_3_13), - IntegrationEnv("faststream", "050", lambda: not PYTHON_3_13), + 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: not PYTHON_3_13), + IntegrationEnv("grpcio", "1641", lambda: sys.version_info < (3, 13)), IntegrationEnv("grpcio", "1680"), IntegrationEnv("grpcio", "latest"), IntegrationEnv("litestar", "230"),