-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (102 loc) · 4.37 KB
/
Copy pathextension-validation.yml
File metadata and controls
126 lines (102 loc) · 4.37 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
name: Extension Validation
on:
pull_request:
paths:
- 'packages/ext-*/**'
jobs:
validate-extension:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20'
- name: Detect new/modified extensions
id: detect
run: |
# Find all modified ext-* packages
EXTENSIONS=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '^packages/ext-' | cut -d'/' -f2 | sort -u)
echo "extensions=$EXTENSIONS" >> $GITHUB_OUTPUT
- name: Validate each extension
run: |
for ext in ${{ steps.detect.outputs.extensions }}; do
echo "Validating $ext..."
# Check required files
for file in package.json manifest.json README.md LICENSE tsconfig.json; do
if [ ! -f "packages/$ext/$file" ]; then
echo "❌ Missing required file: $file"
exit 1
fi
done
# Check package.json structure
cd packages/$ext
# Check naming convention
NAME=$(node -p "require('./package.json').name")
if [[ ! "$NAME" =~ ^@framers/agentos-ext- ]]; then
echo "❌ Package name must start with @framers/agentos-ext-"
exit 1
fi
# Check license
LICENSE=$(node -p "require('./package.json').license")
if [ "$LICENSE" != "MIT" ]; then
echo "❌ License must be MIT"
exit 1
fi
# Check manifest
ID=$(node -p "require('./manifest.json').id")
if [[ ! "$ID" =~ ^com\.framers\.ext\. ]]; then
echo "❌ Extension ID must start with com.framers.ext."
exit 1
fi
# Check for secrets
if grep -r "api[_-]key\|secret\|password\|token" src/ --include="*.ts" --include="*.js" | grep -v "process.env" | grep -v "options\." | grep -v "config\."; then
echo "⚠️ Warning: Possible hardcoded secrets detected"
fi
cd ../..
echo "✅ $ext validation passed"
done
- name: Test coverage check
run: |
for ext in ${{ steps.detect.outputs.extensions }}; do
cd packages/$ext
if [ -f "package.json" ] && grep -q '"test"' package.json; then
npm ci || npm install
# Run coverage
if npm run test:coverage 2>/dev/null; then
# Check coverage threshold (80%)
if [ -f "coverage/coverage-summary.json" ]; then
COVERAGE=$(node -p "require('./coverage/coverage-summary.json').total.statements.pct")
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
echo "⚠️ Warning: Test coverage is ${COVERAGE}% (minimum 80% recommended)"
else
echo "✅ Test coverage: ${COVERAGE}%"
fi
fi
fi
fi
cd ../..
done
- name: Comment PR
uses: actions/github-script@v6
with:
script: |
const extensions = '${{ steps.detect.outputs.extensions }}'.split(' ').filter(Boolean);
if (extensions.length === 0) return;
const body = `## 🔍 Extension Validation Results
Validated extensions: ${extensions.map(e => `\`${e}\``).join(', ')}
### ✅ All validation checks passed!
Thank you for contributing to AgentOS Extensions! Your submission will be reviewed by maintainers.
### 📋 Checklist for maintainers:
- [ ] Code quality and best practices
- [ ] Security review (no hardcoded secrets)
- [ ] Test coverage >80%
- [ ] Documentation completeness
- [ ] Semantic versioning
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});