monio 0.1.1

Pure Rust cross-platform input monitoring library with proper drag detection
Documentation
name: CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  # Check formatting
  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt

      - name: Check formatting
        run: cargo fmt --all -- --check

  # Run clippy lints
  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy

      - name: Install dependencies (Linux)
        run: |
          sudo apt-get update
          sudo apt-get install -y libx11-dev libxtst-dev libevdev-dev

      - name: Run clippy (default features)
        run: cargo clippy -- -D warnings

      - name: Run clippy (all features)
        run: cargo clippy --all-features -- -D warnings

  # Build and test on multiple platforms
  build:
    name: Build & Test
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        rust: [stable]
        include:
          - os: ubuntu-latest
            rust: nightly

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust (${{ matrix.rust }})
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}

      # Linux dependencies
      - name: Install dependencies (Ubuntu)
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt-get install -y libx11-dev libxtst-dev libevdev-dev

      # Cache cargo build
      - name: Cache cargo
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}

      # Build with different feature combinations
      - name: Build (default features)
        run: cargo build

      - name: Build (all features)
        run: cargo build --all-features

      - name: Build (no default features - evdev only)
        if: matrix.os == 'ubuntu-latest'
        run: cargo build --no-default-features --features evdev

      # Run tests
      - name: Run tests (default features)
        run: cargo test

      - name: Run tests (all features)
        run: cargo test --all-features

      # Build examples
      - name: Build examples (default features)
        run: cargo build --examples

      - name: Build examples (all features)
        run: cargo build --examples --all-features

  # Documentation check
  docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Install dependencies (Linux)
        run: |
          sudo apt-get update
          sudo apt-get install -y libx11-dev libxtst-dev libevdev-dev

      - name: Build documentation
        run: cargo doc --all-features --no-deps

      - name: Check for broken doc links
        run: cargo doc --all-features --no-deps 2>&1 | grep -i "warning" && exit 1 || true

  # Check cross-compilation targets
  cross:
    name: Cross Compilation
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          - x86_64-pc-windows-gnu
          - x86_64-apple-darwin

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Install cross
        run: cargo install cross --git https://github.com/cross-rs/cross

      - name: Build for ${{ matrix.target }}
        run: cross build --target ${{ matrix.target }}
        continue-on-error: true