-
Notifications
You must be signed in to change notification settings - Fork 7
368 lines (306 loc) · 14.7 KB
/
analyze-contributions.yml
File metadata and controls
368 lines (306 loc) · 14.7 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
name: Analyze Shipping Potential
on:
pull_request:
paths:
- 'applications/2025/pending/*.yml'
types:
- opened
- synchronize
- reopened
workflow_run:
workflows: ["Validate Application"]
types:
- completed
jobs:
analyze:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' || github.event.workflow_run.conclusion == 'success' }}
permissions:
pull-requests: write
issues: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install PyGithub pandas pyyaml requests
- name: Extract GitHub username
id: get-username
run: |
# Find the application file from the PR
echo "Finding application files..."
# Get changed files
CHANGED_FILES=$(git diff --name-only origin/main...HEAD | grep "applications/2025/pending/.*\.yml$" || true)
if [ -z "$CHANGED_FILES" ]; then
echo "No application files found in PR"
exit 1
fi
# Get the first application file
APP_FILE=$(echo "$CHANGED_FILES" | head -n 1)
echo "Found application file: $APP_FILE"
# Extract username from filename
USERNAME=$(basename "$APP_FILE" .yml)
echo "Extracted username: $USERNAME"
echo "username=$USERNAME" >> $GITHUB_OUTPUT
echo "app_file=$APP_FILE" >> $GITHUB_OUTPUT
- name: Create analysis scripts
run: |
mkdir -p scripts
# Create analyze_github_profile.py
cat > scripts/analyze_github_profile.py << 'SCRIPT_END'
#!/usr/bin/env python3
import os
import sys
import json
from github import Github
from datetime import datetime, timedelta
from collections import defaultdict
def analyze_profile(username, token):
g = Github(token)
try:
user = g.get_user(username)
except:
print(f"Error: Could not find user {username}")
return None
analysis = {
'genai_score': 0,
'oss_score': 0,
'projects_score': 0,
'activity_score': 0,
'prod_score': 0
}
# Analyze repositories
ai_tool_count = 0
oss_projects = 0
total_stars = 0
has_ci_cd = False
has_tests = False
repos = user.get_repos()
for repo in repos[:30]: # Limit to 30 repos for API rate limits
if not repo.fork:
# Check for AI tool configs
try:
contents = repo.get_contents("")
for content in contents:
if content.name in ['.cursorrules', '.claude', '.copilot', 'cursor.json']:
ai_tool_count += 1
break
except:
pass
# Check for CI/CD
try:
repo.get_contents(".github/workflows")
has_ci_cd = True
except:
pass
# Check for tests
try:
test_dirs = ['test', 'tests', '__tests__', 'spec']
for test_dir in test_dirs:
try:
repo.get_contents(test_dir)
has_tests = True
break
except:
pass
except:
pass
# Count stars
total_stars += repo.stargazers_count
if repo.stargazers_count > 10:
oss_projects += 1
# Calculate scores
# GenAI Score (max 50)
analysis['genai_score'] = min(ai_tool_count * 10, 50)
# OSS Score (max 30)
analysis['oss_score'] = min(oss_projects * 5 + min(total_stars, 10), 30)
# Projects Score (max 10)
analysis['projects_score'] = min(user.public_repos, 10)
# Activity Score (max 5)
analysis['activity_score'] = 5 if user.public_repos > 10 else 3
# Production Score (max 5)
if has_ci_cd:
analysis['prod_score'] += 2
if has_tests:
analysis['prod_score'] += 2
analysis['prod_score'] = min(analysis['prod_score'] + 1, 5)
return analysis
if __name__ == "__main__":
username = sys.argv[1]
token = os.environ.get('GITHUB_TOKEN', '')
result = analyze_profile(username, token)
if result:
# Output results for GitHub Actions
total = sum(result.values())
print(f"::set-output name=total_score::{total}")
print(f"::set-output name=genai_score::{result['genai_score']}")
print(f"::set-output name=oss_score::{result['oss_score']}")
print(f"::set-output name=projects_score::{result['projects_score']}")
print(f"::set-output name=activity_score::{result['activity_score']}")
print(f"::set-output name=prod_score::{result['prod_score']}")
# Save results
os.makedirs('applications/2025/scorecards', exist_ok=True)
with open(f'applications/2025/scorecards/{username}-score.json', 'w') as f:
result['total_score'] = total
result['username'] = username
result['timestamp'] = datetime.now().isoformat()
json.dump({'scores': result}, f, indent=2)
SCRIPT_END
chmod +x scripts/analyze_github_profile.py
- name: Analyze GitHub Profile
id: analyze
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
run: |
echo "🔍 Analyzing GitHub profile for ${{ steps.get-username.outputs.username }}..."
python scripts/analyze_github_profile.py "${{ steps.get-username.outputs.username }}"
- name: Generate Scorecard
run: |
echo "📄 Generating detailed scorecard..."
mkdir -p applications/2025/scorecards
cat > "applications/2025/scorecards/${{ steps.get-username.outputs.username }}-scorecard.md" << EOF
# 🚀 Shipping Potential Analysis: @${{ steps.get-username.outputs.username }}
**Generated**: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
## Overall Score: ${{ steps.analyze.outputs.total_score }}/100
### 📊 Detailed Breakdown
| Category | Score | Weight |
|----------|-------|--------|
| 🤖 GenAI Tool Mastery | ${{ steps.analyze.outputs.genai_score }}/50 | 50% |
| 🌟 Open Source Contributions | ${{ steps.analyze.outputs.oss_score }}/30 | 30% |
| 🛠️ Project Quality | ${{ steps.analyze.outputs.projects_score }}/10 | 10% |
| 📈 GitHub Activity | ${{ steps.analyze.outputs.activity_score }}/5 | 5% |
| 🚢 Production Readiness | ${{ steps.analyze.outputs.prod_score }}/5 | 5% |
### 🎯 Recommendation
$(if [ ${{ steps.analyze.outputs.total_score }} -ge 80 ]; then
echo "**READY TO SHIP!** 🎉 This developer shows excellent potential for the Ship-Every-Friday squad."
elif [ ${{ steps.analyze.outputs.total_score }} -ge 60 ]; then
echo "**STRONG POTENTIAL!** This developer has good foundations and could be a great addition to the team."
else
echo "**KEEP BUILDING!** We encourage this developer to strengthen their GenAI tool usage and open source contributions."
fi)
### 💡 Next Steps
$(if [ ${{ steps.analyze.outputs.total_score }} -ge 80 ]; then
echo "- The team will review your application promptly"
echo "- Expect to hear back within 2-3 business days"
echo "- Start thinking about what you'd ship on your first Friday!"
elif [ ${{ steps.analyze.outputs.total_score }} -ge 60 ]; then
echo "- Your application will be reviewed by the team"
echo "- We may reach out for additional information"
echo "- Consider adding more GenAI tool usage to your projects"
else
echo "- Add .cursorrules or similar AI tool configs to your projects"
echo "- Contribute to more open source projects"
echo "- Build projects that demonstrate production readiness"
fi)
EOF
- name: Comment Score on PR
uses: actions/github-script@v6
with:
script: |
const score = ${{ steps.analyze.outputs.total_score || 0 }};
const emoji = score >= 80 ? '🚀' : score >= 60 ? '✈️' : '🛸';
const comment = `${emoji} **Shipping Potential Score: ${score}/100**
### 📊 Analysis Breakdown:
- 🤖 GenAI Tool Mastery: ${{ steps.analyze.outputs.genai_score || 0 }}/50
- 🌟 Open Source Contributions: ${{ steps.analyze.outputs.oss_score || 0 }}/30
- 🛠️ Project Quality: ${{ steps.analyze.outputs.projects_score || 0 }}/10
- 📈 GitHub Activity: ${{ steps.analyze.outputs.activity_score || 0 }}/5
- 🚢 Production Readiness: ${{ steps.analyze.outputs.prod_score || 0 }}/5
### 🎯 Verdict:
${score >= 80 ? "**READY TO SHIP!** 🎉 The team will be in touch ASAP!" :
score >= 60 ? "**STRONG POTENTIAL!** Looking forward to reviewing your application!" :
"**KEEP BUILDING!** Focus on GenAI tools and open source contributions!"}
---
*🤖 This analysis was performed automatically by our Ship-Squad Bot*`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})
- name: Auto-label based on score
uses: actions/github-script@v6
with:
script: |
const score = ${{ steps.analyze.outputs.total_score || 0 }};
let labels = [];
// Score-based labels
if (score >= 80) {
labels.push('ready-to-ship', 'priority-review');
} else if (score >= 60) {
labels.push('high-potential');
}
// Category-based labels
if (${{ steps.analyze.outputs.genai_score || 0 }} >= 35) {
labels.push('ai-power-user');
}
if (${{ steps.analyze.outputs.oss_score || 0 }} >= 20) {
labels.push('oss-contributor');
}
if (${{ steps.analyze.outputs.prod_score || 0 }} >= 4) {
labels.push('prod-ready');
}
// Add labels to PR
if (labels.length > 0) {
try {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
});
} catch (error) {
console.log('Some labels may not exist:', error.message);
}
}
- name: Create High Score Issue
if: ${{ steps.analyze.outputs.total_score >= 80 }}
uses: actions/github-script@v6
with:
script: |
const applicantUsername = '${{ steps.get-username.outputs.username }}';
const score = ${{ steps.analyze.outputs.total_score }};
const issueTitle = `🚀 HIGH SCORE ALERT: ${applicantUsername} scored ${score}/100!`;
const issueBody = `New ship-ready developer found!
**Applicant**: [@${applicantUsername}](https://github.com/${applicantUsername})
**Total Score**: ${score}/100
**Application PR**: #${{ github.event.pull_request.number }}
### Score Breakdown:
- 🤖 GenAI Tools: ${{ steps.analyze.outputs.genai_score }}/50
- 🌟 Open Source: ${{ steps.analyze.outputs.oss_score }}/30
- 🛠️ Projects: ${{ steps.analyze.outputs.projects_score }}/10
- 📈 Activity: ${{ steps.analyze.outputs.activity_score }}/5
- 🏭 Production Ready: ${{ steps.analyze.outputs.prod_score }}/5
### Quick Actions:
- [View Application](https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }})
- [GitHub Profile](https://github.com/${applicantUsername})
This developer is ready to ship! 🚀
cc: @alokemajumder`;
try {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: issueTitle,
body: issueBody,
labels: ['high-score', 'ready-to-ship'],
assignees: ['alokemajumder']
});
} catch (error) {
console.log('Could not assign to alokemajumder:', error.message);
// Try without assignee
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: issueTitle,
body: issueBody,
labels: ['high-score', 'ready-to-ship']
});
}