name: Test SDK on PR

permissions:
  checks: write
  contents: read
  pull-requests: read
  statuses: write
  id-token: write

on:
  pull_request:
    types: [opened, synchronize, reopened]
    branches:
      - main

jobs:
  test-go-sdk:
    name: Test Go SDK
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}

      - name: Setup Go
        uses: actions/setup-go@v5
        with:
          go-version: '1.22.5'
          cache: true

      - name: Run tests
        working-directory: ${{ github.workspace }}/tests
        env:
          CENSYS_PAT: ${{ secrets.PAT }}
          CENSYS_ORG_ID: ${{ secrets.ORG_ID }}
        run: |
          go test -v ./...
