name: Cargo Build & Test

on:
  push:
  pull_request:

env:
  CARGO_TERM_COLOR: always

jobs:
  build_and_test:
    name: Rust project - latest
    runs-on: ubuntu-latest
    strategy:
      matrix:
        toolchain:
          - nightly
    steps:
      - uses: actions/checkout@v4
      - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
      - run: cargo build --all-targets --all-features --verbose
      - run: cargo test --all-targets --all-features --verbose
      - run: cargo test --doc --all-features --verbose
      - run: cargo clippy --all-targets --all-features --verbose
        env:
          RUSTFLAGS: -Dwarnings
      - run: cargo fmt --all --check
      - run: cargo doc --workspace --all-features --no-deps --document-private-items
        env:
          RUSTDOCFLAGS: "--cfg doc_cfg -D warnings"
