Skip to content
Open
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
98 changes: 98 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Integration

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
# Integration suite against a real Redis server (tests marked "integration").
integration:
runs-on: ubuntu-latest
# A hung task would otherwise block stop() (no shutdown timeout) for hours.
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# Oldest and newest supported Python versions.
python-version: ["3.10", "3.14"]

services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 2s
--health-timeout 3s
--health-retries 15

env:
REDIS_URL: redis://localhost:6379/15
# Fail instead of skipping when the Redis service is not reachable.
REDIS_REQUIRED: "1"

steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
persist-credentials: false

- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --python ${{ matrix.python-version }}

- name: Run integration tests
run: uv run --python ${{ matrix.python-version }} pytest -m integration -v

# Unit and integration suites with the lowest versions allowed by the
# declared dependency ranges, to catch lower bounds that are too loose.
lowest-direct:
runs-on: ubuntu-latest
timeout-minutes: 15

services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 2s
--health-timeout 3s
--health-retries 15

env:
REDIS_URL: redis://localhost:6379/15
REDIS_REQUIRED: "1"
UV_RESOLUTION: lowest-direct

steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
persist-credentials: false

- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0

- name: Set up Python 3.10
run: uv python install 3.10

- name: Install lowest direct dependencies
# Re-resolves the lock with the lowest allowed versions (not committed).
run: uv sync --python 3.10

- name: Run unit tests
run: uv run --python 3.10 pytest

- name: Run integration tests
run: uv run --python 3.10 pytest -m integration
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ With coverage:
uv run coverage run -m pytest && uv run coverage report
```

The default run uses mocked Redis only and does not need a Redis server. Any warning raised during the tests fails the run.

### Running Integration Tests

The tests in `tests/integration/` run one or more `TaskManager` instances against a real Redis server. They carry the `integration` marker and are deselected by default.

1. Start a throwaway Redis server on a free port, without persistence:
```bash
redis-server --port 6399 --save "" --appendonly no --daemonize yes
```
2. Point the tests at it with `REDIS_URL` (default: `redis://localhost:6379/15`) and select the marker:
```bash
REDIS_URL=redis://localhost:6399/0 uv run pytest -m integration
```
3. Stop the server when you are done:
```bash
redis-cli -p 6399 shutdown nosave
```

If Redis does not answer, the integration tests are skipped (set `REDIS_REQUIRED=1` to make them fail instead, as CI does). Each test uses its own random key prefix and deletes only its own keys at the end: the database is never flushed.

Tests marked `xfail(strict=True)` in `tests/integration/test_known_bugs.py` describe known bugs: they assert the correct behaviour and fail today. When a fix makes one pass, pytest reports it as `XPASS(strict)` and the run fails: remove the marker in the same change, so the scenario becomes a regression test.

### Code Quality

The project uses pre-commit hooks that run automatically on `git commit`. You can also run them manually:
Expand Down
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,20 @@ max-args = 8

[tool.pytest.ini_options]
asyncio_mode = "auto"
# Integration tests need a real Redis server: they are deselected by default and
# run with `pytest -m integration` (the last -m on the command line wins).
addopts = "-m 'not integration'"
markers = [
"integration: tests that run against a real Redis server (REDIS_URL, default redis://localhost:6379/15)",
]
# Any warning raised during the tests is an error.
filterwarnings = [
"error",
# Python 3.14 deprecates asyncio.iscoroutinefunction, still used by the
# stream consumer: remove this entry once it switches to inspect.iscoroutinefunction.
"ignore:'asyncio.iscoroutinefunction' is deprecated:DeprecationWarning",
]

[tool.coverage.run]
# The integration suite is deselected in the default (coverage) run.
omit = ["tests/integration/*"]
Empty file added tests/integration/__init__.py
Empty file.
Loading
Loading