name: 🔨 Build Test

on:
  pull_request:
    paths:
      - '**.go'
      - '**.mod'
  workflow_dispatch:

jobs:
  build:
    name: Test Builds
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
    steps:
      - name: Set up Go
        uses: actions/setup-go@v4
        with:
          go-version: 1.24.x

      - name: Check out code
        uses: actions/checkout@v3

      - name: Build
        run: go build .
        working-directory: cmd/dnsx/

      - name: Test
        run: go test ./...
        working-directory: .
        env:
          GH_ACTION: true
          PDCP_API_KEY: "${{ secrets.PDCP_API_KEY }}"

      - name: Integration Tests
        env:
          GH_ACTION: true
          PDCP_API_KEY: "${{ secrets.PDCP_API_KEY }}"
        run: bash run.sh
        working-directory: integration_tests/
        
      - name: Race Condition Tests
        run: go run -race .
        working-directory: cmd/dnsx/

      
