Skip to content

Commit f761def

Browse files
sdk-python: update v2 ci, worker, and tests
1 parent 2f41d4f commit f761def

3 files changed

Lines changed: 70 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
- run: pip install -e '.[dev]'
21+
- run: ruff check src/ tests/
22+
- run: mypy src/durable_workflow/
23+
24+
test:
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
python-version: ["3.10", "3.11", "3.12"]
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
- run: pip install -e '.[dev]'
35+
- run: pytest tests/ -m "not integration" -q
36+
37+
integration:
38+
runs-on: ubuntu-latest
39+
needs: [lint, test]
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
path: sdk-python
44+
- uses: actions/checkout@v4
45+
with:
46+
repository: durable-workflow/server
47+
path: server
48+
- uses: actions/setup-python@v5
49+
with:
50+
python-version: "3.12"
51+
- run: pip install -e '.[dev]'
52+
working-directory: sdk-python
53+
- name: Start server stack
54+
working-directory: sdk-python
55+
run: |
56+
docker compose -f docker-compose.test.yml up -d --wait --timeout 120
57+
- name: Run integration tests
58+
working-directory: sdk-python
59+
env:
60+
DURABLE_WORKFLOW_SERVER_URL: http://localhost:8080
61+
DURABLE_WORKFLOW_AUTH_TOKEN: test-token
62+
run: pytest tests/integration/ -v
63+
- name: Teardown
64+
if: always()
65+
working-directory: sdk-python
66+
run: docker compose -f docker-compose.test.yml down -v

src/durable_workflow/worker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import asyncio
4+
import contextlib
45
import logging
56
import traceback
67
import uuid
@@ -295,10 +296,8 @@ async def run(self) -> None:
295296
await self._register()
296297
wf_loop = asyncio.create_task(self._poll_workflow_tasks())
297298
act_loop = asyncio.create_task(self._poll_activity_tasks())
298-
try:
299+
with contextlib.suppress(asyncio.CancelledError):
299300
await asyncio.gather(wf_loop, act_loop)
300-
except asyncio.CancelledError:
301-
pass
302301

303302
async def stop(self) -> None:
304303
self._stop.set()

tests/test_worker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import asyncio
4+
import contextlib
45
from unittest.mock import AsyncMock
56

67
import pytest
@@ -384,10 +385,8 @@ async def test_run_starts_both_loops(self, mock_client: AsyncMock) -> None:
384385
await asyncio.sleep(0.05)
385386
await worker.stop()
386387
run_task.cancel()
387-
try:
388+
with contextlib.suppress(asyncio.CancelledError):
388389
await run_task
389-
except asyncio.CancelledError:
390-
pass
391390
assert mock_client.register_worker.call_count == 1
392391
assert mock_client.poll_workflow_task.call_count >= 1
393392
assert mock_client.poll_activity_task.call_count >= 1

0 commit comments

Comments
 (0)