name: CI

on:
  push:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

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

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

      - name: build examples
        run: cargo build --examples

      - name: test
        run: cargo test --all-targets

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

      - name: test (no default features)
        run: cargo test --all-targets --no-default-features

      - name: clippy (contextual)
        run: cargo clippy --all-targets --features contextual -- -D warnings

      - name: build examples (contextual)
        run: cargo build --examples --features contextual

      - name: test (contextual)
        run: cargo test --all-targets --features contextual

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

      - name: test (contextual, no default features)
        run: cargo test --all-targets --no-default-features --features contextual
