openlogi 0.6.23

OpenLogi command-line interface — a local-first companion for Logitech HID++ peripherals.
name: CI

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

# Cancel superseded runs on the same ref (rapid PR pushes / force-pushes).
# Always cancel here: CI never signs or publishes artifacts.
concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  CARGO_INCREMENTAL: 0
  RUSTFLAGS: "-D warnings"

# rust-cache policy (see PR description for measured rationale):
# - prefix-key v1-rust: bust the thrashing v0-rust multi-GB entries (~21 GB).
# - shared-key groups jobs that share OS + rustc channel + debug profile.
# - save-if master/main only: PRs restore base-branch caches without writing
#   new multi-GB keys that evict Windows/MSRV under the 10 GB soft limit.
jobs:
  fmt:
    name: rustfmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - run: cargo fmt --all -- --check

  clippy:
    name: clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
        with:
          prefix-key: v1-rust
          shared-key: linux-stable-debug
          save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
      - run: |
          sudo apt-get update
          sudo apt-get install -y \
            libudev-dev \
            gcc g++ clang libfontconfig-dev libwayland-dev \
            libxkbcommon-x11-dev libx11-xcb-dev \
            libssl-dev libzstd-dev pkg-config
      - run: cargo clippy --workspace --all-targets -- -D warnings

  # Both first-class platforms: macOS and Linux compile disjoint cfg-gated
  # code (evdev/zbus vs the ObjC surface), so a single-runner MSRV check would
  # miss a too-new stabilization on the other side.
  msrv:
    name: MSRV (cargo check, ${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, ubuntu-latest]
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@1.96
      - uses: Swatinem/rust-cache@v2
        with:
          prefix-key: v1-rust
          # Host OS splits Linux vs macOS; rustc 1.96 is already in the key.
          shared-key: msrv-debug
          save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
      - if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -y \
            libudev-dev \
            gcc g++ clang libfontconfig-dev libwayland-dev \
            libxkbcommon-x11-dev libx11-xcb-dev \
            libssl-dev libzstd-dev pkg-config
      - run: cargo check --workspace --all-targets

  # Stable Linux typecheck is covered by `clippy` above (clippy subsumes
  # `cargo check` for the same --workspace --all-targets set — same rationale
  # as clippy-windows). MSRV stays on the `msrv` matrix (1.96).

  docs-hid:
    name: rustdoc (hid crates)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
        with:
          prefix-key: v1-rust
          # Share debug deps with clippy/test-linux; RUSTDOCFLAGS is step-scoped
          # below so it does not fork the rust-cache env hash.
          shared-key: linux-stable-debug
          save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
      - run: |
          sudo apt-get update
          sudo apt-get install -y \
            libudev-dev \
            pkg-config
      - name: cargo doc (openlogi-hid)
        env:
          RUSTDOCFLAGS: "-D warnings"
        run: cargo doc -p openlogi-hid --no-deps --document-private-items
      - name: cargo doc (openlogi-hidpp)
        env:
          RUSTDOCFLAGS: "-D warnings"
        run: cargo doc -p openlogi-hidpp --no-deps --document-private-items

  # openlogi-core / openlogi-hid / openlogi-assets / openlogi / openlogi-hook
  # all compile on Linux today (the hook crate has stubs for non-macOS targets).
  # openlogi-gui needs GPUI's wayland / x11 system libs; the same dependency set
  # the clippy job installs is sufficient. Test workspace there as well so the
  # config-roundtrip and binding suites run on a non-macOS host.
  test-linux:
    name: tests (linux)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
        with:
          prefix-key: v1-rust
          shared-key: linux-stable-debug
          save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
      - run: |
          sudo apt-get update
          sudo apt-get install -y \
            libudev-dev \
            gcc g++ clang libfontconfig-dev libwayland-dev \
            libxkbcommon-x11-dev libx11-xcb-dev \
            libssl-dev libzstd-dev pkg-config
      - run: cargo test --workspace --exclude openlogi-gui

  test-macos:
    name: tests (macos, ${{ matrix.arch }})
    runs-on: ${{ matrix.runner }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - arch: arm64
            runner: macos-latest
          - arch: x86_64
            runner: macos-15-intel
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
        with:
          prefix-key: v1-rust
          # Host triple already splits arm64 vs x86_64 in the final cache key.
          shared-key: macos-stable-debug
          save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
      - name: Verify runner architecture
        run: test "$(uname -m)" = "${{ matrix.arch }}"
      - run: cargo test --workspace --all-targets

  cargo-deny:
    name: cargo-deny
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      # Prebuilt binary install is faster than cargo-deny-action's bootstrap path
      # (~100s observed); advisory DB is still fetched by `cargo deny check`.
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-deny
      # Global flags before subcommand (matches cargo-deny-action defaults).
      - run: cargo deny --all-features check

  clippy-windows:
    name: clippy (windows)
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
        with:
          prefix-key: v1-rust
          shared-key: windows-stable-debug
          save-if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
      # Whole workspace, matching the Linux jobs — GPUI's DirectX backend
      # covers the GUI on Windows. clippy subsumes `cargo check` and
      # additionally lints the Windows-only code paths (the WH_MOUSE_LL hook,
      # SendInput synthesis, native HID writer, the composite HID++ channel,
      # and the agent's HKCU-Run autostart) that the Linux/macOS clippy jobs
      # never compile.
      - run: cargo clippy --workspace --all-targets -- -D warnings