Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ name: Testing

on:
pull_request:
branches: [develop]
branches: [develop, main]

jobs:
run-tests:
runs-on: ubuntu-latest

run-unit-tests:
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -25,11 +26,40 @@ jobs:
- name: Setup uv
uses: astral-sh/setup-uv@v7

- name: Create virtual environment
run: uv venv .venv && source .venv/bin/activate
# - name: Create virtual environment
# run: uv venv .venv && source .venv/bin/activate

- name: Install modules
run: uv sync

- name: Run tests for Python ${{ matrix.python-version }}
run: uv run pytest
- name: Run unit tests for Python ${{ matrix.python-version }}
run: uv run pytest tests/unit

run-integration-tests:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Setup uv
uses: astral-sh/setup-uv@v7

- name: Install modules
run: uv sync --extra redis --extra aiopika

- name: Setup Docker containers
run: docker compose -f ./docker-compose-tests.yml up --wait

- name: Run integration tests for Python ${{ matrix.python-version }}
run: uv run pytest tests/integration
20 changes: 20 additions & 0 deletions docker-compose-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
redis:
image: redis:latest
ports:
- "6379:6379"

rabbitmq:
image: rabbitmq:latest
environment:
- RABBITMQ_DEFAULT_USER=guest
- RABBITMQ_DEFAULT_PASSWORD=guest
hostname: localhost
ports:
- "5672:5672"
healthcheck:
test: "rabbitmq-diagnostics check_running -q"
interval: 5s
timeout: 5s
retries: 10
start_period: 5s
2 changes: 1 addition & 1 deletion examples/counter/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio

from taskiq_redis import PubSubBroker, RedisAsyncResultBackend
from taskiq_cancellation.integrations.redis import RedisCancellationBackend
from taskiq_cancellation.backends.redis import RedisCancellationBackend


url = "redis://localhost"
Expand Down
21 changes: 17 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = ["taskiq", "typing-extensions>=4.13.2"]
dependencies = [
"async-timeout>=5.0.1 ; python_full_version < '3.11'",
"taskiq",
"typing-extensions>=4.15.0 ; python_full_version < '3.11'",
]

[project.optional-dependencies]
redis = ["redis~=3.0"]
redis = ["redis~=6.0"]
aiopika = ["aio_pika"]

[project.urls]
Expand All @@ -44,8 +48,12 @@ check = "mypy --install-types --non-interactive {args:src/taskiq_cancellation te

[tool.mypy]
ignore_missing_imports = true
exclude = ["examples"]

exclude = [
# Added so that "mypy ." would work
"examples",
# Contains Python 3.11+ code, has to be excluded. Runtime checks don't work.
"src/taskiq_cancellation/cancellation_handlers/edge_3_11.py",
]

[tool.coverage.run]
source_pkgs = ["taskiq_cancellation", "tests"]
Expand All @@ -70,3 +78,8 @@ dev = [
"pytest-asyncio>=0.24.0",
"ruff>=0.14.4",
]

[tool.ruff]
# Edge cancellation is currently Python 3.11+ which causes linter to freak out
# For such versioning cases tests must be written
target-version = "py314"
5 changes: 1 addition & 4 deletions src/taskiq_cancellation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
from .backends.modular import ModularCancellationBackend


__all__ = [
"CancellationBackend",
"ModularCancellationBackend"
]
__all__ = ["CancellationBackend", "ModularCancellationBackend"]
8 changes: 7 additions & 1 deletion src/taskiq_cancellation/abc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from .backend import CancellationBackend
from .notifier import CancellationNotifier
from .state_holder import CancellationStateHolder
from .started_listening_event import StartedListeningEvent


__all__ = ["CancellationBackend", "CancellationNotifier", "CancellationStateHolder"]
__all__ = [
"CancellationBackend",
"CancellationNotifier",
"CancellationStateHolder",
"StartedListeningEvent",
]
Loading