name: CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  format:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo fmt --all -- --check

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo clippy --all-targets -- -D warnings
      - run: cargo clippy --all-targets --features subscriber -- -D warnings
      - run: cargo clippy --all-targets --features compose -- -D warnings
      - run: cargo clippy --all-targets --features "subscriber,compose" -- -D warnings

  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo test --all-targets
      - run: cargo test --all-features --all-targets

  msrv:
    name: MSRV (1.89)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@1.89.0
      - run: cargo build --all-targets --all-features
