name: Lint & Test

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]
  # Allow manual runs (e.g. to validate after a release commit was skipped).
  workflow_dispatch:

jobs:
  test:
    # Skip release-publishing commits — version bumps don't affect lint/tests
    # and the release.yml pipeline is already running. PRs and manual dispatch
    # always run.
    if: ${{ github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'chore: release') }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install system dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends libportaudio2

      - name: Install dependencies
        working-directory: server
        run: |
          pip install --upgrade pip
          pip install -e ".[dev]"

      - name: Lint with ruff
        working-directory: server
        run: ruff check src/ tests/

      - name: Run tests
        working-directory: server
        run: pytest --tb=short -q
