-
Notifications
You must be signed in to change notification settings - Fork 1
235 lines (196 loc) · 8.17 KB
/
validate.yml
File metadata and controls
235 lines (196 loc) · 8.17 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
name: Validate Customizations
on:
pull_request:
branches:
- main
paths:
- ".github/agents/**"
- ".github/prompts/**"
- ".github/skills/**"
push:
branches:
- main
paths:
- ".github/agents/**"
- ".github/prompts/**"
- ".github/skills/**"
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install pyyaml
- 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"
# Check if file has YAML frontmatter
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
# Check for required fields (name, description)
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
done
fi
else
echo "ℹ️ No agents directory found" >> $GITHUB_STEP_SUMMARY
fi
echo "error_count_agents=$ERROR_COUNT" >> $GITHUB_OUTPUT
- name: Validate Prompt Files
id: validate_prompts
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📝 Prompt Validation" >> $GITHUB_STEP_SUMMARY
ERROR_COUNT=0
if [ -d ".github/prompts" ]; then
PROMPTS=$(find .github/prompts -name "*.prompt.md" | sort)
if [ -z "$PROMPTS" ]; then
echo "✅ No prompt files found" >> $GITHUB_STEP_SUMMARY
else
for file in $PROMPTS; do
echo "Checking: $file"
# Check if file has YAML frontmatter
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
# Check for required fields
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
done
fi
else
echo "ℹ️ No prompts directory found" >> $GITHUB_STEP_SUMMARY
fi
echo "error_count_prompts=$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"
# Check for required sections
HAS_NAME=false
HAS_DESC=false
HAS_USAGE=false
if grep -q "^## Name" "$file" || grep -q "^# " "$file"; then
HAS_NAME=true
fi
if grep -q -i "description" "$file"; then
HAS_DESC=true
fi
if grep -q -i "usage\|how to use\|example" "$file"; then
HAS_USAGE=true
fi
if [ "$HAS_NAME" = true ] && [ "$HAS_DESC" = true ] && [ "$HAS_USAGE" = true ]; then
echo "✅ Valid structure: $file" >> $GITHUB_STEP_SUMMARY
else
echo "⚠️ Incomplete structure: $file" >> $GITHUB_STEP_SUMMARY
[ "$HAS_NAME" = false ] && echo " - Missing name/title" >> $GITHUB_STEP_SUMMARY
[ "$HAS_DESC" = false ] && echo " - Missing description" >> $GITHUB_STEP_SUMMARY
[ "$HAS_USAGE" = false ] && echo " - Missing usage/examples" >> $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: Check for Broken Links
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 🔗 Link Validation" >> $GITHUB_STEP_SUMMARY
# Find all markdown files in customization directories
FILES=$(find .github/agents .github/prompts .github/skills -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
# Extract relative links (not starting with http)
LINKS=$(grep -oP '\[.*?\]\(\K[^)]+(?=\))' "$file" 2>/dev/null | grep -v "^http" || true)
for link in $LINKS; do
# Remove anchor
LINK_PATH=$(echo "$link" | cut -d'#' -f1)
# Skip empty paths (anchor-only links)
if [ -z "$LINK_PATH" ]; then
continue
fi
# Resolve relative path
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
else
echo "⚠️ Found $BROKEN_LINKS broken link(s)" >> $GITHUB_STEP_SUMMARY
fi
fi
- name: Summary
run: |
TOTAL_ERRORS=$((
${{ steps.validate_agents.outputs.error_count_agents }} +
${{ steps.validate_prompts.outputs.error_count_prompts }} +
${{ steps.validate_skills.outputs.error_count_skills }}
))
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
echo "" >> $GITHUB_STEP_SUMMARY
echo "Please review and fix the issues listed above." >> $GITHUB_STEP_SUMMARY
exit 1
fi