name: "Testing"
on: [push, pull_request]

jobs:
  test:
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]
        features: ["--all-features", "--no-default-features"]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: true
      - name: Init cache
        uses: Swatinem/rust-cache@v2
      - name: Install dependencies (Ubuntu only)
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt-get install -y libdbus-1-dev
      - name: Set toolchain version
        run: |
          rustup override set 1.84
          rustup component add rustfmt
      - name: cargo check
        run: cargo check ${{ matrix.features }}
      - name: cargo fmt
        run: cargo fmt --all -- --check
      - name: cargo clippy
        run: |
          rustup component add clippy
          cargo clippy -- -D warnings
      - name: cargo test
        run: cargo test ${{ matrix.features }}
