-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlefthook.yml
More file actions
142 lines (133 loc) · 4.35 KB
/
lefthook.yml
File metadata and controls
142 lines (133 loc) · 4.35 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Lefthook configuration for Scopes project
# https://github.com/evilmartians/lefthook
pre-commit:
parallel: true
commands:
editorconfig:
glob: "*"
exclude: ".claude/.*|tmp/.*|LICENSE|gradle/verification-metadata.xml"
run: |
docker run --rm -v "$(pwd):/workspace" \
-w /workspace \
mstruebing/editorconfig-checker:latest \
ec --exclude LICENSE --exclude gradle/verification-metadata.xml \
{staged_files} || true
skip:
- merge
- rebase
spotless:
glob: "**/*.{kt,kts,json,yml,yaml,md,sh}"
run: ./gradlew spotlessApply --daemon
stage_fixed: true
skip:
- merge
- rebase
detekt:
glob: "**/*.kt"
run: ./gradlew detekt --daemon
skip:
- merge
- rebase
kotlin-test:
glob: "**/*.kt"
run: ./gradlew test --daemon
skip:
- merge
- rebase
shellcheck:
glob: "**/*.sh"
run: |
if command -v shellcheck &> /dev/null; then
echo "🔍 Running shellcheck on shell scripts..."
shellcheck {staged_files}
else
echo "❌ shellcheck not found!"
echo " Please install shellcheck to validate shell scripts:"
echo " • macOS: brew install shellcheck"
echo " • Ubuntu/Debian: sudo apt install shellcheck"
echo " • CentOS/RHEL: sudo yum install shellcheck"
echo " • Or download from: https://github.com/koalaman/shellcheck"
echo ""
echo " Skipping shell script validation for now..."
exit 1
fi
skip:
- merge
- rebase
yamllint:
glob: "**/*.{yml,yaml}"
run: |
if command -v yamllint &> /dev/null; then
echo "🔍 Running yamllint on YAML files..."
yamllint {staged_files}
else
echo "❌ yamllint not found!"
echo " Please install yamllint to validate YAML files:"
echo " • macOS: brew install yamllint"
echo " • Ubuntu/Debian: sudo apt install yamllint"
echo " • CentOS/RHEL: sudo yum install yamllint"
echo " • Or install with pip: pip install yamllint"
echo ""
echo " Skipping YAML validation for now..."
exit 1
fi
skip:
- merge
- rebase
shfmt:
glob: "**/*.sh"
run: |
if command -v shfmt &> /dev/null; then
echo "🔍 Checking shell script formatting with shfmt..."
# Check if files need formatting
if ! shfmt -d -i 2 -ci {staged_files}; then
echo "❌ Shell scripts need formatting!"
echo " Run: shfmt -w -i 2 -ci {staged_files}"
exit 1
fi
echo "✅ Shell scripts are properly formatted"
else
echo "❌ shfmt not found!"
echo " Please install shfmt to format shell scripts:"
echo " • macOS: brew install shfmt"
echo " • Ubuntu/Debian: sudo apt install shfmt"
echo " • Or download from: https://github.com/mvdan/sh"
echo ""
echo " Skipping shell script formatting check for now..."
exit 1
fi
skip:
- merge
- rebase
# Claude Code integration - runs after file edits
post-tool-use-edit:
parallel: true
commands:
spotless-format:
glob: "**/*.{kt,kts,json,yml,yaml,md,sh}"
run: |
echo "🔧 Auto-formatting file: {files}"
./gradlew spotlessApply --daemon --quiet
echo "✅ Spotless formatting completed"
detekt-check:
glob: "**/*.kt"
run: |
echo "🔍 Running Detekt analysis with auto-correction"
./gradlew detekt -Pdetekt.autoCorrect=true --daemon --quiet || true
echo "✅ Detekt analysis completed"
# Optional: Run tests for the affected module only
module-test:
glob: "**/*.kt"
run: |
# Extract module from file path and run tests for that module only
MODULE_PATH=$(echo "{file}" | cut -d'/' -f1)
if [ -f "$MODULE_PATH/build.gradle.kts" ]; then
echo "Running tests for module: $MODULE_PATH"
./gradlew :$MODULE_PATH:test --daemon --quiet
else
echo "No module found for {file}, skipping tests"
fi
# Skip hooks during CI/CD
skip_output:
- meta
- success