Skip to content

Commit d26abf8

Browse files
committed
Use a pinned Go version for golangci-lint.
1 parent 92c8b91 commit d26abf8

File tree

3 files changed

+50
-13
lines changed

3 files changed

+50
-13
lines changed

.pre-commit-config.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,24 @@ 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:
55+
- id: executable-shell
56+
name: executable-shell
57+
entry: chmod +x
58+
language: system
59+
types: [shell]
60+
5661
- id: golangci-lint
62+
name: golangci-lint
63+
language: system
64+
types: [go]
65+
require_serial: true
66+
pass_filenames: false
67+
entry: etc/golangci-lint.sh
68+
69+
- id: check-licenses
70+
name: check-licenses
71+
language: system
72+
types: [go]
73+
entry: etc/check_license.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)