From 306ba33661c73dfaa27224c0ba4f9557059cdafc Mon Sep 17 00:00:00 2001 From: Francesco Cheinasso Date: Fri, 27 Oct 2023 15:53:44 +0200 Subject: [PATCH] Added pre-commit hook configuration --- .github/workflows/lint.yml | 2 +- .pre-commit-config.yaml | 15 +++++++++++++++ Makefile | 7 ++++++- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0537af055d..99328acd6b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,7 +24,7 @@ jobs: uses: golangci/golangci-lint-action@v3.7.0 with: only-new-issues: true - version: v1.54.2 + version: v1.55.1 args: --timeout=900s gomodtidy: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..a246334186 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,15 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/golangci/golangci-lint + rev: v1.55.1 + hooks: + - id: golangci-lint + name: golangci-lint + description: Fast linters runner for Go. + entry: golangci-lint run --new + types: [go] + language: golang + require_serial: true + pass_filenames: false + fail_fast: true diff --git a/Makefile b/Makefile index 581dcf934d..e0a78df784 100644 --- a/Makefile +++ b/Makefile @@ -104,12 +104,17 @@ fmt: gci addlicense # Install golangci-lint if not available golangci-lint: ifeq (, $(shell which golangci-lint)) - @go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2 + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.1 GOLANGCILINT=$(GOBIN)/golangci-lint else GOLANGCILINT=$(shell which golangci-lint) endif +# pre-commit install the pre-commit hook +pre-commit: + pip3 install pre-commit + pre-commit install + markdownlint: ifeq (, $(shell which markdownlint)) @echo "markdownlint is not installed. Please install it: https://github.com/igorshubovych/markdownlint-cli#installation"