-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathlefthook.yml
More file actions
197 lines (183 loc) · 6.51 KB
/
Copy pathlefthook.yml
File metadata and controls
197 lines (183 loc) · 6.51 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Lefthook configuration
# See https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
#
# To install: lefthook install
# To skip: LEFTHOOK=0 git commit/push
# To install tools: make bootstrap
pre-commit:
parallel: true
commands:
# Format and lint Go code with auto-fix (includes gofumpt and goimports)
go-lint-fix:
tags: backend lint style
glob: "*.go"
run: |
if ! command -v golangci-lint > /dev/null 2>&1; then
echo "⚠️ golangci-lint not found. Run 'make bootstrap' to install tools."
echo " Skipping Go formatting and linting check..."
exit 0
fi
# Get unique package directories from staged files
packages=$(echo {staged_files} | xargs -n1 dirname | sort -u | xargs -I {} echo "./{}")
if [ -n "$packages" ]; then
golangci-lint run --fix $packages
fi
stage_fixed: true
# Lint shell scripts
shellcheck:
tags: shell lint
glob: "*.sh"
run: |
if ! command -v shellcheck > /dev/null 2>&1; then
echo "⚠️ shellcheck not found. Run 'make bootstrap' to install tools."
echo " Skipping shell script linting..."
exit 0
fi
shellcheck {staged_files}
# Fix markdown formatting issues
markdownlint-fix:
tags: docs style
glob: "*.md"
run: |
if ! command -v markdownlint-cli2 > /dev/null 2>&1; then
echo "⚠️ markdownlint-cli2 not found. Run 'make bootstrap' to install tools."
echo " Skipping markdown auto-fix..."
exit 0
fi
markdownlint-cli2 --fix {staged_files}
git add {staged_files}
stage_fixed: true
# Fail fast if any skill source can't be loaded — covers a missing
# SKILL.md, unparseable frontmatter, an empty `name` or `description`,
# a directory mismatch in bundled assets, or a malformed remote
# registry entry. Full Agent Skills spec compliance
# (https://agentskills.io/specification) is hand-reviewed in MRs,
# not enforced here.
validate-skills:
tags: backend skills
glob: "internal/commands/skills/**"
run: |
if ! command -v go > /dev/null 2>&1; then
echo "⚠️ go not found. Skipping skills validation..."
exit 0
fi
go test ./internal/commands/skills/...
# Check if documentation needs regeneration
check-docs:
tags: docs
glob: "internal/commands/**/*.go"
run: |
echo "Checking if documentation needs regeneration..."
make gen-docs > /dev/null 2>&1
if git diff --quiet docs/; then
echo "✔ Documentation is up to date."
exit 0
else
echo ""
echo "✖ ERROR: Documentation changes detected!"
echo ""
echo "Command files were modified and documentation is out of sync."
echo "The documentation has been regenerated for you."
echo ""
echo "Next steps:"
echo " 1. Review the changes in docs/"
echo " 2. Stage the changes: git add docs/"
echo " 3. Commit again"
echo ""
exit 1
fi
commit-msg:
commands:
# Validate commit message format using conventional commits
commitlint:
run: |
if ! command -v node > /dev/null 2>&1; then
echo "⚠️ node not found. Commit message validation requires Node.js."
echo " Skipping commit message validation..."
exit 0
fi
# Install commitlint dependencies if not already installed
if [ ! -d "scripts/commit-lint/node_modules" ]; then
echo "Installing commitlint dependencies (one-time setup)..."
cd scripts/commit-lint && npm install
else
cd scripts/commit-lint
fi
npx commitlint --config .commitlintrc.js --edit {1}
pre-push:
parallel: true
commands:
# Build the project
build:
tags: backend
run: make build
# Lint Go code (only changes vs main)
go-lint:
tags: backend lint
run: |
if ! command -v golangci-lint > /dev/null 2>&1; then
echo "⚠️ golangci-lint not found. Run 'make bootstrap' to install tools."
echo " Skipping Go linting..."
exit 0
fi
golangci-lint run --new-from-rev=origin/main
# Run unit tests on changed packages and their reverse dependencies
go-test:
tags: backend test
run: make test-changed
# Check generated docs and Go code. Chained into one command because both
# mutate the working tree and check git diff — running them in parallel
# would cause false positives.
check-generated:
tags: backend docs
run: |
# Skip if no command files changed vs origin/main
if git diff --quiet origin/main -- internal/commands/ cmd/gen-docs/; then
echo "✔ No command changes detected. Skipping doc generation check."
exit 0
fi
make gen-docs > /dev/null 2>&1
if ! git diff --quiet docs/; then
echo "✖ Generated docs or navigation are out of date. Run 'make gen-docs', then commit."
exit 1
fi
echo "✔ Documentation is up to date."
make generate > /dev/null 2>&1
if ! git diff --quiet; then
echo "✖ Generated Go code is out of date. Run 'make generate' and commit."
exit 1
fi
echo "✔ Generated code is up to date."
# Lint markdown files
markdownlint:
tags: docs lint
glob: "*.md"
run: |
if ! command -v markdownlint-cli2 > /dev/null 2>&1; then
echo "⚠️ markdownlint-cli2 not found. Run 'make bootstrap' to install tools."
echo " Skipping markdown linting..."
exit 0
fi
markdownlint-cli2 {push_files}
# Check prose style
vale:
tags: docs prose
glob: "docs/**/*.md"
run: |
if ! command -v vale > /dev/null 2>&1; then
echo "⚠️ vale not found. Run 'make bootstrap' to install tools."
echo " Skipping prose checking..."
exit 0
fi
vale --minAlertLevel error {push_files}
# Check links in documentation (can be slow)
lychee:
tags: docs links
glob: "*.md"
run: |
if ! command -v lychee > /dev/null 2>&1; then
echo "⚠️ lychee not found. Run 'make bootstrap' to install tools."
echo " Skipping link checking..."
exit 0
fi
lychee --offline --include-fragments {push_files}