on: [push, pull_request]

name: Continuous Integration

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - name: Cache Cargo dependencies
        uses: Swatinem/rust-cache@v2
      - run: cargo fmt --all -- --check

  clippy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - name: Cache Cargo dependencies
        uses: Swatinem/rust-cache@v2
      - run: cargo clippy -- -D clippy::pedantic

  check:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Cargo dependencies
        uses: Swatinem/rust-cache@v2
      - run: cargo check --all --verbose

  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        features: 
          - ""
          - "--no-default-features"
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable
      - name: Cache Cargo dependencies
        uses: Swatinem/rust-cache@v2
      - run: cargo test --all --verbose ${{ matrix.features }}
