From 0315c6d7621b70038a601ce67619591e857998cc Mon Sep 17 00:00:00 2001 From: Kaloyan Tanev Date: Sun, 21 Jul 2024 18:50:36 +0300 Subject: [PATCH] Run local linter with charon's linting config --- .pre-commit-config.yaml | 10 +++++----- .pre-commit/run_linter.sh | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100755 .pre-commit/run_linter.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0d5b0401a..82f26597f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,13 +41,13 @@ repos: # Then run code validators (on the formatted code) - - repo: https://github.com/golangci/golangci-lint # See .golangci.yml for config - rev: v1.59.1 - hooks: - - id: golangci-lint - - repo: local hooks: + - id: golangci-lint + name: golangci-lint + language: script + entry: .pre-commit/run_linter.sh + types: [ file, go ] - id: run-go-tests name: run-go-tests language: script diff --git a/.pre-commit/run_linter.sh b/.pre-commit/run_linter.sh new file mode 100755 index 000000000..aedebc999 --- /dev/null +++ b/.pre-commit/run_linter.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +VERSION="1.59.1" + +if ! command -v golangci-lint &> /dev/null +then + echo "golangci-lint could not be found" + exit 1 +fi + +version_check=$(golangci-lint version) +if [[ $version_check != *"$VERSION"* ]]; then + echo $version_check + echo "golangci-lint version is not $VERSION" + exit 1 +fi + +golangci-lint run