Skip to content

Commit 9903267

Browse files
committed
feat: Enhanced contribution system with automated validation
- Added contribution review checklist for maintainers - Created successful contributions gallery with examples - Enhanced contribute.ts with PR conflict detection - Added GitHub Action for automated PR validation - Created auto-labeling configuration for PRs - Updated CONTRIBUTING.md with links to new resources This improves the contribution workflow by: 1. Providing clear review criteria 2. Showcasing successful contributions 3. Preventing PR conflicts early 4. Automating validation checks 5. Auto-labeling PRs for better organization Based on experience processing contributions from the community.
1 parent 745cf54 commit 9903267

File tree

6 files changed

+734
-0
lines changed

6 files changed

+734
-0
lines changed

.github/labeler.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Configuration for auto-labeling PRs based on changed files
2+
3+
# Core changes
4+
core:
5+
- changed-files:
6+
- any-glob-to-any-file:
7+
- 'src/core/**/*'
8+
- 'src/interfaces/**/*'
9+
10+
# Connector changes
11+
connectors:
12+
- changed-files:
13+
- any-glob-to-any-file:
14+
- 'src/connectors/**/*'
15+
- 'src/adapters/**/*'
16+
17+
# Documentation
18+
documentation:
19+
- changed-files:
20+
- any-glob-to-any-file:
21+
- '**/*.md'
22+
- 'docs/**/*'
23+
- 'examples/**/*'
24+
25+
# Tests
26+
testing:
27+
- changed-files:
28+
- any-glob-to-any-file:
29+
- '**/__tests__/**/*'
30+
- '**/*.test.ts'
31+
- '**/*.spec.ts'
32+
- 'vitest.config.ts'
33+
34+
# CI/CD
35+
ci/cd:
36+
- changed-files:
37+
- any-glob-to-any-file:
38+
- '.github/**/*'
39+
- '.gitignore'
40+
- '.npmrc'
41+
42+
# Dependencies
43+
dependencies:
44+
- changed-files:
45+
- any-glob-to-any-file:
46+
- 'package.json'
47+
- 'package-lock.json'
48+
- 'tsconfig.json'
49+
50+
# Platform specific
51+
platform/telegram:
52+
- changed-files:
53+
- any-glob-to-any-file:
54+
- 'src/adapters/telegram/**/*'
55+
- 'src/connectors/messaging/telegram/**/*'
56+
57+
platform/discord:
58+
- changed-files:
59+
- any-glob-to-any-file:
60+
- 'src/connectors/messaging/discord/**/*'
61+
62+
platform/cloudflare:
63+
- changed-files:
64+
- any-glob-to-any-file:
65+
- 'wrangler.toml'
66+
- 'src/core/cloud/cloudflare/**/*'
67+
68+
# Contributions
69+
contribution:
70+
- changed-files:
71+
- any-glob-to-any-file:
72+
- 'contrib/**/*'
73+
- 'src/contrib/**/*'
74+
75+
# Performance
76+
performance:
77+
- changed-files:
78+
- any-glob-to-any-file:
79+
- 'src/patterns/**/*'
80+
- 'src/lib/cache/**/*'
81+
- '**/performance/**/*'
82+
83+
# Security
84+
security:
85+
- changed-files:
86+
- any-glob-to-any-file:
87+
- 'src/middleware/auth*.ts'
88+
- 'src/core/security/**/*'
89+
- '**/auth/**/*'

