-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (162 loc) · 6.47 KB
/
validate.yml
File metadata and controls
195 lines (162 loc) · 6.47 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
name: Validate Customizations
on:
pull_request:
branches:
- main
paths:
- ".github/agents/**"
- ".github/skills/**"
- ".github/instructions/**"
push:
branches:
- main
paths:
- ".github/agents/**"
- ".github/skills/**"
- ".github/instructions/**"
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: 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 }}
))
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