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
27 changes: 27 additions & 0 deletions .github/workflows/merge-gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Merge Gate - Full Tests

on:
merge_group: {}

jobs:
full-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4

- name: Install uv and set Python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: make init

- name: Run ALL tests
run: make test
32 changes: 32 additions & 0 deletions .github/workflows/post-merge-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Post-Merge Coverage

on:
push:
branches:
- main

jobs:
coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install uv and set Python version
uses: astral-sh/setup-uv@v7
with:
python-version: "3.14"

- name: Install dependencies
run: make init

- name: Run ALL tests with coverage
run: make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: full
fail_ci_if_error: true
29 changes: 29 additions & 0 deletions .github/workflows/pr-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: PR Unit Tests

on:
pull_request:
types:
- opened
- synchronize

jobs:
unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4

- name: Install uv and set Python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: make init

- name: Run unit tests and linting
run: make test-unit
54 changes: 0 additions & 54 deletions .github/workflows/test.yml

This file was deleted.

10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ test: lint
uv run pytest -vv

test-fast: lint
uv run pytest -vv -m "not slow"
uv run pytest -vv -m "not slow and not integration"

test-slow: lint
uv run pytest -vv -m "slow"
uv run pytest -vv -n auto -m "slow"

test-unit: lint
uv run pytest -vv -n auto -m "not integration"

test-integration: lint
uv run pytest -vv -m "integration"
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ dev = [
"pytest>=9.0.2",
"pytest-asyncio>=1.3.0",
"pytest-coverage>=0.0",
"pytest-xdist>=3.8.0",
"ruff>=0.14.9",
"ty>=0.0.5",
]
Expand All @@ -97,7 +98,8 @@ python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')"
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"integration: marks tests as integration tests (deselect with '-m \"not integration\"')"
]
addopts = [
"--strict-markers",
Expand Down
20 changes: 11 additions & 9 deletions src/chicory/backend/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,31 @@ def __init__(self, config: RedisBackendConfig) -> None:

async def connect(self) -> None:
self._pool = redis.ConnectionPool.from_url(self.dsn)
self._client = redis.Redis(
connection_pool=self._pool, auto_close_connection_pool=False
)
self._client = redis.Redis(connection_pool=self._pool)
await self._client.ping() # ty:ignore[invalid-await]

async def disconnect(self) -> None:
if self._client:
await self._client.close()
await self._client.aclose()
self._client = None
if self._pool:
await self._pool.disconnect()
await self._pool.aclose()
self._pool = None

def _state_key(self, task_id: str) -> str:
@staticmethod
def _state_key(task_id: str) -> str:
return f"chicory:state:{task_id}"

def _result_key(self, task_id: str) -> str:
@staticmethod
def _result_key(task_id: str) -> str:
return f"chicory:result:{task_id}"

def _heartbeat_key(self, worker_id: str) -> str:
@staticmethod
def _heartbeat_key(worker_id: str) -> str:
return f"chicory:heartbeat:{worker_id}"

def _workers_set_key(self) -> str:
@staticmethod
def _workers_set_key() -> str:
"""Key for tracking all worker IDs."""
return "chicory:workers"

Expand Down
5 changes: 5 additions & 0 deletions src/chicory/broker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ async def delete_from_dlq(
"""Permanently delete a message from the DLQ."""
...

@abstractmethod
async def purge_dlq(self, queue: str = DEFAULT_QUEUE) -> int:
"""Delete all messages from the DLQ. Returns count deleted."""
...

@abstractmethod
async def get_dlq_count(self, queue: str = DEFAULT_QUEUE) -> int:
"""Get the number of messages in the Dead Letter Queue."""
Expand Down
Loading