name: Golangci lint

on:
  push:
    branches-ignore: [main]
  pull_request:
    branches: [main]

permissions: {}

jobs:
  golangci:
    name: lint
    permissions:
      # Required: allow read access to the content for analysis.
      contents: read
      # Optional: allow read access to pull request. Use with `only-new-issues` option.
      pull-requests: read
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go: ["1.24"]
        senzingsdk-version: [production-v4, staging-v4]

    steps:
      - name: Checkout repository
        uses: actions/checkout@v5
        with:
          persist-credentials: false

      - name: Install Senzing SDK
        uses: senzing-factory/github-action-install-senzing-sdk@v3
        with:
          senzingsdk-version: ${{ matrix.senzingsdk-version }}

      - name: Copy Senzing headers
        run: |
          mkdir --parents ./szconfig/szhelpers
          cp /opt/senzing/er/sdk/c/*.h ./szconfig/
          cp /opt/senzing/er/sdk/c/szhelpers/*.h ./szconfig/szhelpers
          mkdir --parents ./szconfigmanager/szhelpers
          cp /opt/senzing/er/sdk/c/*.h ./szconfigmanager/
          cp /opt/senzing/er/sdk/c/szhelpers/*.h ./szconfigmanager/szhelpers
          mkdir --parents ./szdiagnostic/szhelpers
          cp /opt/senzing/er/sdk/c/*.h ./szdiagnostic/
          cp /opt/senzing/er/sdk/c/szhelpers/*.h ./szdiagnostic/szhelpers
          mkdir --parents ./szengine/szhelpers
          cp /opt/senzing/er/sdk/c/*.h ./szengine/
          cp /opt/senzing/er/sdk/c/szhelpers/*.h ./szengine/szhelpers
          mkdir --parents ./szproduct/szhelpers
          cp /opt/senzing/er/sdk/c/*.h ./szproduct/
          cp /opt/senzing/er/sdk/c/szhelpers/*.h ./szproduct/szhelpers

      - name: Setup go
        uses: actions/setup-go@v6
        with:
          go-version: ${{ matrix.go }}

      - name: Perform linting
        uses: golangci/golangci-lint-action@v8
        with:
          args: --config=${{ github.workspace }}/.github/linters/.golangci.yaml
          only-new-issues: false
          version: latest
