name: rust-petname CI

on:
  push:
  schedule:
    - cron: "0 0 * * 0" # weekly

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo install cargo-hack
      - run: cargo hack --workspace --feature-powerset build
      - run: cargo hack --workspace --feature-powerset test

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

  clippy:
    name: Clippy # i.e. `cargo check` plus extra linting.
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - run: cargo clippy -- -D warnings

  docs:
    name: Docs # docs.rs-equivalent build (see `scripts/doc`); fails on warnings.
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@nightly
      - run: cargo doc --no-deps --all-features
        env:
          RUSTDOCFLAGS: "--cfg docsrs -D warnings"

  semver:
    name: SemVer # checks the public API bump is adequate (see `scripts/semver-checks`).
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: obi1kenobi/cargo-semver-checks-action@v2
        with:
          feature-group: all-features
