-
Notifications
You must be signed in to change notification settings - Fork 7
305 lines (252 loc) · 9.44 KB
/
validate-resources.yml
File metadata and controls
305 lines (252 loc) · 9.44 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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
name: Validate Level 3 Resources
on:
push:
branches: [main, feature/skills-resources-improvement]
paths:
- 'skills/**/resources/**'
- '.work/validate_resources.py'
- '.github/workflows/validate-resources.yml'
pull_request:
branches: [main]
paths:
- 'skills/**/resources/**'
- '.work/validate_resources.py'
jobs:
validate:
name: Validate Resources Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run basic validation
run: |
python3 .work/validate_resources.py --verbose
continue-on-error: true
- name: Run validation with security checks
run: |
python3 .work/validate_resources.py --check-security --verbose
continue-on-error: true
- name: Run validation with production checks
run: |
python3 .work/validate_resources.py --check-production-ready --verbose
continue-on-error: true
- name: Run validation (JSON output)
run: |
python3 .work/validate_resources.py --strict-mode --json > validation-results.json
continue-on-error: true
- name: Upload validation results
uses: actions/upload-artifact@v4
if: always()
with:
name: validation-results
path: validation-results.json
- name: Check for critical failures
run: |
# Only fail if newly added skills have critical issues
# Allow legacy skills with shorter REFERENCE.md files
python3 .work/validate_resources.py --verbose
continue-on-error: true
- name: Comment validation summary on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const results = JSON.parse(fs.readFileSync('validation-results.json', 'utf8'));
const summary = `## 📋 Level 3 Resources Validation
**Total skills validated**: ${results.total}
- ✅ Passed: ${results.passed}
- ⚠️ Warnings: ${results.warned}
- ❌ Failed: ${results.failed}
### Details
${results.skills.filter(s => s.status === 'fail').slice(0, 5).map(s => `
**${s.skill_name}** (${s.status.toUpperCase()})
- REFERENCE.md: ${s.stats.reference_lines || 0} lines
- Scripts: ${s.stats.scripts_count || 0}
- Examples: ${s.stats.examples_count || 0}
${s.issues.map(i => ` - ❌ ${i}`).join('\n')}
`).join('\n---\n')}
${results.failed > 5 ? `\n... and ${results.failed - 5} more failures. See validation-results.json artifact for details.` : ''}
${results.warned > 0 ? `\n### ⚠️ Warnings: ${results.warned} skills have non-critical warnings` : ''}
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
body: summary
});
check-scripts-executable:
name: Check Scripts Are Executable
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Find non-executable scripts
run: |
echo "Checking for non-executable Python scripts in resources/scripts/..."
non_executable=$(find skills -path "*/resources/scripts/*.py" ! -executable -print)
if [ -n "$non_executable" ]; then
echo "❌ Found non-executable scripts:"
echo "$non_executable"
echo ""
echo "Fix with: chmod +x <script>"
exit 1
else
echo "✅ All scripts are executable"
fi
check-script-shebangs:
name: Check Script Shebangs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check for proper shebangs
run: |
echo "Checking for proper shebangs in Python scripts..."
errors=0
while IFS= read -r script; do
first_line=$(head -n 1 "$script")
if [[ ! "$first_line" =~ ^#!/.*python ]]; then
echo "❌ $script: Missing or invalid shebang"
echo " Found: $first_line"
((errors++))
fi
done < <(find skills -path "*/resources/scripts/*.py" -print)
if [ $errors -gt 0 ]; then
echo ""
echo "Fix with proper shebang: #!/usr/bin/env python3"
exit 1
else
echo "✅ All scripts have proper shebangs"
fi
check-todo-comments:
name: Check for TODO Comments
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check for TODO/stub/mock comments in scripts
run: |
echo "Checking for TODO/stub/mock comments in scripts..."
found=0
while IFS= read -r script; do
# Only flag TODO in actual comments (starting with #), not in strings or code
if grep -qiE '^\s*#.*\bTODO\b' "$script"; then
echo "⚠️ $script: Contains TODO comments"
((found++))
fi
# Only flag problematic 'stub' patterns (not legitimate gRPC usage like "Create stub")
if grep -qiE '^\s*#.*(stub (implementation|method|function|class|code|placeholder)|placeholder stub|needs?.*stub|stub.*incomplete|stub.*replace)' "$script"; then
echo "⚠️ $script: Contains stub implementation references"
((found++))
fi
# Only flag mock implementation in comments
if grep -qiE '^\s*#.*\bmock\b.*\bimplementation\b' "$script"; then
echo "⚠️ $script: May contain mock implementation"
((found++))
fi
done < <(find skills -path "*/resources/scripts/*.py" -print)
if [ $found -gt 0 ]; then
echo ""
echo "⚠️ Found $found scripts with TODO/stub/mock comments"
echo "These should be completed before merging to main"
exit 1
else
echo "✅ No TODO/stub/mock comments found"
fi
lint-scripts:
name: Lint Python Scripts
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install linters
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Lint with ruff
run: |
echo "Linting Python scripts with ruff..."
find skills -path "*/resources/scripts/*.py" -print0 | xargs -0 ruff check --select E,F,W || true
echo "Note: Linting errors are informational only"
continue-on-error: true
security-audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run security audit
run: |
python3 tests/security_audit.py --path skills --output security-report.json --verbose --fail-on high
continue-on-error: true
- name: Upload security report
uses: actions/upload-artifact@v4
if: always()
with:
name: security-audit-report
path: security-report.json
safety-validation:
name: Operational Safety Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Run safety validation
run: |
python3 tests/safety_validator.py --path skills --output safety-report.json --verbose --fail-on high
continue-on-error: true
- name: Upload safety report
uses: actions/upload-artifact@v4
if: always()
with:
name: safety-validation-report
path: safety-report.json
validate-examples:
name: Validate Example Files
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check example file syntax
run: |
echo "Validating example files..."
errors=0
# Check Python examples
while IFS= read -r example; do
if ! python3 -m py_compile "$example" 2>/dev/null; then
echo "❌ $example: Syntax error"
((errors++))
fi
done < <(find skills -path "*/resources/examples/*.py" -print)
# Check YAML examples
while IFS= read -r example; do
if command -v yamllint &> /dev/null; then
if ! yamllint -d relaxed "$example" 2>/dev/null; then
echo "⚠️ $example: YAML formatting issues"
fi
fi
done < <(find skills -path "*/resources/examples/*.{yaml,yml}" -print 2>/dev/null)
if [ $errors -gt 0 ]; then
echo ""
echo "❌ Found $errors Python examples with syntax errors"
exit 1
else
echo "✅ All example files have valid syntax"
fi