Skip to content

Commit 9073480

Browse files
stefanhallerkyu08
andcommitted
Use a better way of pinning the version of golangci-lint
Instead of requiring the user to install the right version of the tool in their .bin folder, create a shim that automatically runs the right version of the tool. This has several benefits: - it works out of the box with no setup required (the tool will be automatically downloaded and compiled the first time it is used) - no work needed for developers when we bump the golangci-lint version - it works in working copies that are used in different environments (e.g. locally on a Mac, or inside a dev container) Co-authored-by: kyu08 <49891479+kyu08@users.noreply.github.com>
1 parent 9625ee8 commit 9073480

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ jobs:
170170
- name: Lint
171171
uses: golangci/golangci-lint-action@v8
172172
with:
173+
# If you change this, make sure to also update scripts/golangci-lint-shim.sh
173174
version: v2.2.1
174175
- name: errors
175176
run: golangci-lint run

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
},
2525
"go.alternateTools": {
26-
"golangci-lint-v2": "${workspaceFolder}/.bin/golangci-lint",
26+
"golangci-lint-v2": "${workspaceFolder}/scripts/golangci-lint-shim.sh",
2727
},
2828
"go.lintTool": "golangci-lint-v2",
2929
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ format:
4040

4141
.PHONY: lint
4242
lint:
43-
./scripts/lint.sh
43+
./scripts/golangci-lint-shim.sh run
4444

4545
# For more details about integration test, see https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md.
4646
.PHONY: integration-test-tui

scripts/golangci-lint-shim.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Must be kept in sync with the version in .github/workflows/ci.yml
6+
version="v2.2.1"
7+
8+
go run "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$version" "$@"

0 commit comments

Comments
 (0)