name: Golangci-lint

on:
  push:
    branches:
      - master
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  golangci:
    strategy:
      fail-fast: false
      matrix:
        include:
          - {os: macos-latest, CGO_ENABLED: "0", GOOS: darwin, GOARCH: amd64}
          - {os: macos-latest, CGO_ENABLED: "1", GOOS: darwin, GOARCH: amd64}
          - {os: macos-latest, CGO_ENABLED: "0", GOOS: darwin, GOARCH: arm64}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: aix, GOARCH: ppc64}
#          - {os: ubuntu-latest, CGO_ENABLED: "1", GOOS: aix, GOARCH: ppc64} # FIXME
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: dragonfly, GOARCH: amd64}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: freebsd, GOARCH: amd64}
#          - {os: ubuntu-latest, CGO_ENABLED: "1", GOOS: freebsd, GOARCH: amd64} # FIXME
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: freebsd, GOARCH: 386}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: freebsd, GOARCH: arm}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: 386}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: amd64}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: arm64}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: arm}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: loong64}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: mips64}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: mips64le}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: mips}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: mipsle}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: ppc64le}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: ppc64}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: riscv64}
#          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: s390x} # FIXME
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: netbsd, GOARCH: amd64}
          - {os: ubuntu-latest, CGO_ENABLED: "1", GOOS: netbsd, GOARCH: amd64}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: openbsd, GOARCH: 386}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: openbsd, GOARCH: amd64}
#          - {os: ubuntu-latest, CGO_ENABLED: "1", GOOS: openbsd, GOARCH: amd64} # FIXME
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: plan9, GOARCH: amd64}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: plan9, GOARCH: 386}
          - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: solaris, GOARCH: amd64}
          - {os: windows-latest, CGO_ENABLED: "0", GOOS: windows, GOARCH: amd64}
          - {os: windows-latest, CGO_ENABLED: "0", GOOS: windows, GOARCH: 386}
    permissions:
      contents: read  # for actions/checkout to fetch code
      pull-requests: read  # for golangci/golangci-lint-action to fetch pull requests
    name: lint
    runs-on: ${{ matrix.os }}
    env:
      CGO_ENABLED: "${{ matrix.CGO_ENABLED }}"
      GOARCH: ${{ matrix.GOARCH }}
      GOOS: ${{ matrix.GOOS }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - name: Setup go
        uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
        with:
          go-version-file: go.mod
      - name: Setup golangci-lint
        uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9  # v8.0.0
        with:
          args: --verbose
          version: latest