.github/workflows/pr-validation.yml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: PR Validation
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
validate-contribution:
9+
name: Validate Contribution
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout PR
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '22'
22+
cache: 'npm'
23+
24+
- name: Install Dependencies
25+
run: npm ci
26+
27+
- name: TypeScript Check
28+
run: npm run typecheck
29+
30+
- name: ESLint Check
31+
run: npm run lint
32+
33+
- name: Run Tests
34+
run: npm test
35+
36+
- name: Check for Conflicts
37+
run: |
38+
# Check if PR has conflicts with other open PRs
39+
gh pr list --state open --json number,files -q '.[] | select(.number != ${{ github.event.pull_request.number }})' > other_prs.json
40+
41+
# Get files changed in this PR
42+
gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path' > this_pr_files.txt
43+
44+
# Check for overlapping files
45+
node -e "
46+
const fs = require('fs');
47+
const otherPRs = JSON.parse(fs.readFileSync('other_prs.json', 'utf8') || '[]');
48+
const thisPRFiles = fs.readFileSync('this_pr_files.txt', 'utf8').split('\n').filter(Boolean);
49+
50+
const conflicts = [];
51+
for (const pr of otherPRs) {
52+
const prFiles = (pr.files || []).map(f => f.path);
53+
const overlapping = thisPRFiles.filter(f => prFiles.includes(f));
54+
if (overlapping.length > 0) {
55+
conflicts.push({ pr: pr.number, files: overlapping });
56+
}
57+
}
58+
59+
if (conflicts.length > 0) {
60+
console.log('⚠️ Potential conflicts detected:');
61+
conflicts.forEach(c => {
62+
console.log(\` PR #\${c.pr}: \${c.files.join(', ')}\`);
63+
});
64+
process.exit(1);
65+
}
66+
"
67+
env:
68+
GH_TOKEN: ${{ github.token }}
69+
continue-on-error: true
70+
71+
- name: Check Architecture Compliance
72+
run: |
73+
# Check for platform-specific imports in core modules
74+
echo "Checking for platform-specific imports..."
75+
76+
# Look for direct platform imports in src/core
77+
if grep -r "from 'grammy'" src/core/ 2>/dev/null || \
78+
grep -r "from 'discord.js'" src/core/ 2>/dev/null || \
79+
grep -r "from '@slack/'" src/core/ 2>/dev/null; then
80+
echo "❌ Found platform-specific imports in core modules!"
81+
echo "Please use connector pattern instead."
82+
exit 1
83+
fi
84+
85+
echo "✅ No platform-specific imports in core modules"
86+
87+
- name: Check for Any Types
88+
run: |
89+
# Check for 'any' types in TypeScript files
90+
echo "Checking for 'any' types..."
91+
92+
# Exclude test files and node_modules
93+
if grep -r ": any" src/ --include="*.ts" --include="*.tsx" \
94+
--exclude-dir="__tests__" --exclude-dir="node_modules" | \
95+
grep -v "eslint-disable" | \
96+
grep -v "@typescript-eslint/no-explicit-any"; then
97+
echo "❌ Found 'any' types without proper justification!"
98+
echo "Please use proper types or add eslint-disable with explanation."
99+
exit 1
100+
fi
101+
102+
echo "✅ No unjustified 'any' types found"
103+
104+
- name: Generate Contribution Report
105+
if: always()
106+
run: |
107+
echo "## 📊 Contribution Analysis" >> $GITHUB_STEP_SUMMARY
108+
echo "" >> $GITHUB_STEP_SUMMARY
109+
110+
# Count changes
111+
ADDED=$(git diff --numstat origin/main..HEAD | awk '{sum+=$1} END {print sum}')
112+
DELETED=$(git diff --numstat origin/main..HEAD | awk '{sum+=$2} END {print sum}')
113+
FILES_CHANGED=$(git diff --name-only origin/main..HEAD | wc -l)
114+
115+
echo "### Changes Summary" >> $GITHUB_STEP_SUMMARY
116+
echo "- Files changed: $FILES_CHANGED" >> $GITHUB_STEP_SUMMARY
117+
echo "- Lines added: $ADDED" >> $GITHUB_STEP_SUMMARY
118+
echo "- Lines deleted: $DELETED" >> $GITHUB_STEP_SUMMARY
119+
echo "" >> $GITHUB_STEP_SUMMARY
120+
121+
# Detect contribution type
122+
if git log --oneline origin/main..HEAD | grep -i "perf:"; then
123+
echo "🚀 **Type**: Performance Optimization" >> $GITHUB_STEP_SUMMARY
124+
elif git log --oneline origin/main..HEAD | grep -i "fix:"; then
125+
echo "🐛 **Type**: Bug Fix" >> $GITHUB_STEP_SUMMARY
126+
elif git log --oneline origin/main..HEAD | grep -i "feat:"; then
127+
echo "✨ **Type**: New Feature" >> $GITHUB_STEP_SUMMARY
128+
else
129+
echo "📝 **Type**: Other" >> $GITHUB_STEP_SUMMARY
130+
fi
131+
132+
- name: Comment on PR
133+
if: failure()
134+
uses: actions/github-script@v7
135+
with:
136+
script: |
137+
const message = `## ❌ Validation Failed
138+
139+
Please check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
140+
141+
Common issues:
142+
- TypeScript errors or warnings
143+
- ESLint violations
144+
- Failing tests
145+
- Platform-specific imports in core modules
146+
- Unjustified \`any\` types
147+
148+
Need help? Check our [Contributing Guide](https://github.com/${{ github.repository }}/blob/main/CONTRIBUTING.md).`;
149+
150+
github.rest.issues.createComment({
151+
issue_number: context.issue.number,
152+
owner: context.repo.owner,
153+
repo: context.repo.repo,
154+
body: message
155+
});
156+
157+
label-pr:
158+
name: Auto-label PR
159+
runs-on: ubuntu-latest
160+
if: success()
161+
162+
steps:
163+
- name: Label based on files
164+
uses: actions/labeler@v5
165+
with:
166+
repo-token: '${{ secrets.GITHUB_TOKEN }}'
167+
configuration-path: .github/labeler.yml
168+
169+
- name: Label based on title
170+
uses: actions/github-script@v7
171+
with:
172+
script: |
173+
const title = context.payload.pull_request.title.toLowerCase();
174+
const labels = [];
175+
176+
if (title.includes('perf:')) labels.push('performance');
177+
if (title.includes('fix:')) labels.push('bug');
178+
if (title.includes('feat:')) labels.push('enhancement');
179+
if (title.includes('docs:')) labels.push('documentation');
180+
if (title.includes('test:')) labels.push('testing');
181+
182+
if (labels.length > 0) {
183+
await github.rest.issues.addLabels({
184+
issue_number: context.issue.number,
185+
owner: context.repo.owner,
186+
repo: context.repo.repo,
187+
labels: labels
188+
});
189+
}

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,22 @@ See [Easy Contribute Guide](docs/EASY_CONTRIBUTE.md) for detailed instructions.
167167

168168
## 📚 Resources
169169

170+
### Contribution Guides
171+
172+
- [Easy Contribute Guide](docs/EASY_CONTRIBUTE.md) - Automated contribution tools
173+
- [Contribution Review Checklist](docs/CONTRIBUTION_REVIEW_CHECKLIST.md) - For maintainers
174+
- [Successful Contributions](docs/SUCCESSFUL_CONTRIBUTIONS.md) - Examples and hall of fame
170175
- [Development Workflow](docs/DEVELOPMENT_WORKFLOW.md) - Detailed development guide
176+
177+
### Technical Documentation
178+
171179
- [Cloudflare Workers Documentation](https://developers.cloudflare.com/workers/)
172180
- [grammY Documentation](https://grammy.dev/)
173181
- [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/)
174182
- [Telegram Bot API](https://core.telegram.org/bots/api)
175183

184+
## 🏆 Recent Successful Contributions
185+
186+
Check out our [Successful Contributions Gallery](docs/SUCCESSFUL_CONTRIBUTIONS.md) to see real examples of community contributions that made Wireframe better!
187+
176188
Thank you for contributing to make Wireframe the best universal AI assistant platform!

0 commit comments

Comments
 (0)