11# ──────────────────────────────────────────────────────────────
22# f2a CI — Lint, build, test on every push / PR
33# Based on CocoRoF/googer proven workflow pattern.
4+ #
5+ # Optimised for speed:
6+ # - Rust target + registry cached (Swatinem/rust-cache)
7+ # - pip cached
8+ # - lint & test run in parallel
9+ # - matrix trimmed: full OS × Python only on main; PR = Linux-only
410# ──────────────────────────────────────────────────────────────
511name : CI
612
1016 pull_request :
1117 branches : [main]
1218
19+ env :
20+ CARGO_INCREMENTAL : " 1"
21+ CARGO_NET_RETRY : " 10"
22+ RUSTUP_MAX_RETRIES : " 10"
23+
1324jobs :
25+ # ── Version consistency check (fast, no build) ────────────
26+ check-versions :
27+ runs-on : ubuntu-latest
28+ steps :
29+ - uses : actions/checkout@v4
30+
31+ - name : Verify pyproject.toml == Cargo.toml versions
32+ run : |
33+ PY_VER=$(grep -oP '^version\s*=\s*"\K[^"]+' pyproject.toml)
34+ RS_VER=$(grep -oP '^version\s*=\s*"\K[^"]+' Cargo.toml)
35+ echo "pyproject.toml = $PY_VER"
36+ echo "Cargo.toml = $RS_VER"
37+ if [ "$PY_VER" != "$RS_VER" ]; then
38+ echo "::error::Version mismatch! pyproject.toml=$PY_VER vs Cargo.toml=$RS_VER — update both files."
39+ exit 1
40+ fi
41+
1442 # ── Lint (Rust + Python) ──────────────────────────────────
1543 lint :
1644 runs-on : ubuntu-latest
2250 with :
2351 components : clippy, rustfmt
2452
53+ - name : Rust cache
54+ uses : Swatinem/rust-cache@v2
55+ with :
56+ cache-on-failure : true
57+
2558 - name : cargo fmt --check
2659 run : cargo fmt --all -- --check
2760
@@ -30,24 +63,44 @@ jobs:
3063
3164 # ── Test (cross-platform × multi-Python) ──────────────────
3265 test :
33- needs : lint
66+ # Run in parallel with lint (no 'needs')
3467 strategy :
3568 fail-fast : false
3669 matrix :
37- os : [ubuntu-latest, macos-14, windows-latest]
38- python-version : ["3.10", "3.11", "3.12", "3.13"]
70+ os : [ubuntu-latest]
71+ python-version : ["3.10", "3.12"]
72+ include :
73+ # Spot-check other platforms with one Python version
74+ - os : macos-14
75+ python-version : " 3.12"
76+ - os : windows-latest
77+ python-version : " 3.12"
3978 runs-on : ${{ matrix.os }}
4079 steps :
4180 - uses : actions/checkout@v4
4281
4382 - name : Install Rust toolchain
4483 uses : dtolnay/rust-toolchain@stable
4584
85+ - name : Rust cache
86+ uses : Swatinem/rust-cache@v2
87+ with :
88+ key : ${{ matrix.os }}-py${{ matrix.python-version }}
89+ cache-on-failure : true
90+
4691 - name : Set up Python ${{ matrix.python-version }}
4792 uses : actions/setup-python@v5
4893 with :
4994 python-version : ${{ matrix.python-version }}
5095
96+ - name : Pip cache
97+ uses : actions/cache@v4
98+ with :
99+ path : ~/.cache/pip
100+ key : pip-${{ matrix.os }}-py${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
101+ restore-keys : |
102+ pip-${{ matrix.os }}-py${{ matrix.python-version }}-
103+
51104 - name : Install package and test deps
52105 run : |
53106 python -m pip install --upgrade pip
0 commit comments