pixhunt 0.7.0

Fast screen finding: template matching (RGB tolerance / ZNCC), color-blob search and wait/poll APIs, with pluggable capture backends (cross-platform xcap, plus Windows GDI / DXGI / PrintWindow window capture).
name: CI

on:
  push:
    branches: [master]
  pull_request:
  # 库 crate 不提交 Cargo.lock(惯例),于是每跑一次 CI 都是**重新解析**依赖:上游一发新版,
  # 解析结果就可能落到从没编过的组合上。而不改代码就不会触发 push/PR——定时跑一次当下限预警。
  schedule:
    - cron: "17 3 * * 1" # 每周一 03:17 UTC(错开整点,排队快些)

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: build & test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    # 定时任务只做 MSRV 预警,不必再烧整套矩阵的 runner 时间。
    if: github.event_name != 'schedule'
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2

      # 跨平台保底后端(xcap)在 Linux 上要链接 XCB、Xrandr、D-Bus、PipeWire、Wayland、
      # EGL、GBM;runner 镜像未预装这些 -dev 包(缺失时报
      # `rust-lld: error: unable to find library -lxcb` / `-lgbm`)。libclang 是给
      # pipewire-sys 的 bindgen 用的。注意:只有代码真调用到 xcap 时这些库才会被真正
      # 需求(`-Wl,--as-needed` 会丢掉未被引用的),所以换了后端必须先跑一次才暴露。
      - name: Install Linux system deps
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends \
            pkg-config libclang-dev \
            libxcb1-dev libxrandr-dev libdbus-1-dev \
            libpipewire-0.3-dev libwayland-dev libegl-dev libgbm-dev

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

      - name: Build (default features)
        run: cargo build --release

      - name: Test (default features)
        run: cargo test --release

      - name: Test (parallel)
        run: cargo test --release --features parallel

      - name: Test (all features) [windows]
        if: matrix.os == 'windows-latest'
        run: cargo test --release --all-features

      - name: Test (match-corr) [linux]
        if: matrix.os == 'ubuntu-latest'
        run: cargo test --release --features match-corr

      - name: Test (match-corr + parallel) [linux]
        if: matrix.os == 'ubuntu-latest'
        run: cargo test --release --features match-corr,parallel

      # tracing 只在 rustdoc 步骤里出现过,单独让它真编译一次(埋点宏展开、字段名
      # 写错这类问题只有真编译时才暴露)。
      - name: Test (tracing) [linux]
        if: matrix.os == 'ubuntu-latest'
        run: cargo test --release --features tracing

      - name: Clippy (default features)
        run: cargo clippy --release --all-targets -- -D warnings

      - name: Clippy (all features) [windows]
        if: matrix.os == 'windows-latest'
        run: cargo clippy --release --all-targets --all-features -- -D warnings

      - name: Clippy (match-corr) [linux]
        if: matrix.os == 'ubuntu-latest'
        run: cargo clippy --release --all-targets --features match-corr -- -D warnings

      # 文档链接写错不会让编译失败(只会出 warning),所以单独把 rustdoc 的告警当错误。
      - name: Rustdoc (warnings are errors) [windows]
        if: matrix.os == 'windows-latest'
        env:
          RUSTDOCFLAGS: -D warnings
        run: cargo doc --no-deps --all-features

      - name: Rustdoc (warnings are errors) [linux]
        if: matrix.os == 'ubuntu-latest'
        env:
          RUSTDOCFLAGS: -D warnings
        run: cargo doc --no-deps --features match-corr,parallel,tracing

  # 声明了 rust-version = "1.88"(下限由 xcap 的 Linux 依赖 zbus 5 决定),那就真拿
  # 1.88 编一次:否则 MSRV 声明会悄悄失真。只测默认 feature——开 `match-corr` 后
  # corrmatch 的依赖(wide/safe_arch)目前要 1.89。也是 schedule 唯一跑的任务。
  msrv:
    name: build on MSRV (1.88)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@1.88
      - uses: Swatinem/rust-cache@v2
      - name: Install Linux system deps
        run: |

          sudo apt-get update
          sudo apt-get install -y --no-install-recommends \
            pkg-config libclang-dev \
            libxcb1-dev libxrandr-dev libdbus-1-dev \
            libpipewire-0.3-dev libwayland-dev libegl-dev libgbm-dev
      - name: Build (default features)
        run: cargo build --release