From 38fc107f9449de35a7fbc8faba2386bcff76ecac Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 13 Jul 2025 14:44:57 +0200 Subject: [PATCH 1/3] 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 6b6cbcd52ca..7f431fca9e6 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 23a0e524bb6..dd4398af90b 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 f972100a143..38dc118cb82 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 00000000000..24e32ac8580 --- /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" "$@" From c8a1e894e00401027d2b958264fa3ccd985583c8 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 13 Jul 2025 14:45:22 +0200 Subject: [PATCH 2/3] Remove unused script lint.sh --- .gitignore | 1 - scripts/lint.sh | 12 ------------ 2 files changed, 13 deletions(-) delete mode 100755 scripts/lint.sh diff --git a/.gitignore b/.gitignore index e9c93214f5b..6d9b25784d4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ coverage.txt .idea/ # Binaries -.bin/ lazygit lazygit.exe diff --git a/scripts/lint.sh b/scripts/lint.sh deleted file mode 100755 index 98d697bc100..00000000000 --- a/scripts/lint.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -if [ ! -x ./.bin/golangci-lint ]; then - echo 'You need to install golangci-lint into .bin' - echo 'One way to do this is to run' - echo ' GOBIN=$(pwd)/.bin go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.1' - exit 1 -fi - -./.bin/golangci-lint run From 37d5aeea8b4fc6b005207719d80c2212d0105f92 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 18 Jul 2025 15:36:43 +0200 Subject: [PATCH 3/3] Remove unnecessary golangci-lint install step from dev-container Dockerfile --- .devcontainer/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 03c43d4119d..6e7b5fd5825 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,8 +5,6 @@ ARG VARIANT=1-bullseye FROM golang:${VARIANT} RUN go install mvdan.cc/gofumpt@latest -RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0 -RUN golangci-lint --version # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \