Documentation
name: Lint & Test

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

jobs:
  test:
    runs-on: ubuntu-latest
    env:
      RUSTFLAGS: -D warnings
      RUST_BACKTRACE: full
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          components: rustfmt
      - uses: Swatinem/rust-cache@v2
      - name: Test (default/all features)
        run: cargo test
      - name: Test (not features)
        run: cargo test --no-default-features

  lint:
    runs-on: ubuntu-latest
    env:
      RUSTFLAGS: -D warnings
      MSRV: 1.68.0
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ env.MSRV }}
          components: clippy, rustfmt
      - uses: Swatinem/rust-cache@v2
      - name: Check formatting
        run: cargo fmt -- --check
      - name: Catch common mistakes and unwrap calls
        run: cargo clippy -- -D warnings

  fuzz:
    runs-on: ubuntu-latest
    env:
      RUSTFLAGS: -D warnings
      RUST_BACKTRACE: full
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: nightly
      - uses: Swatinem/rust-cache@v2
      - name: Fuzz
        run: |
          cargo --locked install cargo-fuzz
          cargo --locked fuzz run parse_no_panic -- -max_total_time=30 -max_len=100M