-
Notifications
You must be signed in to change notification settings - Fork 1
357 lines (304 loc) Β· 10.9 KB
/
documentation-validation.yml
File metadata and controls
357 lines (304 loc) Β· 10.9 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
name: Documentation Quality Gate
on:
pull_request:
paths:
- '**/*.md'
- 'docs/**'
- 'scripts/documentation/**'
- '.github/workflows/documentation-validation.yml'
push:
branches: [main, develop]
schedule:
- cron: '0 0 * * 0' # Weekly full scan on Sunday
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
env:
PYTHON_VERSION: "3.11"
UV_VERSION: "0.5.7"
jobs:
validate-links:
name: Validate Documentation Links
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install UV
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Create output directory
run: mkdir -p output
- name: Run link validation
run: |
uv run python scripts/documentation/validate_links_comprehensive.py \
--repo-root . \
--output output \
--format both \
--fail-on-broken
- name: Upload link validation results
uses: actions/upload-artifact@v4
if: always()
with:
name: link-validation-results
path: |
output/link_validation.json
output/link_validation.md
retention-days: 30
- name: Display link validation summary
if: always()
run: |
if [ -f output/link_validation.json ]; then
python3 -c "
import json
with open('output/link_validation.json') as f:
data = json.load(f)
broken = sum(1 for r in data if r.get('status') == 'broken')
ok = sum(1 for r in data if r.get('status') == 'ok')
ext = sum(1 for r in data if r.get('status') == 'external')
print('\n## Link Validation Summary')
print(f'- Total link checks: {len(data)}')
print(f'- OK: {ok}')
print(f'- Broken: {broken}')
print(f'- External: {ext}')
"
fi
check-quality:
name: Check Content Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install UV
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Create output directory
run: mkdir -p output
- name: Analyze content quality
run: |
uv run python scripts/documentation/analyze_content_quality.py \
--repo-root . \
--output output \
--format both \
--min-score 60
continue-on-error: true
- name: Upload quality results
uses: actions/upload-artifact@v4
if: always()
with:
name: quality-analysis-results
path: |
output/content_quality.json
output/content_quality.md
retention-days: 30
- name: Display quality summary
if: always()
run: |
if [ -f output/content_quality.json ]; then
python3 -c "
import json
with open('output/content_quality.json') as f:
data = json.load(f)
n = len(data)
avg = sum(q['score'] for q in data) / n if n else 0
ph = sum(q['metrics'].get('placeholder_count', 0) for q in data)
low = sum(1 for q in data if q['score'] < 60)
print('\n## Content Quality Summary')
print(f'- Files analyzed: {n}')
print(f'- Average score: {avg:.1f}/100')
print(f'- Total placeholders: {ph}')
print(f'- Files below 60: {low}')
"
fi
validate-structure:
name: Validate AGENTS.md Structure
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install UV
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Create output directory
run: mkdir -p output
- name: Validate AGENTS.md structure
run: |
uv run python scripts/documentation/validate_agents_structure.py \
--repo-root . \
--output output \
--format both
continue-on-error: true
- name: Upload structure validation results
uses: actions/upload-artifact@v4
if: always()
with:
name: agents-structure-results
path: |
output/agents_validation.json
output/agents_validation.md
retention-days: 30
- name: Display structure validation summary
if: always()
run: |
if [ -f output/agents_validation.json ]; then
python3 -c "
import json
with open('output/agents_validation.json') as f:
data = json.load(f)
total = len(data)
valid = sum(1 for a in data if a.get('valid'))
print('\n## AGENTS.md Structure Summary')
print(f'- Total files: {total}')
print(f'- Valid files: {valid}')
print(f'- Invalid files: {total - valid}')
"
fi
generate-dashboard:
name: Generate Documentation Dashboard
needs: [validate-links, check-quality, validate-structure]
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install UV
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Create output directory
run: mkdir -p output
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Consolidate results
run: |
# Move all JSON results to output directory
find artifacts -name "*.json" -exec cp {} output/ \;
find artifacts -name "*.html" -exec cp {} output/ \;
- name: Generate dashboard
run: |
uv run python scripts/documentation/generate_dashboard.py \
--repo-root . \
--output output
- name: Upload dashboard
uses: actions/upload-artifact@v4
with:
name: documentation-dashboard
path: output/documentation_dashboard.html
retention-days: 90
- name: Publish dashboard to GitHub Pages
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./output
destination_dir: documentation-quality
keep_files: false
enforce-quality-gate:
name: Enforce Quality Gates
needs: [validate-links, check-quality, validate-structure]
runs-on: ubuntu-latest
if: always() && github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install UV
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Create output directory
run: mkdir -p output
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Consolidate results
run: |
find artifacts -name "*.json" -exec cp {} output/ \;
- name: Enforce quality gates
run: |
uv run python scripts/documentation/enforce_quality_gate.py \
--repo-root . \
--output output \
--min-quality-score 70 \
--max-broken-links 10 \
--max-placeholders 100 \
--min-agents-valid-rate 80 \
--allow-warnings
- name: Comment PR with results
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
let comment = '## π Documentation Quality Check Results\n\n';
// Add summary from each validation
const files = [
'output/link_validation.json',
'output/content_quality.json',
'output/agents_validation.json'
];
for (const file of files) {
if (fs.existsSync(file)) {
const data = JSON.parse(fs.readFileSync(file, 'utf8'));
if (file.includes('link_validation')) {
const broken = Array.isArray(data) ? data.filter(r => r.status === 'broken').length : 0;
const total = Array.isArray(data) ? data.length : 0;
comment += '### π Link Validation\n';
comment += `- Link checks: ${total}\n`;
comment += `- Broken: ${broken}\n\n`;
} else if (file.includes('content_quality')) {
const arr = Array.isArray(data) ? data : [];
const n = arr.length;
const avg = n ? arr.reduce((s, q) => s + (q.score || 0), 0) / n : 0;
const ph = arr.reduce((s, q) => s + (q.metrics?.placeholder_count || 0), 0);
comment += '### π Content Quality\n';
comment += `- Average score: ${avg.toFixed(1)}/100\n`;
comment += `- Total placeholders: ${ph}\n\n`;
} else if (file.includes('agents_validation')) {
const arr = Array.isArray(data) ? data : [];
const total = arr.length;
const valid = arr.filter(a => a.valid).length;
comment += '### π€ AGENTS.md Structure\n';
comment += `- Valid files: ${valid}/${total}\n`;
comment += `- Invalid files: ${total - valid}\n\n`;
}
}
}
comment += '\n[View detailed dashboard β](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});