Skip to content

Commit 3f87ca2

Browse files
authored
Update golangci-lint to newer faster version (vitessio#16636)
Signed-off-by: Andres Taylor <[email protected]>
1 parent feb845a commit 3f87ca2

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

.github/workflows/static_checks_etc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ jobs:
193193
194194
- name: Install golangci-lint
195195
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.go_files == 'true'
196-
run: go install github.com/golangci/golangci-lint/cmd/[email protected].1
196+
run: go install github.com/golangci/golangci-lint/cmd/[email protected].2
197197

198198
- name: Clean Env
199199
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.go_files == 'true'

misc/git/hooks/golangci-lint

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,44 @@
1414
# limitations under the License.
1515

1616
# Required version of golangci-lint
17-
REQUIRED_VERSION="v1.60.1"
17+
REQUIRED_VERSION="v1.60.2"
18+
19+
# Function to compare versions in pure Bash
20+
version_greater_or_equal() {
21+
local IFS=.
22+
local i
23+
local ver1=($1)
24+
local ver2=($2)
25+
26+
# Fill empty fields in ver1 with zeros
27+
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
28+
ver1[i]=0
29+
done
30+
# Fill empty fields in ver2 with zeros
31+
for ((i=${#ver2[@]}; i<${#ver1[@]}; i++)); do
32+
ver2[i]=0
33+
done
34+
35+
for ((i=0; i<${#ver1[@]}; i++)); do
36+
if ((10#${ver1[i]} > 10#${ver2[i]})); then
37+
return 0
38+
elif ((10#${ver1[i]} < 10#${ver2[i]})); then
39+
return 1
40+
fi
41+
done
42+
return 0
43+
}
1844

1945
# Check if golangci-lint is installed and capture the version
2046
if ! command -v golangci-lint >/dev/null 2>&1; then
2147
echo "golangci-lint not found. Installing version $REQUIRED_VERSION..."
2248
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$REQUIRED_VERSION
2349
else
2450
VERSION_OUTPUT=$(golangci-lint --version)
25-
INSTALLED_VERSION=$(echo "$VERSION_OUTPUT" | sed -n 's/^golangci-lint has version \([v0-9.]*\).*/\1/p')
26-
if [ "$INSTALLED_VERSION" != "$REQUIRED_VERSION" ]; then
27-
echo "golangci-lint version $INSTALLED_VERSION found, but $REQUIRED_VERSION is required."
28-
echo "Installing correct version $REQUIRED_VERSION..."
51+
INSTALLED_VERSION=$(echo "$VERSION_OUTPUT" | sed -n 's/^golangci-lint has version v\([0-9.]*\).*/\1/p')
52+
if ! version_greater_or_equal "$INSTALLED_VERSION" "${REQUIRED_VERSION#v}"; then
53+
echo "golangci-lint version $INSTALLED_VERSION found, but $REQUIRED_VERSION or newer is required."
54+
echo "Installing version $REQUIRED_VERSION..."
2955
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$REQUIRED_VERSION
3056
fi
3157
fi

0 commit comments

Comments
 (0)