name: Rusty Pipeline 

on:
  push:
    branches: [main, develop]
    paths:
      - "**/*.rs"
      - "Cargo.toml"
      - "Cargo.lock"
      - ".github/workflows/**"
  pull_request:
    paths:
      - "**/*.rs"
      - "Cargo.toml"
      - "Cargo.lock"
      - ".github/workflows/**"

jobs:
  rust-ci-suite:
    name: Run Rust checks and tests
    runs-on: ubuntu-slim
    steps:
      - name: Checkout sources
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt

      - name: Cache cargo directories
        uses: Swatinem/rust-cache@v2

      - name: Format check
        run: cargo fmt --all -- --check

      - name: Clippy
        run: cargo clippy --all-targets --all-features --locked -- -D warnings

      - name: Tests
        run: cargo test --all-features --locked
