Skip to content

Commit d758adc

Browse files
authored
GODRIVER-3357 Make linting more repeatable (#1826)
1 parent b2724c6 commit d758adc

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,7 @@ buildvariants:
23482348
run_on:
23492349
- rhel8.7-small
23502350
expansions:
2351+
# Keep this in sync with go version used in etc/golangci-lint.sh
23512352
GO_DIST: "/opt/golang/go1.22"
23522353
tasks:
23532354
- name: ".static-analysis"

.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: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@ repos:
5050
- id: markdown-link-check
5151
exclude: ^(vendor)
5252

53-
- repo: https://github.com/golangci/golangci-lint
54-
rev: v1.60.1
55-
hooks:
56-
- id: golangci-lint
57-
5853
- repo: local
5954
hooks:
6055
- id: executable-shell
6156
name: executable-shell
6257
entry: chmod +x
6358
language: system
6459
types: [shell]
60+
61+
- 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

Taskfile.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@ tasks:
5757
# alignment of atomically accessed variables on 32-bit architectures (see
5858
# https://staticcheck.io/docs/checks#SA1027)
5959
lint:
60-
deps: [install-golangci-lint]
6160
cmds:
62-
- GOOS=linux GOARCH=386 golangci-lint run --config .golangci.yml ./...
63-
- GOOS=linux GOARCH=arm golangci-lint run --config .golangci.yml ./...
64-
- GOOS=linux GOARCH=arm64 golangci-lint run --config .golangci.yml ./...
65-
- GOOS=linux GOARCH=amd64 golangci-lint run --config .golangci.yml ./...
66-
- GOOS=linux GOARCH=ppc64le golangci-lint run --config .golangci.yml ./...
67-
- GOOS=linux GOARCH=s390x golangci-lint run --config .golangci.yml ./...
61+
- GOOS=linux GOARCH=386 etc/golangci-lint.sh
62+
- GOOS=linux GOARCH=arm etc/golangci-lint.sh
63+
- GOOS=linux GOARCH=arm64 etc/golangci-lint.sh
64+
- GOOS=linux GOARCH=amd64 etc/golangci-lint.sh
65+
- GOOS=linux GOARCH=ppc64le etc/golangci-lint.sh
66+
- GOOS=linux GOARCH=s390x etc/golangci-lint.sh
6867

6968
update-notices: bash etc/generate_notices.pl > THIRD-PARTY-NOTICES
7069

@@ -188,10 +187,3 @@ tasks:
188187
internal: true
189188
cmds:
190189
- go install github.com/walle/lll/...@latest
191-
192-
# NOTE: A golangci-lint version is also pinned in .pre-commit-config.yaml. Make
193-
# sure to change it there to keep it in-sync with what's used here!
194-
install-golangci-lint:
195-
internal: true
196-
cmds:
197-
- go install github.com/golangci/golangci-lint/cmd/[email protected]

etc/golangci-lint.sh

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

0 commit comments

Comments
 (0)