Skip to content

Commit 55908c0

Browse files
committed
CI for main + system tests
1 parent 49aa42a commit 55908c0

File tree

9 files changed

+452
-73
lines changed

9 files changed

+452
-73
lines changed

.github/workflows/ci-develop.yml

Lines changed: 21 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,51 @@
1-
name: CI – Develop Branch
2-
3-
4-
# Triggers
5-
# --------
6-
# • pull_request → quick job (lint + type-check + unit tests)
7-
# • push → full job (quick job + DB migrations + integration tests +
8-
# Docker build & smoke test)
1+
name: CI – Main Branch (Single Job, System Required)
92

103
on:
114
pull_request:
12-
branches: [develop]
13-
push:
14-
branches: [develop]
5+
branches: [main]
6+
workflow_dispatch:
157

8+
concurrency:
9+
group: ci-main-${{ github.ref }}
10+
cancel-in-progress: true
1611

17-
# Job 1 ─ Quick validation (executed only on pull_request events)
18-
# --------------------------------------------------------------------------- #
19-
# Runs fast checks that give reviewers immediate feedback. No external
20-
# services or Docker are used to keep runtime under one minute.
12+
env:
13+
PYTHON_VERSION: "3.12"
14+
MPLBACKEND: Agg
15+
ASYNCFLOW_RUN_SYSTEM_TESTS: "1"
2116

2217
jobs:
23-
quick:
24-
if: github.event_name == 'pull_request'
18+
all-checks:
2519
runs-on: ubuntu-latest
20+
timeout-minutes: 25
2621

2722
steps:
28-
# Checkout repository
29-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
3024

31-
# Install Python 3.12
32-
- uses: actions/setup-python@v4
25+
- uses: actions/setup-python@v5
3326
with:
34-
python-version: "3.12"
27+
python-version: ${{ env.PYTHON_VERSION }}
28+
cache: 'pip'
3529

36-
# Restore Poetry cache for faster installs
3730
- uses: actions/cache@v3
3831
with:
3932
path: ~/.cache/pypoetry
4033
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
4134

42-
# Install project + development dependencies
43-
- name: Install dependencies
35+
- name: Install Poetry & deps
4436
run: |
4537
curl -sSL https://install.python-poetry.org | python3 -
38+
export PATH="$HOME/.local/bin:$PATH"
4639
poetry config virtualenvs.create false
4740
poetry install --with dev --no-interaction
4841
49-
# Code quality gates
50-
- name: Run Ruff (lint & formatting check)
42+
- name: Ruff (lint)
5143
run: poetry run ruff check src tests
5244

53-
- name: Run MyPy (type-check)
45+
- name: MyPy (type-check)
5446
run: poetry run mypy src tests
55-
56-
# Unit-tests only (exclude integration markers)
57-
- name: Run unit tests
58-
env:
59-
ENVIRONMENT: test
60-
run: poetry run pytest -m "not integration" --disable-warnings
61-
62-
63-
64-
# Job 2 ─ Full validation (executed only on push events)
65-
full:
66-
if: |
67-
github.event_name == 'push' &&
68-
github.ref == 'refs/heads/develop'
69-
runs-on: ubuntu-latest
70-
71-
steps:
72-
- uses: actions/checkout@v3
73-
- uses: actions/setup-python@v4
74-
with: { python-version: '3.12' }
75-
- uses: actions/cache@v3
76-
with:
77-
path: ~/.cache/pypoetry
78-
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
7947

80-
- name: Install dependencies
81-
run: |
82-
curl -sSL https://install.python-poetry.org | python3 -
83-
poetry config virtualenvs.create false
84-
poetry install --with dev --no-interaction
85-
86-
- name: Run Ruff
87-
run: poetry run ruff check src tests
88-
89-
- name: Run mypy
90-
run: poetry run mypy src
91-
92-
- name: Run all tests
48+
- name: All tests (unit + integration + system)
9349
run: |
9450
poetry run pytest \
95-
--cov=src --cov-report=term \
9651
--disable-warnings
97-
98-
99-
100-

.github/workflows/ci-main.yml

Whitespace-only changes.

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ bash scripts/quality_check.sh
248248

249249
Runs **ruff** (lint/format check) and **mypy** on `src` and `tests`.
250250

251-
#### 2) Run tests with coverage
251+
#### 2) Run tests with coverage (unit + integration)
252252

253253
**Linux / macOS / WSL**
254254

