name: CI

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

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

jobs:
  test:
    name: build + test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo build --verbose
      - run: cargo test --verbose

  doc:
    name: rustdoc (builds clean)
    runs-on: ubuntu-latest
    # Intra-doc links have pre-existing breakage that gets cleaned up in
    # 0.2.0 — we run `cargo doc` to ensure the build itself works but
    # don't deny warnings yet.
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo doc --no-deps

  fmt:
    name: rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - run: cargo fmt --all --check

  # Clippy is intentionally omitted from CI for 0.1.0 — the codebase has
  # pre-existing lint debt that's tracked for a 0.2.0 cleanup pass.
