Skip to content

Commit 143d476

Browse files
authored
Use a better way of pinning the version of golangci-lint (#4733)
- **PR Description** 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) Approach suggested by @kyu08.
2 parents d159b28 + 37d5aee commit 143d476

File tree

7 files changed

+11
-17
lines changed

7 files changed

+11
-17
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ ARG VARIANT=1-bullseye
55
FROM golang:${VARIANT}
66

77
RUN go install mvdan.cc/gofumpt@latest
8-
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
9-
RUN golangci-lint --version
108

119
# [Optional] Uncomment this section to install additional OS packages.
1210
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \

.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

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ coverage.txt
1414
.idea/
1515

1616
# Binaries
17-
.bin/
1817
lazygit
1918
lazygit.exe
2019

.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" "$@"

scripts/lint.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)