-
Notifications
You must be signed in to change notification settings - Fork 0
279 lines (232 loc) · 9.4 KB
/
validate.yml
File metadata and controls
279 lines (232 loc) · 9.4 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
name: Validate Customizations
on:
pull_request:
branches:
- main
paths:
- ".github/agents/**"
- ".github/skills/**"
- ".github/instructions/**"
- ".github/hooks/**"
- ".github/mcp.json"
- ".mcp.json"
push:
branches:
- main
paths:
- ".github/agents/**"
- ".github/skills/**"
- ".github/instructions/**"
- ".github/hooks/**"
- ".github/mcp.json"
- ".mcp.json"
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Validate Agent Files
id: validate_agents
run: |
echo "## 🤖 Agent Validation" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=0
if [ -d ".github/agents" ]; then
AGENTS=$(find .github/agents -name "*.agent.md" | sort)
if [ -z "$AGENTS" ]; then
echo "✅ No agent files found" >> $GITHUB_STEP_SUMMARY
else
for file in $AGENTS; do
echo "Checking: $file"
if ! head -1 "$file" | grep -q "^---$"; then
echo "❌ Missing YAML frontmatter: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
else
echo "✅ Valid structure: $file" >> $GITHUB_STEP_SUMMARY
fi
if ! grep -q "^description:" "$file"; then
echo "⚠️ Missing 'description' field: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
done
fi
else
echo "ℹ️ No agents directory found" >> $GITHUB_STEP_SUMMARY
fi
echo "error_count_agents=$ERROR_COUNT" >> $GITHUB_OUTPUT
- name: Validate Skill Files
id: validate_skills
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 🎯 Skill Validation" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=0
if [ -d ".github/skills" ]; then
SKILLS=$(find .github/skills -name "SKILL.md" | sort)
if [ -z "$SKILLS" ]; then
echo "✅ No skill files found" >> $GITHUB_STEP_SUMMARY
else
for file in $SKILLS; do
echo "Checking: $file"
if ! head -1 "$file" | grep -q "^---$"; then
echo "❌ Missing YAML frontmatter: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
if ! grep -q "^name:" "$file"; then
echo "⚠️ Missing 'name' field: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
if ! grep -q "^description:" "$file"; then
echo "⚠️ Missing 'description' field: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
if grep -q -i "usage\|how to use\|example\|when to use" "$file"; then
echo "✅ Valid structure: $file" >> $GITHUB_STEP_SUMMARY
else
echo "⚠️ Missing usage/examples: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
done
fi
else
echo "ℹ️ No skills directory found" >> $GITHUB_STEP_SUMMARY
fi
echo "error_count_skills=$ERROR_COUNT" >> $GITHUB_OUTPUT
- name: Validate Instruction Files
id: validate_instructions
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📋 Instructions Validation" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=0
if [ -d ".github/instructions" ]; then
INSTRUCTIONS=$(find .github/instructions -name "*.instructions.md" | sort)
if [ -z "$INSTRUCTIONS" ]; then
echo "✅ No instruction files found" >> $GITHUB_STEP_SUMMARY
else
for file in $INSTRUCTIONS; do
echo "Checking: $file"
if ! head -1 "$file" | grep -q "^---$"; then
echo "❌ Missing YAML frontmatter: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
if ! grep -q "^applyTo:" "$file"; then
echo "⚠️ Missing 'applyTo' field: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
else
echo "✅ Valid structure: $file" >> $GITHUB_STEP_SUMMARY
fi
done
fi
else
echo "ℹ️ No instructions directory found" >> $GITHUB_STEP_SUMMARY
fi
echo "error_count_instructions=$ERROR_COUNT" >> $GITHUB_OUTPUT
- name: Validate Hook Files
id: validate_hooks
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 🪝 Hook Validation" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=0
if [ -d ".github/hooks" ]; then
HOOKS=$(find .github/hooks -name "*.json" | sort)
if [ -z "$HOOKS" ]; then
echo "✅ No hook files found" >> $GITHUB_STEP_SUMMARY
else
for file in $HOOKS; do
echo "Checking: $file"
if ! jq empty "$file" >/dev/null 2>&1; then
echo "❌ Invalid JSON: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
continue
fi
VERSION=$(jq -r '.version // empty' "$file")
if [ "$VERSION" != "1" ]; then
echo "❌ Missing or invalid version: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
if ! jq -e '.hooks | type == "object"' "$file" >/dev/null 2>&1; then
echo "❌ Missing hooks object: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
else
echo "✅ Valid structure: $file" >> $GITHUB_STEP_SUMMARY
fi
done
fi
else
echo "ℹ️ No hooks directory found" >> $GITHUB_STEP_SUMMARY
fi
echo "error_count_hooks=$ERROR_COUNT" >> $GITHUB_OUTPUT
- name: Validate MCP Configuration
id: validate_mcp
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 🔌 MCP Validation" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=0
for file in .github/mcp.json .mcp.json; do
if [ ! -f "$file" ]; then
continue
fi
echo "Checking: $file"
if ! jq empty "$file" >/dev/null 2>&1; then
echo "❌ Invalid JSON: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
continue
fi
if ! jq -e '.mcpServers | type == "object"' "$file" >/dev/null 2>&1; then
echo "❌ Missing mcpServers object: $file" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=$((ERROR_COUNT + 1))
else
echo "✅ Valid structure: $file" >> $GITHUB_STEP_SUMMARY
fi
done
if [ ! -f ".github/mcp.json" ] && [ ! -f ".mcp.json" ]; then
echo "ℹ️ No repository or workspace MCP config found" >> $GITHUB_STEP_SUMMARY
fi
echo "error_count_mcp=$ERROR_COUNT" >> $GITHUB_OUTPUT
- name: Check for Broken Links
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 🔗 Link Validation" >> $GITHUB_STEP_SUMMARY
FILES=$(find .github/agents .github/skills .github/instructions -name "*.md" 2>/dev/null || true)
if [ -z "$FILES" ]; then
echo "ℹ️ No markdown files to check" >> $GITHUB_STEP_SUMMARY
else
BROKEN_LINKS=0
for file in $FILES; do
LINKS=$(grep -oP '\[.*?\]\(\K[^)]+(?=\))' "$file" 2>/dev/null | grep -v "^http" || true)
for link in $LINKS; do
LINK_PATH=$(echo "$link" | cut -d'#' -f1)
if [ -z "$LINK_PATH" ]; then continue; fi
DIR=$(dirname "$file")
FULL_PATH="$DIR/$LINK_PATH"
if [ ! -e "$FULL_PATH" ]; then
echo "❌ Broken link in $file: $link" >> $GITHUB_STEP_SUMMARY
BROKEN_LINKS=$((BROKEN_LINKS + 1))
fi
done
done
if [ $BROKEN_LINKS -eq 0 ]; then
echo "✅ No broken links found" >> $GITHUB_STEP_SUMMARY
fi
fi
- name: Summary
run: |
TOTAL_ERRORS=$((
${{ steps.validate_agents.outputs.error_count_agents }} +
${{ steps.validate_skills.outputs.error_count_skills }} +
${{ steps.validate_instructions.outputs.error_count_instructions }} +
${{ steps.validate_hooks.outputs.error_count_hooks }} +
${{ steps.validate_mcp.outputs.error_count_mcp }}
))
echo "" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
if [ $TOTAL_ERRORS -eq 0 ]; then
echo "### ✅ All validations passed!" >> $GITHUB_STEP_SUMMARY
exit 0
else
echo "### ⚠️ Found $TOTAL_ERRORS issue(s)" >> $GITHUB_STEP_SUMMARY
exit 1
fi