-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile-processing-matrix-verification.yml
More file actions
385 lines (317 loc) · 15.2 KB
/
file-processing-matrix-verification.yml
File metadata and controls
385 lines (317 loc) · 15.2 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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
---
name: 🔍 File Processing Matrix Verification Agent
"on":
push:
branches: [main, develop]
paths:
- '**/*.md'
- '**/*.py'
- '**/*.js'
- '**/*.ts'
- '**/*.json'
- '**/*.yml'
- '**/*.yaml'
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
schedule:
# Run every 6 hours to verify matrix compliance
- cron: '0 */6 * * *'
workflow_dispatch:
inputs:
verification_scope:
description: 'Scope of verification to perform'
required: true
default: 'full_matrix'
type: choice
options:
- full_matrix
- workflow_compliance
- documentation_sync
- performance_metrics
generate_report:
description: 'Generate detailed compliance report'
required: false
default: true
type: boolean
env:
MATRIX_COMPLIANCE_VERSION: "1.0"
VERIFICATION_ENABLED: true
jobs:
verify-file-processing-matrix:
name: 🔍 Verify File Processing Matrix Compliance
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
steps:
- name: 🔍 Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: 🐍 Setup Python Environment
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: 📦 Install Dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml requests python-frontmatter markdownify beautifulsoup4
- name: 📊 Verify File Processing Matrix Implementation
id: matrix_verification
run: |
python3 << 'EOF'
import os
import yaml
import json
from pathlib import Path
from datetime import datetime
print("🔍 Starting File Processing Matrix Verification...")
# Load workflows and documentation
workflows_dir = Path('.github/workflows')
workflows_docs_dir = Path('.workflows')
verification_results = {
"verification_timestamp": datetime.now().isoformat(),
"matrix_compliance": {},
"workflow_coverage": {},
"missing_implementations": [],
"performance_metrics": {},
"recommendations": []
}
# Expected file types from matrix
expected_file_types = ['.md', '.py', '.js', '.ts', '.json', '.yml', '.yaml']
# Check each workflow for file type coverage
total_workflows = 0
compliant_workflows = 0
for workflow_file in workflows_dir.glob('*.yml'):
total_workflows += 1
with open(workflow_file, 'r') as f:
workflow_content = f.read()
try:
workflow_data = yaml.safe_load(workflow_content)
except yaml.YAMLError as e:
print(f"❌ Invalid YAML in {workflow_file.name}: {e}")
continue
workflow_name = workflow_file.stem
print(f"📋 Analyzing workflow: {workflow_name}")
# Check if workflow has file type triggers
file_triggers = []
has_file_processing = False
if 'on' in workflow_data and workflow_data['on']:
on_config = workflow_data['on']
if isinstance(on_config, dict):
# Check push triggers
if 'push' in on_config and isinstance(on_config['push'], dict):
if 'paths' in on_config['push']:
file_triggers.extend(on_config['push']['paths'])
# Check pull request triggers
if 'pull_request' in on_config and isinstance(on_config['pull_request'], dict):
if 'paths' in on_config['pull_request']:
file_triggers.extend(on_config['pull_request']['paths'])
# Check if covers expected file types
if file_triggers:
covered_types = []
for ext in expected_file_types:
if any(ext in str(trigger) for trigger in file_triggers):
covered_types.append(ext)
has_file_processing = len(covered_types) >= 5 # At least 5 of 7 file types
if has_file_processing:
compliant_workflows += 1
verification_results["workflow_coverage"][workflow_name] = {
"triggers": file_triggers,
"covers_matrix_files": has_file_processing,
"file_types_covered": len([ext for ext in expected_file_types if any(ext in str(trigger) for trigger in file_triggers)])
}
status = "✅ COMPLIANT" if has_file_processing else "❌ NON-COMPLIANT"
print(f" {status} - {len(file_triggers)} triggers, covers {verification_results['workflow_coverage'][workflow_name]['file_types_covered']}/7 file types")
# Calculate matrix compliance score
compliance_score = compliant_workflows / total_workflows if total_workflows > 0 else 0
verification_results["matrix_compliance"] = {
"score": compliance_score,
"compliant_workflows": compliant_workflows,
"total_workflows": total_workflows,
"compliance_percentage": f"{compliance_score:.1%}"
}
print(f"\n📊 Matrix Compliance Summary:")
print(f" Compliant Workflows: {compliant_workflows}/{total_workflows}")
print(f" Compliance Score: {compliance_score:.1%}")
# Check for missing documented workflows
documented_workflows = {
"integrated-documentation-validation.yml": "Security & validation workflow",
"auto-documentation-update.yml": "Automatic documentation updates",
"ai-orchestration-setup.yml": "AI coordination and setup",
"copilot-documentation-agent.yml": "Copilot-powered documentation agent",
"file-processing-matrix-verification.yml": "Matrix compliance verification",
"github-models-documentation-enhancer.yml": "GitHub Models AI enhancement"
}
missing_count = 0
for workflow_name, description in documented_workflows.items():
workflow_path = workflows_dir / workflow_name
if workflow_path.exists():
print(f"✅ {description} - IMPLEMENTED")
else:
print(f"❌ {description} - MISSING")
verification_results["missing_implementations"].append(f"{workflow_name}: {description}")
missing_count += 1
# Performance metrics
verification_results["performance_metrics"] = {
"estimated_processing_times": {
".md": "15-30s per file",
".py": "5-10s per file",
".js/.ts": "10-15s per file",
".json": "1-2s per file",
".yml/.yaml": "2-5s per file"
},
"optimization_status": "Parallel processing configured",
"current_compliance": f"{compliance_score:.1%}",
"target_compliance": "100%"
}
# Generate recommendations
if compliance_score < 0.8:
verification_results["recommendations"].append(
f"Matrix compliance is {compliance_score:.1%} - improve workflow file type coverage"
)
if missing_count > 0:
verification_results["recommendations"].append(
f"Implement {missing_count} missing workflows for full documentation compliance"
)
if compliance_score >= 0.8:
verification_results["recommendations"].append(
"Excellent compliance! Consider optimizing performance and adding advanced features"
)
# Save verification report
with open('matrix_verification_report.json', 'w') as f:
json.dump(verification_results, f, indent=2)
print(f"\n✅ File Processing Matrix Verification completed!")
print(f"📊 Final Compliance Score: {compliance_score:.1%}")
print(f"🔧 Recommendations: {len(verification_results['recommendations'])}")
# Set outputs using proper GitHub Actions syntax
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f"compliance_score={compliance_score:.2f}\n")
f.write(f"missing_count={missing_count}\n")
f.write(f"compliant_workflows={compliant_workflows}\n")
f.write(f"total_workflows={total_workflows}\n")
EOF
- name: 📋 Generate Compliance Report
if: github.event.inputs.generate_report != 'false'
run: |
python3 << 'EOF'
import json
from datetime import datetime
# Load verification results
with open('matrix_verification_report.json', 'r') as f:
results = json.load(f)
# Generate markdown report
report = f"""# 🔍 File Processing Matrix Compliance Report
**Generated:** {results['verification_timestamp']}
**Verification Scope:** ${{ github.event.inputs.verification_scope || 'full_matrix' }}
## 📊 Compliance Summary
- **Matrix Compliance Score:** {results['matrix_compliance']['compliance_percentage']}
- **Compliant Workflows:** {results['matrix_compliance']['compliant_workflows']}/{results['matrix_compliance']['total_workflows']}
- **Status:** {'🟢 EXCELLENT' if results['matrix_compliance']['score'] >= 0.8 else '🟡 NEEDS IMPROVEMENT' if results['matrix_compliance']['score'] >= 0.6 else '🔴 CRITICAL'}
## 🔄 Workflow Coverage Analysis
"""
for workflow, data in results['workflow_coverage'].items():
status = "✅ COMPLIANT" if data['covers_matrix_files'] else "❌ NON-COMPLIANT"
report += f"### {workflow} - {status}\n"
report += f"- **File Type Coverage:** {data['file_types_covered']}/7 file types\n"
report += f"- **File Triggers:** {len(data['triggers'])} configured\n\n"
if results['missing_implementations']:
report += "## ❌ Missing Implementations\n\n"
for missing in results['missing_implementations']:
report += f"- {missing}\n"
report += "\n"
if results['recommendations']:
report += "## 💡 Recommendations\n\n"
for rec in results['recommendations']:
report += f"- {rec}\n"
report += "\n"
report += f"""## ⚡ Performance Metrics
**Estimated Processing Times:**
"""
for file_type, time in results['performance_metrics']['estimated_processing_times'].items():
report += f"- **{file_type}:** {time}\n"
report += f"""
**Current Status:** {results['performance_metrics']['optimization_status']}
**Compliance Target:** {results['performance_metrics']['target_compliance']}
---
*This report is automatically generated every 6 hours by the File Processing Matrix Verification Agent.*
"""
# Save report
with open('MATRIX_COMPLIANCE_REPORT.md', 'w') as f:
f.write(report)
print("📋 Compliance report generated: MATRIX_COMPLIANCE_REPORT.md")
EOF
- name: 🚨 Check Compliance Threshold
id: compliance_check
run: |
COMPLIANCE_SCORE=$(cat matrix_verification_report.json | python3 -c "
import sys, json
data = json.load(sys.stdin)
print(data['matrix_compliance']['score'])
")
MISSING_COUNT=$(cat matrix_verification_report.json | python3 -c "
import sys, json
data = json.load(sys.stdin)
print(len(data['missing_implementations']))
")
echo "Compliance score: $COMPLIANCE_SCORE"
echo "Missing implementations: $MISSING_COUNT"
# Set thresholds
MIN_COMPLIANCE=0.7
MAX_MISSING=2
if (( $(echo "$COMPLIANCE_SCORE < $MIN_COMPLIANCE" | bc -l) )); then
echo "::warning::Matrix compliance below threshold ($COMPLIANCE_SCORE < $MIN_COMPLIANCE)"
echo "compliance_status=warning" >> $GITHUB_OUTPUT
elif [ "$MISSING_COUNT" -gt "$MAX_MISSING" ]; then
echo "::warning::Too many missing implementations ($MISSING_COUNT > $MAX_MISSING)"
echo "compliance_status=warning" >> $GITHUB_OUTPUT
else
echo "::notice::Matrix compliance acceptable ($COMPLIANCE_SCORE >= $MIN_COMPLIANCE)"
echo "compliance_status=success" >> $GITHUB_OUTPUT
fi
- name: 📤 Upload Verification Artifacts
uses: actions/upload-artifact@v4
with:
name: matrix-verification-report-${{ github.run_number }}
path: |
matrix_verification_report.json
MATRIX_COMPLIANCE_REPORT.md
retention-days: 30
- name: 💬 Create Issue for Non-Compliance (if needed)
if: steps.compliance_check.outputs.compliance_status == 'warning'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const reportContent = fs.readFileSync('MATRIX_COMPLIANCE_REPORT.md', 'utf8');
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🚨 File Processing Matrix Compliance Warning',
body: `## File Processing Matrix Compliance Issue Detected
The automated verification agent has detected compliance issues with the file processing matrix implementation.
**Action Required:** Review and address the issues identified in the compliance report.
## Verification Report
${reportContent}
---
**Auto-generated by:** File Processing Matrix Verification Agent
**Run ID:** ${{ github.run_number }}
**Timestamp:** ${new Date().toISOString()}`,
labels: ['automation', 'compliance', 'matrix-verification']
});
console.log(`Created issue #${issue.data.number}`);
- name: ✅ Verification Complete
run: |
echo "🎉 File Processing Matrix Verification completed successfully!"
echo "📊 Compliance status: ${{ steps.compliance_check.outputs.compliance_status || 'success' }}"
echo "📋 Report available in artifacts and repository"
echo "🔍 Monitoring: Automated verification runs every 6 hours"
if [ "${{ steps.compliance_check.outputs.compliance_status }}" = "warning" ]; then
echo "⚠️ Compliance issues detected - check the generated issue for details"
else
echo "✅ All systems compliant with file processing matrix specifications"
fi