-
Notifications
You must be signed in to change notification settings - Fork 6
351 lines (308 loc) · 13.2 KB
/
skills-progression.yml
File metadata and controls
351 lines (308 loc) · 13.2 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
name: Skills Progression Engine
# Tracks student progress and unlocks new challenges
on:
pull_request:
types: [closed]
paths:
- 'learning-room/learning-room/**'
issues:
types: [closed]
workflow_dispatch:
inputs:
student_username:
description: 'Student GitHub username'
required: true
action:
description: 'Action (check_progress, assign_next, reset)'
required: true
default: 'check_progress'
permissions:
contents: read
issues: write
pull-requests: write
jobs:
track-completion:
name: Track Skill Completion
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Record completion
uses: actions/github-script@v7
with:
script: |
try {
const student = context.payload.pull_request.user.login;
const prNumber = context.payload.pull_request.number;
// Get linked issue
const prBody = context.payload.pull_request.body || '';
const issueMatch = prBody.match(/(?:close|closes|fix|fixes|resolve|resolves)\s+#(\d+)/i);
if (!issueMatch) {
console.log('No linked issue found in PR body');
return;
}
const issueNumber = parseInt(issueMatch[1]);
// Get issue to determine skill
const { data: issue } = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber
});
// Determine skill category from labels
const labels = issue.labels.map(l => typeof l === 'string' ? l : l.name);
let skillType = 'general';
if (labels.includes('skill: markdown')) skillType = 'markdown';
if (labels.includes('skill: accessibility')) skillType = 'accessibility';
if (labels.includes('skill: review')) skillType = 'review';
if (labels.includes('skill: collaboration')) skillType = 'collaboration';
// Award badge in comment
const badges = {
'markdown': 'Markdown Master',
'accessibility': 'Accessibility Advocate',
'review': 'Code Reviewer',
'collaboration': 'Team Player',
'general': 'Contributor'
};
const badge = badges[skillType] || badges['general'];
const skills = {
'markdown': ['- Proper Markdown syntax', '- Document structure', '- Formatting best practices'],
'accessibility': ['- Heading hierarchy', '- Descriptive link text', '- Alt text for images', '- Screen reader considerations'],
'review': ['- Constructive feedback', '- Suggesting improvements', '- Thorough examination'],
'collaboration': ['- Clear communication', '- Following conventions', '- Team coordination']
};
const skillLines = skills[skillType] || [];
const skillBody = [
'## Skill Unlocked: ' + badge,
'',
'Congratulations @' + student + '! You\'ve completed a **' + skillType + '** challenge.',
'',
'### Your Progress',
'',
'This PR demonstrated:',
...skillLines,
'',
'### What\'s Next?',
'',
'Check your profile for the next available challenge, or explore:',
'- [Learning Path Tracker](../../.github/docs/LEARNING_PATHS.md)',
'- [Available Challenges](../../learning-room/docs/CHALLENGES.md)',
'',
'Keep up the amazing work!',
'',
'---',
'*Progress tracked by Learning Room Skills Engine*'
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: skillBody
});
// Add achievement label to PR
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: ['achievement: ' + skillType]
});
} catch (labelError) {
console.log('Could not add label:', labelError.message);
}
} catch (error) {
console.error('Error tracking completion:', error);
// Don't fail workflow - just log the error
}
unlock-next-challenge:
name: Unlock Next Challenge
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Check for next challenge
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const student = context.payload.pull_request.user.login;
// Count student's merged PRs
const { data: studentPRs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
creator: student
});
const mergedCount = studentPRs.filter(pr => pr.merged_at).length;
// Load challenge progression rules
const progressionPath = '.github/data/challenge-progression.json';
let progression = {
levels: [
{
name: 'Beginner',
requiredPRs: 0,
challenges: ['fix-broken-link', 'add-keyboard-shortcut', 'complete-welcome']
},
{
name: 'Intermediate',
requiredPRs: 1,
challenges: ['fix-heading-hierarchy', 'improve-link-text', 'add-alt-text']
},
{
name: 'Advanced',
requiredPRs: 3,
challenges: ['review-accessibility', 'create-documentation', 'mentor-peer']
},
{
name: 'Expert',
requiredPRs: 5,
challenges: ['design-challenge', 'accessibility-audit', 'create-template']
}
]
};
if (fs.existsSync(progressionPath)) {
progression = JSON.parse(fs.readFileSync(progressionPath, 'utf8'));
}
// Determine current level
let currentLevel = progression.levels[0];
for (const level of progression.levels) {
if (mergedCount >= level.requiredPRs) {
currentLevel = level;
}
}
// Check if student just leveled up
const previousMergedCount = mergedCount - 1;
let previousLevel = progression.levels[0];
for (const level of progression.levels) {
if (previousMergedCount >= level.requiredPRs) {
previousLevel = level;
}
}
if (currentLevel.name !== previousLevel.name) {
// Level up!
const challengeList = currentLevel.challenges
.map(c => '- [ ] ' + c.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '))
.join('\n');
const levelUpBody = [
'## Level Up: ' + currentLevel.name + '!',
'',
'@' + student + ', you\'ve reached **' + currentLevel.name + '** level!',
'',
'**Stats:**',
'- Merged PRs: ' + mergedCount,
'- Level: ' + currentLevel.name,
'',
'**Unlocked Challenges:**',
challengeList,
'',
'Check the [Challenges Board](../../learning-room/docs/CHALLENGES.md) to get started!',
'',
'---',
'*Achievement unlocked by Skills Engine*'
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: levelUpBody
});
} else {
// Progress within level
const nextLevelIndex = progression.levels.findIndex(l => l.name === currentLevel.name) + 1;
if (nextLevelIndex < progression.levels.length) {
const nextLevel = progression.levels[nextLevelIndex];
const prsToNextLevel = nextLevel.requiredPRs - mergedCount;
const challengeList = currentLevel.challenges
.map(c => '- ' + c.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '))
.join('\n');
const progressBody = [
'## Progress Update',
'',
'Great work, @' + student + '!',
'',
'**Current Level:** ' + currentLevel.name,
'**Merged PRs:** ' + mergedCount,
'**Next Level:** ' + nextLevel.name + ' (' + prsToNextLevel + ' more merged PR' + (prsToNextLevel === 1 ? '' : 's') + ')',
'',
'**Available Challenges:**',
challengeList,
'',
'Keep going!'
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: progressBody
});
}
}
celebrate-milestone:
name: Celebrate Milestones
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Check for milestones
uses: actions/github-script@v7
with:
script: |
const student = context.payload.pull_request.user.login;
// Get all merged PRs
const { data: allPRs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed',
creator: student,
per_page: 100
});
const mergedPRs = allPRs.filter(pr => pr.merged_at);
const count = mergedPRs.length;
// Milestone numbers
const milestones = [1, 5, 10, 25, 50, 100];
if (milestones.includes(count)) {
const messages = {
1: 'Your first merged PR! This is the start of your open source journey.',
5: 'Five merged contributions! You\'re building real momentum.',
10: 'Double digits! You\'re becoming a regular contributor.',
25: 'Quarter century! Your impact is undeniable.',
50: 'Half a hundred! You\'re a pillar of this community.',
100: 'ONE HUNDRED contributions! You\'re a legend!'
};
const filesImproved = mergedPRs.reduce((sum, pr) => sum + (pr.changed_files || 0), 0);
const memberSince = new Date(mergedPRs[mergedPRs.length - 1].created_at).toLocaleDateString();
const milestoneBody = [
'## MILESTONE REACHED: ' + count + ' Merged PRs!',
'',
'@' + student + ' \u2014 ' + messages[count],
'',
'**Your Impact:**',
'- Contributions merged: ' + count,
'- Files improved: ' + filesImproved,
'- Community member since: ' + memberSince,
'',
'**Share your achievement!**',
'Add this badge to your GitHub profile:',
'',
'```markdown',
'',
'```',
'',
'---',
'*Milestone celebrated by Skills Engine*'
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: milestoneBody
});
}