-
Notifications
You must be signed in to change notification settings - Fork 4
201 lines (166 loc) · 5.89 KB
/
validate.yml
File metadata and controls
201 lines (166 loc) · 5.89 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
name: Validate Lola Modules
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
validate-structure:
name: Validate Module Structure
runs-on: ubuntu-latest
strategy:
matrix:
module: [ansible-collection, ansible-role, ansible-collection-development]
steps:
- uses: actions/checkout@v4
- name: Check required directories exist
run: |
module="${{ matrix.module }}"
echo "Checking $module structure..."
# Check module/ directory exists
if [ ! -d "$module/module" ]; then
echo "❌ $module/module/ directory missing"
exit 1
fi
# Check required files
for file in AGENTS.md mcps.json; do
if [ ! -f "$module/module/$file" ]; then
echo "❌ $module/module/$file missing"
exit 1
fi
done
# Check required subdirectories
for dir in commands skills agents; do
if [ ! -d "$module/module/$dir" ]; then
echo "❌ $module/module/$dir/ directory missing"
exit 1
fi
done
echo "✅ $module structure valid"
validate-frontmatter:
name: Validate Frontmatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: pip install pyyaml
- name: Validate command frontmatter
run: |
python3 << 'EOF'
import yaml
import sys
from pathlib import Path
errors = []
# Find all command files
for cmd_file in Path('.').glob('*/module/commands/*.md'):
with open(cmd_file) as f:
content = f.read()
# Extract frontmatter
if not content.startswith('---'):
errors.append(f"{cmd_file}: Missing frontmatter")
continue
parts = content.split('---', 2)
if len(parts) < 3:
errors.append(f"{cmd_file}: Invalid frontmatter format")
continue
try:
fm = yaml.safe_load(parts[1])
except yaml.YAMLError as e:
errors.append(f"{cmd_file}: Invalid YAML - {e}")
continue
# Check required fields
if 'description' not in fm:
errors.append(f"{cmd_file}: Missing 'description' field")
if 'argument-hint' not in fm:
errors.append(f"{cmd_file}: Missing 'argument-hint' field")
if errors:
print("❌ Frontmatter validation errors:")
for error in errors:
print(f" - {error}")
sys.exit(1)
print("✅ All command frontmatter valid")
EOF
- name: Validate skill frontmatter
run: |
python3 << 'EOF'
import yaml
import sys
from pathlib import Path
errors = []
# Find all skill SKILL.md files
for skill_file in Path('.').glob('*/module/skills/*/SKILL.md'):
with open(skill_file) as f:
content = f.read()
# Extract frontmatter
if not content.startswith('---'):
errors.append(f"{skill_file}: Missing frontmatter")
continue
parts = content.split('---', 2)
if len(parts) < 3:
errors.append(f"{skill_file}: Invalid frontmatter format")
continue
try:
fm = yaml.safe_load(parts[1])
except yaml.YAMLError as e:
errors.append(f"{skill_file}: Invalid YAML - {e}")
continue
# Check required fields
if 'name' not in fm:
errors.append(f"{skill_file}: Missing 'name' field")
if 'description' not in fm:
errors.append(f"{skill_file}: Missing 'description' field")
if errors:
print("❌ Frontmatter validation errors:")
for error in errors:
print(f" - {error}")
sys.exit(1)
print("✅ All skill frontmatter valid")
EOF
validate-json:
name: Validate JSON Files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate mcps.json files
run: |
for json_file in */module/mcps.json; do
echo "Checking $json_file..."
if ! jq empty "$json_file" 2>/dev/null; then
echo "❌ $json_file is not valid JSON"
exit 1
fi
# Check for mcpServers key
if ! jq -e '.mcpServers' "$json_file" >/dev/null; then
echo "❌ $json_file missing 'mcpServers' key"
exit 1
fi
done
echo "✅ All JSON files valid"
check-placeholders:
name: Check for Placeholders
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for placeholder text outside template/
run: |
if grep -r '\[REPLACE:' --exclude-dir=template --exclude-dir=.git --exclude-dir=tmp --exclude-dir=.github .; then
echo "❌ Found unreplaced placeholder text outside template/ directory"
exit 1
fi
echo "✅ No placeholder text found"
validate-references:
name: Validate File References
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check zen-of-ansible.txt exists
run: |
if [ ! -f "ansible-collection/module/skills/ansible-zen/zen-of-ansible.txt" ]; then
echo "❌ zen-of-ansible.txt missing"
exit 1
fi
echo "✅ Referenced files exist"