name: CI

on:
  push:
  pull_request:

env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-2025]

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          components: clippy, rustfmt
          targets: x86_64-pc-windows-msvc

      - name: Build
        run: cargo build

      - name: Test (unit)
        run: cargo test

      - name: Clippy
        run: cargo clippy --all-targets --all-features

      - name: Check Windows target
        if: runner.os == 'Windows'
        run: cargo check --target x86_64-pc-windows-msvc

      - name: Clippy Windows target
        if: runner.os == 'Windows'
        run: cargo clippy --target x86_64-pc-windows-msvc --all-targets --all-features

      - name: Format check
        run: cargo fmt --check
