Rust + CI etc #191
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Install uv (fast Python + package manager) and enable caching | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v3 | |
| # Cache uv tool + resolver cache (speeds up uvx + resolves) | |
| - name: Cache uv caches | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/uv | |
| key: uv-cache-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'uv.lock') }} | |
| # Style checks via uvx (no env creation needed, blazing fast) | |
| - name: black (s2and/) | |
| run: uvx --from black==24.8.0 black s2and --check --line-length 120 | |
| - name: black (scripts/*.py) | |
| shell: bash | |
| run: | | |
| shopt -s nullglob | |
| files=(scripts/*.py) | |
| if (( ${#files[@]} )); then | |
| uvx --from black==24.8.0 black "${files[@]}" --check --line-length 120 | |
| fi | |
| typecheck-and-test: | |
| runs-on: ubuntu-latest | |
| needs: [lint] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| s2and_rust/target | |
| key: cargo-${{ runner.os }}-${{ hashFiles('s2and_rust/Cargo.lock') }} | |
| restore-keys: | | |
| cargo-${{ runner.os }}- | |
| # Optional: ensure a specific Python (uv can also manage this on its own) | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| # Cache uv resolver + wheels + project venv | |
| - name: Cache uv + venv | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/uv | |
| .venv | |
| key: uv-venv-${{ runner.os }}-py311-${{ hashFiles('pyproject.toml', 'uv.lock') }} | |
| restore-keys: | | |
| uv-venv-${{ runner.os }}-py311- | |
| uv-venv- | |
| # Sync environment from lock if present (fast; no network if cached) | |
| - name: Sync deps (locked if available) | |
| shell: bash | |
| run: | | |
| if [[ -f uv.lock ]]; then | |
| uv sync --extra dev --frozen | |
| else | |
| # No lock present; resolve once, then install | |
| uv sync --extra dev | |
| fi | |
| # Build/install Rust extension for parity tests | |
| - name: Build Rust extension | |
| run: uvx --from maturin maturin develop -m s2and_rust/Cargo.toml | |
| # Type checking (run mypy commands directly) | |
| - name: mypy (s2and) | |
| run: uv run --no-project mypy s2and --ignore-missing-imports | |
| - name: mypy (scripts) | |
| run: uv run --no-project mypy scripts/*.py --ignore-missing-imports | |
| # Single pytest run with coverage (replaces the two docker pytest calls) | |
| - name: pytest (coverage) | |
| env: | |
| # keep startup lean; avoid user-level plugins on hosted runners | |
| PYTHONPATH: . | |
| run: | | |
| uv run --no-project pytest tests/ \ | |
| --cov=s2and --cov-report=term-missing --cov-fail-under=40 | |