From 61a8bea41ebfdbe6c4a8cc89501fd34797d1815c Mon Sep 17 00:00:00 2001 From: thek4n Date: Tue, 2 Jun 2026 16:19:16 +0300 Subject: [PATCH] ci(pre-commit): add pre-commit --- .pre-commit-config.yaml | 67 +++++++++++++++++++++++++++++++++++++++++ rust-toolchain.toml | 3 ++ 2 files changed, 70 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 rust-toolchain.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6668ce3 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,67 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + # - id: no-commit-to-branch + # args: [--branch, master, --branch, main, --pattern, release/.*] + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: mixed-line-ending + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-executables-have-shebangs + + - repo: https://github.com/jorisroovers/gitlint + rev: v0.19.1 + hooks: + - id: gitlint + args: [ + "--ignore", "body-is-missing", "--contrib=CT1", "--msg-filename" + ] + stages: [commit-msg] + + - repo: local + hooks: + - id: clippy + name: clippy + language: system + entry: cargo clippy --release -- -W clippy::all -W clippy::pedantic + pass_filenames: false + always_run: true + + - id: audit + name: Security check + language: system + entry: cargo audit + pass_filenames: false + always_run: true + + - id: deny + name: Dependency policy check + language: system + entry: cargo deny check + pass_filenames: false + always_run: true + + - id: tarpaulin + name: Test coverage gate + language: system + entry: cargo tarpaulin --fail-under 80 + pass_filenames: false + always_run: true + + - id: cargo-fmt + name: cargo fmt + language: system + entry: cargo fmt --check + pass_filenames: false + always_run: true + + - id: check-todos # [NOGREP] + name: check-todos # [NOGREP] + language: system + entry: sh -c "! grep --color=always --binary-files=without-match --dereference-recursive --exclude-dir='notes' --exclude-dir='target' --exclude-dir='node_modules' --exclude-dir='.git' --exclude='.pre-commit-config.yaml' --exclude-dir='venv' 'TODO' | grep -v '[NOGREP]'" # [NOGREP] + pass_filenames: false + always_run: true diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..d0ead5e --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +components = ["clippy", "rustfmt"]