name: CI

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

jobs:
  lint-test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Go
        uses: actions/setup-go@v5
        with:
          go-version: '1.24.x'
          check-latest: true

      - name: Install system dependencies (audio)
        run: sudo apt-get update && sudo apt-get install -y libasound2-dev

      - name: Cache Go modules
        uses: actions/cache@v4
        with:
          path: |
            ~/go/pkg/mod
            ~/.cache/go-build
          key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
          restore-keys: ${{ runner.os }}-go-

      - name: Install dependencies
        run: go mod download

      - name: Lint
        uses: golangci/golangci-lint-action@v7
        with:
          version: v2.7.2
          args: --timeout=3m

      - name: Test
        run: go test ./...
