From 917652b56cc77c15bc72df885963b1845040ee36 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Fri, 31 Mar 2023 12:22:21 +0300 Subject: [PATCH] [#1] Add pre-commit CI Signed-off-by: Alex Vanin --- .golangci.yml | 56 ++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 36 ++++++++++++++++++++++++ .woodpecker/pre-commit.yml | 6 ++++ 3 files changed, 98 insertions(+) create mode 100644 .golangci.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .woodpecker/pre-commit.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..67f93e7 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,56 @@ +# This file contains all available configuration options +# with their default values. + +# options for analysis running +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m + + # include test files or not, default is true + tests: true + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" + format: tab + +# all available settings of specific linters +linters-settings: + exhaustive: + # indicates that switch statements are to be considered exhaustive if a + # 'default' case is present, even if all enum members aren't listed in the + # switch + default-signifies-exhaustive: true + govet: + # report about shadowed variables + check-shadowing: false + +linters: + enable: + # mandatory linters + - govet + - revive + + # some default golangci-lint linters + - errcheck + - gosimple + - ineffassign + - staticcheck + - typecheck + - unused + + # extra linters + - exhaustive + - godot + - gofmt + - whitespace + - goimports + disable-all: true + fast: false + +issues: + include: + - EXC0002 # should have a comment + - EXC0003 # test/Test ... consider calling this + - EXC0004 # govet + - EXC0005 # C-style breaks diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1fe9dcd --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,36 @@ +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 diff --git a/.woodpecker/pre-commit.yml b/.woodpecker/pre-commit.yml new file mode 100644 index 0000000..8de638d --- /dev/null +++ b/.woodpecker/pre-commit.yml @@ -0,0 +1,6 @@ +pipeline: + pre-commit: + image: git.frostfs.info/truecloudlab/frostfs-ci:v0.36 + commands: + - export HOME="$(getent passwd $(id -u) | cut '-d:' -f6)" + - pre-commit run --hook-stage manual -- 2.45.2