name: CI

on:
    push:
        branches: [main]
    pull_request:

jobs:
    test:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v4
            - uses: Swatinem/rust-cache@v2
            - uses: dtolnay/rust-toolchain@stable
            - run: cargo test --no-default-features
            - run: cargo test --features serde --no-default-features
            - run: cargo test --features bytemuck --no-default-features
            - run: cargo test --all-features

    lint:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v4
            - uses: Swatinem/rust-cache@v2
            - uses: dtolnay/rust-toolchain@stable
              with:
                components: clippy, rustfmt
            - run: cargo fmt --check
            - run: cargo clippy --all-features -- -D warnings

    docs:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v4
            - uses: Swatinem/rust-cache@v2
            - uses: dtolnay/rust-toolchain@stable
            - run: cargo doc --all-features --no-deps
              env:
                RUSTDOCFLAGS: "-D warnings"
