name: Test

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

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go-version: ['1.25.x']

    steps:
    - uses: actions/checkout@v4

    - uses: actions/setup-go@v5
      with:
        go-version: ${{ matrix.go-version }}
        cache: true

    - name: Vet
      run: go vet ./...

    - name: Run tests
      run: go test -v -race -coverprofile=coverage.out ./...

    - name: Upload coverage
      uses: codecov/codecov-action@v4
      with:
        files: ./coverage.out
        flags: unittests
        name: codecov-umbrella
      continue-on-error: true

  build:
    runs-on: ubuntu-latest
    needs: [test]
    steps:
    - uses: actions/checkout@v4

    - uses: actions/setup-go@v5
      with:
        go-version: '1.25.x'
        cache: true

    - name: Build CLI
      run: go build -o foxhound ./cmd/foxhound/

    - name: Build all packages
      run: go build ./...

    - name: Upload artifact
      uses: actions/upload-artifact@v4
      with:
        name: foxhound-binary
        path: foxhound
