mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
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.
This commit is contained in:
@ -5,8 +5,6 @@ ARG VARIANT=1-bullseye
|
|||||||
FROM golang:${VARIANT}
|
FROM golang:${VARIANT}
|
||||||
|
|
||||||
RUN go install mvdan.cc/gofumpt@latest
|
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.
|
# [Optional] Uncomment this section to install additional OS packages.
|
||||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||||
|
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -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
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,7 +14,6 @@ coverage.txt
|
|||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
# Binaries
|
# Binaries
|
||||||
.bin/
|
|
||||||
lazygit
|
lazygit
|
||||||
lazygit.exe
|
lazygit.exe
|
||||||
|
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -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",
|
||||||
}
|
}
|
||||||
|
2
Makefile
2
Makefile
@ -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
8
scripts/golangci-lint-shim.sh
Executable 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" "$@"
|
@ -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
|
|
Reference in New Issue
Block a user