1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-22 19:21:52 +03:00

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>
This commit is contained in:
Stefan Haller
2025-07-13 14:44:57 +02:00
parent d159b28dc0
commit 38fc107f94
4 changed files with 11 additions and 2 deletions

View File

@ -170,6 +170,7 @@ jobs:
- name: Lint - name: Lint
uses: golangci/golangci-lint-action@v8 uses: golangci/golangci-lint-action@v8
with: with:
# If you change this, make sure to also update scripts/golangci-lint-shim.sh
version: v2.2.1 version: v2.2.1
- name: errors - name: errors
run: golangci-lint run run: golangci-lint run

View File

@ -23,7 +23,7 @@
}, },
}, },
"go.alternateTools": { "go.alternateTools": {
"golangci-lint-v2": "${workspaceFolder}/.bin/golangci-lint", "golangci-lint-v2": "${workspaceFolder}/scripts/golangci-lint-shim.sh",
}, },
"go.lintTool": "golangci-lint-v2", "go.lintTool": "golangci-lint-v2",
} }

View File

@ -40,7 +40,7 @@ format:
.PHONY: lint .PHONY: lint
lint: lint:
./scripts/lint.sh ./scripts/golangci-lint-shim.sh run
# For more details about integration test, see https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md. # For more details about integration test, see https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md.
.PHONY: integration-test-tui .PHONY: integration-test-tui

8
scripts/golangci-lint-shim.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
set -e
# Must be kept in sync with the version in .github/workflows/ci.yml
version="v2.2.1"
go run "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$version" "$@"