From 38fc107f9449de35a7fbc8faba2386bcff76ecac Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 13 Jul 2025 14:44:57 +0200 Subject: [PATCH] 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> --- .github/workflows/ci.yml | 1 + .vscode/settings.json | 2 +- Makefile | 2 +- scripts/golangci-lint-shim.sh | 8 ++++++++ 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100755 scripts/golangci-lint-shim.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b6cbcd52..7f431fca9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -170,6 +170,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v8 with: + # If you change this, make sure to also update scripts/golangci-lint-shim.sh version: v2.2.1 - name: errors run: golangci-lint run diff --git a/.vscode/settings.json b/.vscode/settings.json index 23a0e524b..dd4398af9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,7 +23,7 @@ }, }, "go.alternateTools": { - "golangci-lint-v2": "${workspaceFolder}/.bin/golangci-lint", + "golangci-lint-v2": "${workspaceFolder}/scripts/golangci-lint-shim.sh", }, "go.lintTool": "golangci-lint-v2", } diff --git a/Makefile b/Makefile index f972100a1..38dc118cb 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ format: .PHONY: 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. .PHONY: integration-test-tui diff --git a/scripts/golangci-lint-shim.sh b/scripts/golangci-lint-shim.sh new file mode 100755 index 000000000..24e32ac85 --- /dev/null +++ b/scripts/golangci-lint-shim.sh @@ -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" "$@"