|
| 1 | +name: Lint |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +concurrency: |
| 6 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 7 | + cancel-in-progress: true |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + golangci-lint: |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + # macOS combinations |
| 19 | + - {os: macos-latest, CGO_ENABLED: "0", GOOS: darwin, GOARCH: amd64} |
| 20 | + - {os: macos-latest, CGO_ENABLED: "1", GOOS: darwin, GOARCH: amd64} |
| 21 | + - {os: macos-latest, CGO_ENABLED: "0", GOOS: darwin, GOARCH: arm64} |
| 22 | + - {os: macos-latest, CGO_ENABLED: "1", GOOS: darwin, GOARCH: arm64} |
| 23 | + |
| 24 | + # Linux combinations |
| 25 | + - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: amd64} |
| 26 | + - {os: ubuntu-latest, CGO_ENABLED: "1", GOOS: linux, GOARCH: amd64} |
| 27 | + - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: arm64} |
| 28 | + - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: 386} |
| 29 | + # - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: loong64} # Not available on go1.18 |
| 30 | + |
| 31 | + # FreeBSD/NetBSD combinations sans CGO_ENABLED=1 |
| 32 | + - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: freebsd, GOARCH: amd64} |
| 33 | + - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: freebsd, GOARCH: arm64} |
| 34 | + - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: netbsd, GOARCH: amd64} |
| 35 | + - {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: netbsd, GOARCH: arm64} |
| 36 | + |
| 37 | + # Windows combinations |
| 38 | + - {os: windows-latest, CGO_ENABLED: "0", GOOS: windows, GOARCH: amd64} |
| 39 | + - {os: windows-latest, CGO_ENABLED: "1", GOOS: windows, GOARCH: amd64} |
| 40 | + - {os: windows-latest, CGO_ENABLED: "0", GOOS: windows, GOARCH: arm64} |
| 41 | + - {os: windows-latest, CGO_ENABLED: "0", GOOS: windows, GOARCH: 386} |
| 42 | + permissions: |
| 43 | + contents: read |
| 44 | + pull-requests: read |
| 45 | + name: lint (${{ matrix.GOOS }}/${{ matrix.GOARCH }}/cgo=${{ matrix.CGO_ENABLED }}) |
| 46 | + runs-on: ${{ matrix.os }} |
| 47 | + env: |
| 48 | + CGO_ENABLED: "${{ matrix.CGO_ENABLED }}" |
| 49 | + GOARCH: ${{ matrix.GOARCH }} |
| 50 | + GOOS: ${{ matrix.GOOS }} |
| 51 | + steps: |
| 52 | + - name: Checkout |
| 53 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 54 | + - name: Setup Go |
| 55 | + uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 |
| 56 | + with: |
| 57 | + go-version-file: go.mod |
| 58 | + - name: Run golangci-lint |
| 59 | + uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 |
| 60 | + with: |
| 61 | + args: --verbose |
| 62 | + |
| 63 | + lint-cgo: |
| 64 | + name: lint (FreeBSD/NetBSD CGO) |
| 65 | + runs-on: ubuntu-latest |
| 66 | + strategy: |
| 67 | + matrix: |
| 68 | + include: |
| 69 | + - {GOOS: freebsd, GOARCH: amd64} |
| 70 | + - {GOOS: netbsd, GOARCH: amd64} |
| 71 | + env: |
| 72 | + CGO_ENABLED: "1" |
| 73 | + GOARCH: ${{ matrix.GOARCH }} |
| 74 | + GOOS: ${{ matrix.GOOS }} |
| 75 | + steps: |
| 76 | + - name: Checkout |
| 77 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 78 | + - name: Setup Go |
| 79 | + uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 |
| 80 | + with: |
| 81 | + go-version-file: go.mod |
| 82 | + - name: Install C toolchain |
| 83 | + run: sudo apt-get update && sudo apt-get install -y clang gcc g++ libc6-dev |
| 84 | + - name: Set CC/CXX |
| 85 | + run: | |
| 86 | + echo 'CC=clang' >> $GITHUB_ENV |
| 87 | + echo 'CXX=clang++' >> $GITHUB_ENV |
| 88 | + - name: Run golangci-lint |
| 89 | + uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 |
| 90 | + with: |
| 91 | + args: --verbose |
0 commit comments