name: go lint

on:
  push:
    paths-ignore:
      - 'docs/**'
      - 'README.md'
    branches:
      - main
  pull_request:
    paths-ignore:
      - 'docs/**'
      - 'README.md'
    branches:
      - main

permissions:
  contents: read

jobs:
  linter:
    permissions:
      contents: read  # for actions/checkout to fetch code
      pull-requests: read  # for golangci/golangci-lint-action to fetch pull requests
    runs-on: ubuntu-22.04

    steps:
    - uses: actions/checkout@v4

    - uses: actions/setup-go@v5
      with:
        go-version: '1.22'
        # workaround: when the files to be extracted are already present, 
        # tar extraction in Golangci Lint fails with the "File exists"
        # https://github.com/golangci/golangci-lint-action/issues/807
        cache: false

    - name: golangci-lint
      uses: golangci/golangci-lint-action@v6
      with:
        version: "v1.57.1"
        args: --timeout 3m --verbose