Skip to content

Commit e097c49

Browse files
committed
Add test timeouts and cleanup to CI/CD workflows with pytest-timeout.
1 parent 2a2f78f commit e097c49

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ on:
77
branches: [ main, master ]
88

99
jobs:
10+
# Run tests in parallel for speed - each job gets its own isolated container
1011
frontend-tests:
1112
runs-on: ubuntu-latest
13+
timeout-minutes: 10
1214
steps:
1315
- uses: actions/checkout@v4
1416
- name: Set up Node.js
@@ -24,40 +26,55 @@ jobs:
2426

2527
backend-tests:
2628
runs-on: ubuntu-latest
29+
timeout-minutes: 10
2730
steps:
2831
- uses: actions/checkout@v4
2932
- name: Install uv
3033
uses: astral-sh/setup-uv@v5
3134
with:
3235
enable-cache: true
33-
cache-dependency-path: server/uv.lock
36+
cache-dependency-glob: server/uv.lock
3437
- name: Set up Python
3538
run: uv python install
3639
- name: Install dependencies
3740
run: cd server && uv sync
3841
- name: Run backend tests
3942
run: |
4043
cd server
41-
PYTHONPATH=. uv run pytest
44+
PYTHONPATH=. uv run pytest --timeout=300
45+
# Safety cleanup - runs even if tests fail
46+
- name: Cleanup processes
47+
if: always()
48+
run: |
49+
pkill -f "pytest" || true
50+
pkill -f "uvicorn" || true
4251
4352
integration-tests:
4453
runs-on: ubuntu-latest
54+
timeout-minutes: 10
4555
steps:
4656
- uses: actions/checkout@v4
4757
- name: Install uv
4858
uses: astral-sh/setup-uv@v5
4959
with:
5060
enable-cache: true
51-
cache-dependency-path: server/uv.lock
61+
cache-dependency-glob: server/uv.lock
5262
- name: Set up Python
5363
run: uv python install
5464
- name: Install dependencies
5565
run: cd server && uv sync
5666
- name: Run integration tests
5767
run: |
5868
cd server
59-
PYTHONPATH=. uv run pytest tests_integration
69+
PYTHONPATH=. uv run pytest tests_integration --timeout=300
70+
# Safety cleanup - runs even if tests fail
71+
- name: Cleanup processes
72+
if: always()
73+
run: |
74+
pkill -f "pytest" || true
75+
pkill -f "uvicorn" || true
6076
77+
# Deploy only runs after ALL tests pass (sequential dependency)
6178
deploy:
6279
needs: [frontend-tests, backend-tests, integration-tests]
6380
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')

server/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies = [
2121
"sqlalchemy>=2.0.45",
2222
"uvicorn>=0.40.0",
2323
"pytest-asyncio>=0.23.5",
24+
"pytest-timeout>=2.3.1",
2425
"aiohttp>=3.13.2",
2526
"aiosqlite>=0.22.1",
2627
]

server/uv.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)