name: ci

# Build + test on every push and pull request to main. Single Linux job
# kept lean — multi-platform release builds happen in release.yml on
# tag push.

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

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  test:
    name: cargo build + test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy

      # System libs for bdslib's transitive native deps on Ubuntu.
      # See `release.yml` for the rationale; CI mirrors the same set.
      - name: Install Linux build dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends \
            pkg-config \
            libfontconfig1-dev \
            libssl-dev \
            libxcb1-dev \
            libxcb-render0-dev \
            libxcb-shape0-dev \
            libxcb-xfixes0-dev \
            libasound2-dev

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2

      - name: cargo build
        run: cargo build --locked

      - name: cargo test
        run: cargo test --locked -- --nocapture

      # Linting is informational — bdslib's vendored sources can drag in
      # warnings that aren't actionable here. `-D warnings` would be too
      # strict; report-only is enough as a smoke check.
      - name: cargo clippy
        run: cargo clippy --no-deps -- -A clippy::all
        continue-on-error: true
