daemos 0.1.2

A local-only music player
Documentation
name: CI

on:
  push:
    branches: [ main ]
  pull_request:

env:
  CARGO_TERM_COLOR: always
  CARGO_INCREMENTAL: false

jobs:
  build-test:
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            toolchain: stable
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            toolchain: nightly
          - os: macos-latest
            target: x86_64-apple-darwin
            toolchain: stable
          - os: macos-latest
            target: x86_64-apple-darwin
            toolchain: nightly
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            toolchain: stable
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            toolchain: nightly

    name: Build & Test (${{ matrix.target }} - ${{ matrix.toolchain }})
    runs-on: ${{ matrix.os }}

    env:
      RA_TARGET: ${{ matrix.target }}

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Cache Cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-

      - name: Cache Cargo build artifacts
        uses: actions/cache@v4
        with:
          path: target
          key: ${{ runner.os }}-target-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-target-${{ matrix.toolchain }}-${{ matrix.target }}-

      - name: Cache Rustup toolchain
        uses: actions/cache@v4
        with:
          path: |
            ~/.rustup
            ~/.cargo/bin
          key: ${{ runner.os }}-rustup-${{ matrix.toolchain }}
          restore-keys: |
            ${{ runner.os }}-rustup-

      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.toolchain }}
          target: ${{ matrix.target }}
          profile: minimal
          override: true

      - name: Install Rust library source
        if: matrix.target == 'x86_64-unknown-linux-gnu'
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.toolchain }}
          target: ${{ matrix.target }}
          profile: minimal
          override: true
          components: rust-src

      - name: Install Linux dependencies
        if: matrix.os == 'ubuntu-latest'
        run: sudo apt-get update && sudo apt-get install -y libasound2-dev

      - name: Build
        run: cargo build --verbose --target ${{ matrix.target }}

      - name: Run tests
        run: cargo test --verbose --target ${{ matrix.target }}

  lint:
    name: Formatter

    needs: build-test

    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Cache Rustup toolchain
        uses: actions/cache@v4
        with:
          path: |
            ~/.rustup
            ~/.cargo/bin
          key: ubuntu-latest-rustup-stable
          restore-keys: |
            ubuntu-latest-rustup-

      - name: Install Rust
        run: |
          rustup update stable
          rustup default stable
          rustup component add rustfmt
          rustup component add clippy

      - name: Install Linux dependencies
        run: sudo apt-get update && sudo apt-get install -y libasound2-dev

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

      - name: Check code for possible improvements
        run: cargo clippy -- -D warnings