summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Grimberg <agrimberg@linuxfoundation.org>2023-07-19 10:47:01 -0700
committerAndrew Grimberg <agrimberg@linuxfoundation.org>2023-07-19 10:47:01 -0700
commit62b5d4eeea25a729bc4ef189a8253ee3839d3e3e (patch)
treee77315ccc6a39c56d009196f605abd54dff10942
parented01e0c799fdc29995620d6ad02109e2f4ea3d78 (diff)
CI: Add pre-commit configuration
* pre-commit definition * configure gitlint for commit message validation * configure editorconfig for other hooks Issue-ID: CIMAN-33 Change-Id: I438771ef4a35597075ef3dab4659437c5355f5f7 Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
-rw-r--r--.editorconfig20
-rw-r--r--.gitlint30
-rw-r--r--.pre-commit-config.yaml46
3 files changed, 96 insertions, 0 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..61fbccb
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,20 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+indent_style = space
+indent_size = 4
+
+[*.{json,yaml,yml}]
+indent_size = 2
+
+[*.markdown]
+max_line_length = 80
+
+[*.py]
+max_line_legth = 120
+
+[*.sh]
+max_line_length = 80
diff --git a/.gitlint b/.gitlint
new file mode 100644
index 0000000..3e8735e
--- /dev/null
+++ b/.gitlint
@@ -0,0 +1,30 @@
+# All these sections are optional, edit this file as you like.
+[general]
+# Ignore certain rules, you can reference them by their id or by their full
+# name
+# ignore=title-trailing-punctuation, T3
+
+# verbosity should be a value between 1 and 3, the command line -v flags take
+# precedence over this
+# verbosity = 2
+
+# By default gitlint will ignore merge commits. Set to 'false' to disable.
+# ignore-merge-commits=true
+
+# By default gitlint will ignore fixup commits. Set to 'false' to disable.
+# ignore-fixup-commits=true
+
+# By default gitlint will ignore squash commits. Set to 'false' to disable.
+# ignore-squash-commits=true
+
+# Enable debug mode (prints more output). Disabled by default.
+# debug=true
+
+# Set the extra-path where gitlint will search for user defined rules
+# See http://jorisroovers.github.io/gitlint/user_defined_rules for details
+# extra-path=examples/
+
+contrib=contrib-title-conventional-commits,contrib-body-requires-signed-off-by
+
+[contrib-title-conventional-commits]
+types=Fix,Feat,Chore,Docs,Style,Refactor,Perf,Test,Revert,CI,Build
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..5624ad6
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,46 @@
+---
+ci:
+ autofix_commit_msg: "Chore: pre-commit autoupdate"
+ skip:
+ # pre-commit.ci does not have actionlint installed
+ - actionlint
+
+repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 # frozen: v4.4.0
+ hooks:
+ - id: trailing-whitespace
+ - id: check-added-large-files
+ - id: check-ast
+ - id: check-json
+ - id: check-merge-conflict
+ - id: check-xml
+ - id: check-yaml
+ - id: debug-statements
+ - id: end-of-file-fixer
+ - id: requirements-txt-fixer
+ - id: mixed-line-ending
+ args: ['--fix=lf']
+ - id: no-commit-to-branch
+ args:
+ - --branch=dev
+ - --branch=master
+ - --branch=main
+ - --branch=rc
+ - --branch=production
+
+ - repo: https://github.com/jorisroovers/gitlint
+ rev: acc9d9de6369b76d22cb4167029d2035e8730b98 # frozen: v0.19.1
+ hooks:
+ - id: gitlint
+
+ - repo: https://github.com/adrienverge/yamllint.git
+ rev: b05e028c5881819161d11cb543fd96a30c06cceb # frozen: v1.32.0
+ hooks:
+ - id: yamllint
+ types: [yaml]
+
+ - repo: https://github.com/rhysd/actionlint
+ rev: fd7ba3c382e13dcc0248e425b4cbc3f1185fa3ee # frozen: v1.6.24
+ hooks:
+ - id: actionlint