name: 🔨 Build Test
on:
  pull_request:
    paths:
      - '**.go'
      - '**.mod'
  workflow_dispatch:


jobs:  
  build:
    name: Test Builds
    runs-on: ubuntu-latest
    steps:
      - name: Set up Go
        uses: actions/setup-go@v4
        with:
          go-version: 1.21.x

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

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

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

      - name: Integration Tests
        env:
          GH_ACTION: true
          PDCP_API_KEY: ${{ secrets.PDCP_API_KEY }}
        run: bash run.sh
        working-directory: integration_tests/

      - name: Race Test
        run: go run -race . -cidr 192.168.1.224/30
        working-directory: cmd/mapcidr/