From 1f661493164265ad3115bfdfda4907cd0189a5fc Mon Sep 17 00:00:00 2001 From: Egor Funtikov Date: Thu, 9 Mar 2023 11:49:52 +0300 Subject: [PATCH] [#17] Add pre-commit config --- .gitlint | 11 ++++++++++ .pre-commit-config.yaml | 45 +++++++++++++++++++++++++++++++++++++++++ Makefile | 10 ++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .gitlint create mode 100644 .pre-commit-config.yaml diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..fda43fb --- /dev/null +++ b/.gitlint @@ -0,0 +1,11 @@ +[general] +fail-without-commits=True +regex-style-search=True +contrib=CC1 + +[title-match-regex] +regex=^\[\#[0-9Xx]+\]\s + +[ignore-by-title] +regex=^Release(.*) +ignore=title-match-regex \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1e89def --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,45 @@ +ci: + autofix_prs: false + +repos: + - repo: https://github.com/jorisroovers/gitlint + rev: v0.19.1 + hooks: + - id: gitlint + stages: [commit-msg] + - id: gitlint-ci + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: check-merge-conflict + - id: check-json + - id: check-xml + - id: check-yaml + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + - id: end-of-file-fixer + exclude: ".key$" + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.9.0.2 + hooks: + - id: shellcheck + + - repo: https://github.com/golangci/golangci-lint + rev: v1.51.2 + hooks: + - id: golangci-lint + + - repo: local + hooks: + - id: go-unit-tests + name: go unit tests + entry: make test + pass_filenames: false + types: [go] + language: system \ No newline at end of file diff --git a/Makefile b/Makefile index 41abb24..0fccc4e 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ BINDIR = bin DIRS = $(BINDIR) BINS = $(BINDIR)/frostfs-http-gw -.PHONY: all $(BINS) $(DIRS) dep docker/ test cover fmt image image-push dirty-image lint docker/lint version clean +.PHONY: all $(BINS) $(DIRS) dep docker/ test cover fmt image image-push dirty-image lint docker/lint pre-commit unpre-commit version clean # .deb package versioning OS_RELEASE = $(shell lsb_release -cs) @@ -109,6 +109,14 @@ docker/lint: --env HOME=/src \ golangci/golangci-lint:v$(LINT_VERSION) bash -c 'cd /src/ && make lint' +# Activate pre-commit hooks +pre-commit: + pre-commit install -t pre-commit -t commit-msg + +# Deactivate pre-commit hooks +unpre-commit: + pre-commit uninstall -t pre-commit -t commit-msg + # Print version version: @echo $(VERSION)