name: ci

on:
  pull_request:
  push:
    branches: ["master"]

jobs:
  ci:
    strategy:
      matrix:
        os: [[self-hosted, linux], [self-hosted, macos]]
    runs-on: "${{ matrix.os }}"
    steps:
      - uses: actions/checkout@v4
      - uses: cargo-bins/cargo-binstall@main

        if: runner.os == 'linux'
      - uses: extractions/setup-just@v1
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: stable
          components: clippy, rustfmt

      - name: "Install and cache dependencies (Linux)"
        if: runner.os == 'linux'
        uses: awalsh128/cache-apt-pkgs-action@latest
        with:
          packages: libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
          version: 1.0

      - name: Formatting
        run: |
          cargo fmt --check

      - name: Lints
        run: |
          cargo clippy

      - name: Build
        run: |
          cargo build --bin hedz_reloaded --no-default-features --features shared/client
          cargo build --bin server --no-default-features --features shared/server

      - name: Tests
        run: |
          cargo test