@@ -262,6 +262,20 @@ bash scripts/run_tests.sh
262262
.\scripts\run_tests.ps1
263263
```
264264

265+
#### 3) Run system tests
266+
267+
**Linux / macOS / WSL**
268+
269+
```bash
270+
bash scripts/run_sys_tests.sh
271+
```
272+
273+
**Windows (PowerShell)**
274+
275+
```powershell
276+
.\scripts\run_sys_tests.ps1
277+
```
278+
265279
Executes **pytest** with a terminal coverage summary (no XML, no slowest list).
266280

267281

pytest.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
addopts = -ra -q
33
testpaths = tests
44
markers =
5-
integration: tests that require external services (database, HTTP calls, etc.)
6-
asyncio_mode = auto
5+
integration: tests that require components interactions
6+
system: end-to-end/system scenarios
7+
asyncio_mode = auto

scripts/run_sys_tests.ps1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Run only system tests (marked @pytest.mark.system) with the required env var.
2+
# Keeps output concise (no XML, no slowest list), shows the usual pytest summary.
3+
#
4+
# Usage:
5+
# .\scripts\run_system_tests.ps1
6+
#
7+
# Notes:
8+
# - Uses `poetry run` when Poetry + pyproject.toml are present; otherwise falls back to `pytest`.
9+
# - Forces a headless backend for any plots generated during tests.
10+
11+
Set-StrictMode -Version Latest
12+
$ErrorActionPreference = 'Stop'
13+
14+
# Resolve repo root
15+
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
16+
$RepoRoot = Resolve-Path (Join-Path $ScriptDir '..')
17+
18+
# Collect test paths (default: tests/system)
19+
if ($args.Count -ge 1) {
20+
$TestPaths = $args
21+
} else {
22+
$TestPaths = @('tests/system')
23+
}
24+
25+
# Decide runner prefix
26+
$UsePoetry = (Get-Command poetry -ErrorAction SilentlyContinue) -ne $null -and
27+
(Test-Path (Join-Path $RepoRoot 'pyproject.toml'))
28+
$Runner = if ($UsePoetry) { 'poetry run pytest' } else { 'pytest' }
29+
30+
# Set env vars for this process
31+
$env:MPLBACKEND = if ($env:MPLBACKEND) { $env:MPLBACKEND } else { 'Agg' }
32+
$env:ASYNCFLOW_RUN_SYSTEM_TESTS = '1'
33+
34+
Push-Location $RepoRoot
35+
try {
36+
Write-Host "==> Running system tests…"
37+
# Clear any configured addopts and run only system-marked tests
38+
$pytestArgs = @(
39+
'-o', 'addopts=',
40+
'-m', 'system',
41+
'--disable-warnings',
42+
'-q'
43+
) + $TestPaths
44+
45+
if ($UsePoetry) {
46+
poetry run pytest @pytestArgs
47+
} else {
48+
pytest @pytestArgs
49+
}
50+
51+
Write-Host "✅ System tests PASSED"
52+
}
53+
finally {
54+
Pop-Location
55+
}

scripts/run_sys_tests.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Run only system tests (marked @pytest.mark.system) with the required env var.
2+
# Keeps output concise (no XML, no slowest list), shows the usual pytest summary.
3+
#
4+
# Usage:
5+
# bash scripts/run_system_tests.sh
6+
#
7+
# Notes:
8+
# - Uses `poetry run` when Poetry + pyproject.toml are present; otherwise falls back to `pytest`.
9+
# - Forces a headless backend for any plots generated during tests.
10+
11+
set -Eeuo pipefail
12+
13+
# Pick test paths (default to tests/system)
14+
if [[ $# -ge 1 ]]; then
15+
TEST_PATHS=("$@")
16+
else
17+
TEST_PATHS=(tests/system)
18+
fi
19+
20+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
21+
RUN_PREFIX=""
22+
if command -v poetry >/dev/null 2>&1 && [[ -f "$REPO_ROOT/pyproject.toml" ]]; then
23+
RUN_PREFIX="poetry run"
24+
fi
25+
26+
# Headless plotting; enable system tests
27+
export MPLBACKEND="${MPLBACKEND:-Agg}"
28+
export ASYNCFLOW_RUN_SYSTEM_TESTS=1
29+
30+
cd "$REPO_ROOT"
31+
32+
echo "==> Running system tests…"
33+
# Clear any configured addopts and run only system-marked tests
34+
# Keep output short but with the final summary line.
35+
$RUN_PREFIX pytest \
36+
-o addopts= \
37+
-m system \
38+
--disable-warnings \
39+
-q \
40+
"${TEST_PATHS[@]}"
41+
42+
echo "✅ System tests PASSED"

tests/integration/single_server/test_single_server.py renamed to tests/integration/single_server/test_int_single_server.py

File renamed without changes.

0 commit comments

Comments
 (0)