-
Notifications
You must be signed in to change notification settings - Fork 0
535 lines (445 loc) · 17.6 KB
/
Copy pathdocs.yml
File metadata and controls
535 lines (445 loc) · 17.6 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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
name: Documentation
on:
push:
branches: [ master ]
paths:
- 'src/**'
- 'README*.md'
- 'docs/**'
- '.github/workflows/docs.yml'
pull_request:
branches: [ master ]
paths:
- 'src/**'
- 'README*.md'
- 'docs/**'
workflow_dispatch:
jobs:
validate-documentation:
name: Validate Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check README files
run: |
echo "📚 Documentation Validation"
echo "=========================="
# Check README.md
if [ -f README.md ]; then
echo "✅ README.md exists"
README_LINES=$(wc -l < README.md)
echo " Lines: $README_LINES"
# Check for required sections
if grep -q "## 功能特性" README.md; then
echo " ✅ Features section found"
else
echo " ⚠️ Features section missing"
fi
if grep -q "## 安装配置" README.md; then
echo " ✅ Installation section found"
else
echo " ⚠️ Installation section missing"
fi
if grep -q "## 使用方法" README.md; then
echo " ✅ Usage section found"
else
echo " ⚠️ Usage section missing"
fi
else
echo "❌ README.md missing"
fi
# Check README-EN.md
if [ -f README-EN.md ]; then
echo "✅ README-EN.md exists"
README_EN_LINES=$(wc -l < README-EN.md)
echo " Lines: $README_EN_LINES"
else
echo "⚠️ README-EN.md missing"
fi
- name: Validate package.json documentation
run: |
echo "📦 Package.json Documentation Check"
echo "=================================="
node -e "
const pkg = require('./package.json');
console.log('Package name:', pkg.name);
console.log('Description:', pkg.description || 'MISSING');
console.log('Version:', pkg.version);
console.log('Author:', pkg.author || 'MISSING');
console.log('License:', pkg.license || 'MISSING');
console.log('Repository:', pkg.repository?.url || 'MISSING');
console.log('Homepage:', pkg.homepage || 'Not set');
console.log('Keywords:', pkg.keywords?.length || 0, 'keywords');
// Check for required fields
const required = ['name', 'version', 'description', 'author', 'license'];
const missing = required.filter(field => !pkg[field]);
if (missing.length > 0) {
console.log('❌ Missing required fields:', missing.join(', '));
process.exit(1);
} else {
console.log('✅ All required fields present');
}
"
- name: Check license file
run: |
echo "📄 License Documentation"
echo "======================"
if [ -f LICENSE ]; then
echo "✅ LICENSE file exists"
LICENSE_LINES=$(wc -l < LICENSE)
echo " Lines: $LICENSE_LINES"
# Check license content
if grep -q "MIT License" LICENSE; then
echo " ✅ MIT License detected"
elif grep -q "Apache License" LICENSE; then
echo " ✅ Apache License detected"
else
echo " ⚠️ License type unclear"
fi
else
echo "❌ LICENSE file missing"
fi
- name: Validate inline documentation
run: |
echo "💬 Inline Code Documentation"
echo "============================"
# Count TSDoc comments
TSDOC_COUNT=$(grep -r "\/\*\*" src/ --include="*.ts" | wc -l)
echo "TSDoc comments found: $TSDOC_COUNT"
# Count exported functions/classes
EXPORTS_COUNT=$(grep -r "^export " src/ --include="*.ts" | wc -l)
echo "Exported items: $EXPORTS_COUNT"
# Calculate documentation coverage (rough estimate)
if [ $EXPORTS_COUNT -gt 0 ]; then
DOC_COVERAGE=$((TSDOC_COUNT * 100 / EXPORTS_COUNT))
echo "Estimated documentation coverage: ${DOC_COVERAGE}%"
if [ $DOC_COVERAGE -lt 50 ]; then
echo "⚠️ Low documentation coverage"
else
echo "✅ Good documentation coverage"
fi
fi
generate-api-docs:
name: Generate API Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install TypeDoc
run: npm install -g typedoc
- name: Build project
run: npm run build
- name: Ensure docs directory structure
run: |
echo "📁 Ensuring docs directory structure"
echo "==================================="
# Create docs directory structure
mkdir -p docs/api docs/cli docs/workflows
- name: Generate API documentation
run: |
echo "📖 Generating API Documentation"
echo "=============================="
# Generate TypeDoc documentation
typedoc src/index.ts \
--out docs/api \
--theme default \
--name "AIFlow API Documentation" \
--readme README.md \
--exclude "**/*.test.ts" \
--exclude "**/test/**" \
--excludePrivate \
--excludeProtected \
--excludeInternal
- name: Generate CLI documentation
run: |
echo "⌨️ Generating CLI Documentation"
echo "=============================="
# Generate CLI help documentation
echo "# AIFlow CLI Documentation" > docs/cli/README.md
echo "" >> docs/cli/README.md
echo "## aiflow Command" >> docs/cli/README.md
echo "" >> docs/cli/README.md
echo "\`\`\`" >> docs/cli/README.md
timeout 30s node dist/aiflow-app.js --help >> docs/cli/README.md || echo "Help command completed"
echo "\`\`\`" >> docs/cli/README.md
echo "" >> docs/cli/README.md
echo "## aiflow-conan Command" >> docs/cli/README.md
echo "" >> docs/cli/README.md
echo "\`\`\`" >> docs/cli/README.md
timeout 30s node dist/aiflow-conan-app.js --help >> docs/cli/README.md || echo "Help command completed"
echo "\`\`\`" >> docs/cli/README.md
echo "" >> docs/cli/README.md
echo "## Configuration Help" >> docs/cli/README.md
echo "" >> docs/cli/README.md
echo "### aiflow Configuration" >> docs/cli/README.md
echo "\`\`\`" >> docs/cli/README.md
timeout 30s node dist/aiflow-app.js --config-help >> docs/cli/README.md || echo "Config help completed"
echo "\`\`\`" >> docs/cli/README.md
echo "" >> docs/cli/README.md
echo "### aiflow-conan Configuration" >> docs/cli/README.md
echo "\`\`\`" >> docs/cli/README.md
timeout 30s node dist/aiflow-conan-app.js --config-help >> docs/cli/README.md || echo "Config help completed"
echo "\`\`\`" >> docs/cli/README.md
- name: Generate workflow documentation
run: |
echo "🔄 Generating Workflow Documentation"
echo "=================================="
cat << 'EOF' > docs/workflows/README.md
# GitHub Actions Workflows
This project uses several GitHub Actions workflows for CI/CD automation:
## Available Workflows
### CI/CD Pipeline (`ci.yml`)
- **Trigger**: Push/PR to master branches
- **Purpose**: Build, test, and validate code quality
- **Jobs**:
- Lint and type checking
- Multi-platform testing (Ubuntu, Windows, macOS)
- Build and package verification
- Security audit
- Integration testing
### Release (`release.yml`)
- **Trigger**: Release published or manual dispatch
- **Purpose**: Build and publish releases to NPM
- **Jobs**:
- Version validation
- Multi-platform artifact building
- GitHub release creation
- NPM publication
- Post-release validation
### Code Quality (`quality.yml`)
- **Trigger**: Push/PR to master branches, daily schedule
- **Purpose**: Comprehensive code quality and security analysis
- **Jobs**:
- CodeQL security analysis
- Dependency vulnerability scanning
- License compliance checking
- Static code analysis
- Performance analysis
### Dependency Updates (`dependency-update.yml`)
- **Trigger**: Weekly schedule or manual dispatch
- **Purpose**: Automated dependency management
- **Jobs**:
- Security updates
- Patch/minor version updates
- Vulnerability assessment
### Performance Monitoring (`performance.yml`)
- **Trigger**: Push to master, PR, daily schedule
- **Purpose**: Monitor and track performance metrics
- **Jobs**:
- Build performance benchmarking
- CLI performance testing
- Package size analysis
- Load testing
- Performance regression detection
### Documentation (`docs.yml`)
- **Trigger**: Changes to docs or source code
- **Purpose**: Validate and generate documentation
- **Jobs**:
- Documentation validation
- API documentation generation
- CLI documentation generation
## Manual Workflow Triggers
Several workflows can be triggered manually:
1. **Release Workflow**: Create a new release
- Go to Actions → Release and Publish → Run workflow
- Specify version and prerelease flag
2. **Dependency Updates**: Update dependencies
- Go to Actions → Dependency Updates → Run workflow
- Choose update type (patch, minor, major, all)
3. **Performance Testing**: Run performance benchmarks
- Go to Actions → Performance Monitoring → Run workflow
## Workflow Status
You can monitor workflow status through:
- GitHub Actions tab
- Commit status checks
- PR status checks
- Release status
## Secrets Configuration
Required secrets for workflows:
- `NPM_TOKEN`: For NPM publishing (release workflow)
- `ACCESS_TOKEN`: Automatically provided by GitHub
## Workflow Artifacts
Workflows generate various artifacts:
- Build artifacts (dist files, packages)
- Test reports
- Performance metrics
- Security scan results
- Documentation
Artifacts are retained for 7-30 days depending on the workflow.
EOF
- name: Update documentation index
run: |
echo "📑 Updating Documentation Index"
echo "=============================="
# Get current version from package.json
VERSION=$(node -p "require('./package.json').version")
echo "Current version: $VERSION"
# Update index.html using template with dynamic version
echo "Updating docs/index.html with version $VERSION using template..."
# Use sed to replace version in template
sed "s/v{{VERSION}}/v$VERSION/g" docs/template.html > docs/index.html
cp README.md docs/
cp README-EN.md docs/
cp config.example.yaml docs/
cp LICENSE docs/
echo "✅ Generated docs/index.html from template with version $VERSION"
- name: Upload documentation artifacts
uses: actions/upload-artifact@v4
with:
name: documentation
path: docs/
retention-days: 30
validate-links:
name: Validate Documentation Links
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install markdown link checker
run: npm install -g markdown-link-check
- name: Check README links
run: |
echo "🔗 Checking Documentation Links"
echo "=============================="
# Check master README
if [ -f README.md ]; then
echo "Checking README.md links:"
markdown-link-check README.md --config .github/mlc-config.json || echo "Some links may be broken"
fi
# Check English README
if [ -f README-EN.md ]; then
echo "Checking README-EN.md links:"
markdown-link-check README-EN.md --config .github/mlc-config.json || echo "Some links may be broken"
fi
- name: Create link checker config
run: |
mkdir -p .github
cat << 'EOF' > .github/mlc-config.json
{
"ignorePatterns": [
{
"pattern": "^http://localhost"
},
{
"pattern": "^https://api.openai.com"
},
{
"pattern": "^https://.*\\.example\\.com"
}
],
"timeout": "20s",
"retryOn429": true,
"retryCount": 3,
"fallbackRetryDelay": "30s",
"aliveStatusCodes": [200, 206, 301, 302, 403, 999]
}
EOF
spell-check:
name: Spell Check Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install spell checker
run: |
sudo apt-get update
sudo apt-get install -y aspell aspell-en
- name: Check spelling in documentation
run: |
echo "📝 Spell Checking Documentation"
echo "=============================="
# Create word list for technical terms
cat << 'EOF' > .aspell.en.pws
personal_ws-1.1 en 100
AIFlow
TypeScript
JavaScript
GitHub
GitLab
Gitee
OpenAI
API
CLI
npm
Node
Conan
webhook
WeChat
WeCom
ESM
TSDoc
JSDoc
config
yaml
json
EOF
# Check README files for spelling
if [ -f README.md ]; then
echo "Spell checking README.md (English sections):"
# Extract English text and check
grep -E "^\s*#|^\s*-|^\s*\*|^[A-Za-z]" README.md | \
aspell --lang=en --personal=.aspell.en.pws list | \
sort -u | head -20 || echo "Spell check completed"
fi
if [ -f README-EN.md ]; then
echo "Spell checking README-EN.md:"
aspell --lang=en --personal=.aspell.en.pws list < README-EN.md | \
sort -u | head -20 || echo "Spell check completed"
fi
publish-docs:
name: Publish Documentation
runs-on: ubuntu-latest
needs: [validate-documentation, generate-api-docs, validate-links]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
contents: read
pages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download documentation artifacts
uses: actions/download-artifact@v4
with:
name: documentation
path: docs/
- name: Setup GitHub Pages
uses: actions/configure-pages@v4
- name: Upload to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: docs/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN}}
- name: Create deployment summary
run: |
echo "# 📚 Documentation Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Documentation has been successfully published to GitHub Pages." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**URL**: ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📋 Published Documentation" >> $GITHUB_STEP_SUMMARY
echo "- API Documentation" >> $GITHUB_STEP_SUMMARY
echo "- CLI Documentation" >> $GITHUB_STEP_SUMMARY
echo "- Workflow Documentation" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Documentation will be available at the URL above within a few minutes." >> $GITHUB_STEP_SUMMARY