name: CI

on:
  push:
    branches: [main]
  pull_request:

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  test:
    name: ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2

      - name: Install yt-dlp + ffmpeg (Linux)
        if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -y ffmpeg
          pipx install yt-dlp

      - name: Install yt-dlp + ffmpeg (macOS)
        if: runner.os == 'macOS'
        run: |
          brew install yt-dlp ffmpeg

      - name: Install nextest
        uses: taiki-e/install-action@nextest

      - name: Install cargo-deny
        uses: taiki-e/install-action@cargo-deny

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

      - name: clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: test
        run: cargo nextest run --no-fail-fast

      - name: deny
        run: cargo deny check
        continue-on-error: true
