@@ -2,21 +2,92 @@ name: CI
22
33on :
44 pull_request :
5- branches :
6- - main
5+ branches : [main]
6+
7+ concurrency :
8+ group : ${{ github.workflow }}-${{ github.ref }}
9+ cancel-in-progress : true
710
811jobs :
9- build :
12+ lint :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - uses : actions/checkout@v4
16+
17+ # Install uv (fast Python + package manager) and enable caching
18+ - name : Setup uv
19+ uses : astral-sh/setup-uv@v3
1020
21+ # Cache uv tool + resolver cache (speeds up uvx + resolves)
22+ - name : Cache uv caches
23+ uses : actions/cache@v4
24+ with :
25+ path : |
26+ ~/.cache/uv
27+ key : uv-cache-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}
28+
29+ # Style checks via uvx (no env creation needed, blazing fast)
30+ - name : black (s2and/)
31+ run : uvx --from black==24.8.0 black s2and --check --line-length 120
32+ - name : black (scripts/*.py)
33+ shell : bash
34+ run : |
35+ shopt -s nullglob
36+ files=(scripts/*.py)
37+ if (( ${#files[@]} )); then
38+ uvx --from black==24.8.0 black "${files[@]}" --check --line-length 120
39+ fi
40+
41+ typecheck-and-test :
1142 runs-on : ubuntu-latest
12-
43+ needs : [lint]
1344 steps :
14- - uses : actions/checkout@v1
15- - name : Build and test with Docker
16- run : |
17- docker build --tag s2and .
18- docker run --rm s2and pytest tests/ --verbose
19- docker run --rm s2and black s2and --check --line-length 120
20- docker run --rm s2and black scripts/*.py --check --line-length 120
21- docker run --rm s2and bash scripts/mypy.sh
22- docker run --rm s2and pytest tests/ --cov s2and --cov-fail-under=40
45+ - uses : actions/checkout@v4
46+
47+ - name : Setup uv
48+ uses : astral-sh/setup-uv@v3
49+
50+ # Optional: ensure a specific Python (uv can also manage this on its own)
51+ - name : Setup Python
52+ uses : actions/setup-python@v5
53+ with :
54+ python-version : ' 3.11'
55+
56+ # Cache uv resolver + wheels + project venv
57+ - name : Cache uv + venv
58+ uses : actions/cache@v4
59+ with :
60+ path : |
61+ ~/.cache/uv
62+ .venv
63+ key : uv-venv-${{ runner.os }}-py311-${{ hashFiles('pyproject.toml', 'uv.lock') }}
64+ restore-keys : |
65+ uv-venv-${{ runner.os }}-py311-
66+ uv-venv-
67+
68+ # Sync environment from lock if present (fast; no network if cached)
69+ - name : Sync deps (locked if available)
70+ shell : bash
71+ run : |
72+ if [[ -f uv.lock ]]; then
73+ uv sync --all-extras --dev --frozen
74+ else
75+ # No lock present; resolve once, then install
76+ uv sync --all-extras --dev
77+ fi
78+
79+ # Type checking (run mypy commands directly)
80+ - name : mypy (s2and)
81+ run : uv run mypy s2and --ignore-missing-imports
82+ - name : mypy (scripts)
83+ run : uv run mypy scripts/*.py --ignore-missing-imports
84+
85+ # Single pytest run with coverage (replaces the two docker pytest calls)
86+ - name : pytest (coverage)
87+ env :
88+ # keep startup lean; avoid user-level plugins on hosted runners
89+ PYTHONPATH : .
90+ run : |
91+ uv run pytest tests/ \
92+ --cov=s2and --cov-report=term-missing --cov-fail-under=40
93+
0 commit comments