Skip to content

Commit 9bfea8e

Browse files
authored
Use a pinned Go version for golangci-lint. (#2151)
1 parent 92c8b91 commit 9bfea8e

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v4
2020
- uses: actions/setup-python@v5
21+
- uses: actions/setup-go@v5
22+
with:
23+
go-version: 'stable'
2124
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ repos:
5050
- id: markdown-link-check
5151
exclude: ^(vendor)
5252

53-
- repo: https://github.com/golangci/golangci-lint
54-
rev: v1.60.1
53+
- repo: local
5554
hooks:
5655
- id: golangci-lint
56+
name: golangci-lint
57+
language: system
58+
types: [go]
59+
require_serial: true
60+
pass_filenames: false
61+
entry: etc/golangci-lint.sh

Makefile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,18 @@ doc:
7070
fmt:
7171
go fmt ./...
7272

73-
.PHONY: install-golangci-lint
74-
install-golangci-lint:
75-
go install github.com/golangci/golangci-lint/cmd/[email protected]
76-
7773
# Lint with various GOOS and GOARCH targets to catch static analysis failures that may only affect
7874
# specific operating systems or architectures. For example, staticcheck will only check for 64-bit
7975
# alignment of atomically accessed variables on 32-bit architectures (see
8076
# https://staticcheck.io/docs/checks#SA1027)
8177
.PHONY: lint
82-
lint: install-golangci-lint
83-
GOOS=linux GOARCH=386 golangci-lint run --config .golangci.yml ./...
84-
GOOS=linux GOARCH=arm golangci-lint run --config .golangci.yml ./...
85-
GOOS=linux GOARCH=arm64 golangci-lint run --config .golangci.yml ./...
86-
GOOS=linux GOARCH=amd64 golangci-lint run --config .golangci.yml ./...
87-
GOOS=linux GOARCH=ppc64le golangci-lint run --config .golangci.yml ./...
88-
GOOS=linux GOARCH=s390x golangci-lint run --config .golangci.yml ./...
78+
lint:
79+
GOOS=linux GOARCH=386 etc/golangci-lint.sh
80+
GOOS=linux GOARCH=arm etc/golangci-lint.sh
81+
GOOS=linux GOARCH=arm64 etc/golangci-lint.sh
82+
GOOS=linux GOARCH=amd64 etc/golangci-lint.sh
83+
GOOS=linux GOARCH=ppc64le etc/golangci-lint.sh
84+
GOOS=linux GOARCH=s390x etc/golangci-lint.sh
8985

9086
.PHONY: update-notices
9187
update-notices:

etc/golangci-lint.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
# Keep this in sync with go version used in static-analysis Evergreen build variant.
5+
GO_VERSION=1.22.8
6+
GOLANGCI_LINT_VERSION=1.60.1
7+
8+
# Unset the cross-compiler overrides while downloading binaries.
9+
GOOS_ORIG=${GOOS:-}
10+
export GOOS=
11+
GOARCH_ORIG=${GOARCH:-}
12+
export GOARCH=
13+
14+
go install golang.org/dl/go$GO_VERSION@latest
15+
go${GO_VERSION} download
16+
GOROOT="$(go${GO_VERSION} env GOROOT)"
17+
PATH="$GOROOT/bin:$PATH"
18+
export PATH
19+
export GOROOT
20+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION}
21+
22+
export GOOS=$GOOS_ORIG
23+
export GOARCH=$GOARCH_ORIG
24+
golangci-lint run --config .golangci.yml ./...

0 commit comments

Comments
 (0)