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]
        go-version: [1.24.x]

    steps:
      - name: Set up Go
        uses: actions/setup-go@v4
        with:
          go-version: ${{ matrix.go-version }}

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

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

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

      - name: Race Condition Tests
        run: go run -race . -u scanme.sh
        working-directory: cmd/tlsx/
        env:
          PDCP_API_KEY: "${{ secrets.PDCP_API_KEY }}"

      - name: Test Example Code
        run: go run .
        working-directory: examples/
        env:
          PDCP_API_KEY: "${{ secrets.PDCP_API_KEY }}"
      
