name: Continuous integration
on: [push, pull_request]

env:
  RUSTFLAGS: "-Dwarnings"
  RUSTDOCFLAGS: "-Dwarnings"

jobs:
  tests:
    name: Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo build --workspace
      - run: cargo test --workspace --no-fail-fast

  checks:
    name: Check clippy, formatting, and documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo clippy --workspace --all-targets
      - run: cargo fmt --check --all
      - run: cargo doc --workspace --no-deps

  min-version:
    name: Check mininum Rust version
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: dtolnay/rust-toolchain@1.70.0
      - uses: Swatinem/rust-cache@v2
      - run: cargo check --workspace
