name: CI

on:
  # Skip doc-only changes (Markdown anywhere) — no need to run fmt/clippy/build/test
  # when nothing compilable changed. A commit touching any non-.md file still runs.
  push:
    branches: [master]
    paths-ignore:
      - '**.md'
  pull_request:
    paths-ignore:
      - '**.md'

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-D warnings"

jobs:
  check:
    name: fmt · clippy · build · test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

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

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

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

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

      - name: Clippy (no default features)
        run: cargo clippy --all-targets --no-default-features -- -D warnings

      - name: Build
        run: cargo build --all-features --verbose

      - name: Build (no default features)
        run: cargo build --no-default-features --verbose

      - name: Test
        run: cargo test --all-features --verbose

      - name: Test (no default features)
        run: cargo test --no-default-features --verbose

  msrv:
    name: MSRV (1.88)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      # Floor is set by `let`-chains (stable since Rust 1.88), used throughout.
      # Keep this in sync with `rust-version` in Cargo.toml.
      - name: Install MSRV toolchain
        uses: dtolnay/rust-toolchain@1.88.0

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

      - name: Check (all features, locked)
        run: cargo check --all-features --locked
