-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
127 lines (106 loc) · 3.75 KB
/
lefthook.yml
File metadata and controls
127 lines (106 loc) · 3.75 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
# Lefthook Git Hooks Configuration
# https://lefthook.dev/configuration/
# Auto-fix formatting and linting issues before commit
pre-commit:
# Skip in CI to allow semantic-release commits
skip:
- ref: main
env:
- CI
commands:
format:
glob: "*.{ts,js,tsx,jsx,svelte}"
run: npx biome check --write --unsafe {staged_files}
stage_fixed: true
fail_text: |
❌ Formatting/linting failed!
Could not fix issues in staged files. Please check the error above and fix manually.
validate-workflows:
glob: ".github/workflows/*.{yml,yaml}"
run: |
echo "🔍 Validating workflow files..."
for file in {staged_files}; do
echo " Checking $file with yamllint..."
yamllint "$file" || exit 1
if command -v actionlint >/dev/null 2>&1; then
echo " Checking $file with actionlint..."
actionlint "$file" || exit 1
else
echo " ⚠️ actionlint not found, skipping"
fi
done
echo "✅ All workflow files validated"
fail_text: |
❌ Workflow validation failed!
Install actionlint for better validation:
brew install actionlint # macOS
go install github.com/rhysd/actionlint/cmd/actionlint@latest
# Check formatting before push
pre-push:
commands:
format-check:
run: npx biome ci --diagnostic-level=error .
fail_text: |
❌ Format check failed!
Your code has formatting issues. Run `npm run format` to fix them.
validate-all-workflows:
run: |
echo "🔍 Validating ALL workflow files before push..."
exit_code=0
# Check if any workflow files exist
workflow_count=$(find .github/workflows -name "*.yml" \
-o -name "*.yaml" 2>/dev/null | wc -l)
if [ "$workflow_count" -eq 0 ]; then
echo "No workflow files found, skipping validation"
exit 0
fi
for file in .github/workflows/*.yml .github/workflows/*.yaml; do
[ -f "$file" ] || continue
echo ""
echo "📄 Checking $file..."
# Run yamllint
if ! yamllint "$file" 2>&1; then
echo " ❌ yamllint failed for $file"
exit_code=1
fi
# Run actionlint if available
if command -v actionlint >/dev/null 2>&1; then
if ! actionlint "$file" 2>&1; then
echo " ❌ actionlint failed for $file"
exit_code=1
fi
else
echo " ⚠️ actionlint not found, skipping"
fi
done
if [ $exit_code -eq 0 ]; then
echo ""
echo "✅ All workflow files validated successfully"
fi
exit $exit_code
fail_text: |
❌ Workflow validation failed!
Fix the errors above before pushing.
Install actionlint for better validation:
brew install actionlint # macOS
go install github.com/rhysd/actionlint/cmd/actionlint@latest
# Validate commit messages using commitlint
commit-msg:
# Skip in CI to allow semantic-release commits
skip:
- ref: main
env:
- CI
commands:
commitlint:
run: npx commitlint --edit {1}
fail_text: |
❌ Commit message validation failed!
Your commit message doesn't follow the Conventional Commits specification.
Format: <type>(<scope>): <subject>
Valid types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
Examples:
feat(core): add new collection query method
fix(agents): resolve memory leak in agent pool
docs(readme): update installation instructions
For more info: https://www.conventionalcommits.org/