1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
repos:
# Pre-commit hooks for general code quality
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-merge-conflict
- id: check-added-large-files
args:
- id: mixed-line-ending
# Rust-specific hooks
- repo: local
hooks:
# Format code with rustfmt
- id: cargo-fmt
name: cargo fmt
description: Format Rust code with rustfmt
entry: cargo fmt --all --
language: system
types:
pass_filenames: false
# Lint with clippy
- id: cargo-clippy
name: cargo clippy
description: Lint Rust code with clippy
entry: cargo clippy --all-targets --all-features -- -D warnings
language: system
types:
pass_filenames: false
# Check compilation
- id: cargo-check
name: cargo check
description: Check that Rust code compiles
entry: cargo check --all-targets --all-features
language: system
types:
pass_filenames: false
# Run unit tests (fast)
# - id: cargo-test
# name: cargo test
# description: Run Rust unit tests
# entry: cargo test --lib --bins --tests
# language: system
# types: [rust]
# pass_filenames: false
# Security audit (optional, can be slow)
- repo: local
hooks:
- id: cargo-audit
name: cargo audit
description: Audit Rust dependencies for security vulnerabilities
entry: bash
args:
- -c
- |
if command -v cargo-audit >/dev/null 2>&1; then
cargo audit
else
echo "cargo-audit not installed, skipping security check"
fi
language: system
types:
pass_filenames: false
stages: # Only run on push, not commit
# Configuration for specific hooks
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip:
submodules: false