name: golangci-lint
on:
  # For now, only lint pull requests, not the main branches.
  pull_request:
    paths:
      - ".github/workflows/golangci-lint.yml"
      - "**.go"
      - "go.mod"
      - "go.sum"
  # TODO(andrew): enable for main branch after an initial waiting period.
  #push:
  #  branches:
  #    - main

  workflow_dispatch:

permissions:
  contents: read
  pull-requests: read

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  golangci:
    name: lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
        with:
          go-version-file: go.mod
          cache: true

      - name: golangci-lint
        uses: golangci/golangci-lint-action@b7bcab6379029e905e3f389a6bf301f1bc220662 # head as of 2026-03-04
        with:
          version: v2.10.1

          # Show only new issues if it's a pull request.
          only-new-issues: true

          # Loading packages with a cold cache takes a while:
          args: --timeout=10m
          
