on:
  push:
    branches:
      - main
  pull_request:

name: CI

jobs:
  check:
    name: Check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: cargo check --all-features

  test:
    name: Test Suite
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v4
      - run: cargo test
      - run: cargo test --all-features

  test-direct-minimal-versions:
    name: Test Direct Minimal Versions
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: rustup toolchain add nightly
      - run: cargo +nightly update -Z minimal-versions
      - run: cargo +stable test

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: rustup component add clippy
      - run: cargo clippy --all-features --locked -- -D warnings

  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: rustup component add rustfmt
      - run: cargo fmt --all -- --check
      - run: npx prettier --check "**/*.md"
