name: CI

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Check formatting
        run: cargo fmt --check --all

      - name: Clippy
        run: cargo clippy --workspace --all-targets -- -D clippy::correctness

      - name: Build
        run: cargo build --workspace

      - name: Test
        run: cargo test --workspace

  msrv:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@1.82.0
      - uses: Swatinem/rust-cache@v2

      # Note: lattix-kge depends on candle which requires Rust 1.80+ (rayon 1.11)
      # MSRV check only tests core crates
      - name: Check MSRV
        run: |
          rm -f Cargo.lock  # v4 lock file requires Cargo 1.83+
          cargo check -p lattix-core
          cargo check -p lattix-temporal
