Skip to content

Commit 38d7ab7

Browse files
committed
chore: improve eligibility logging
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
1 parent ca000b7 commit 38d7ab7

4 files changed

Lines changed: 316 additions & 22 deletions

File tree

.github/scripts/lib/eligibility/has-eligibility-01-gfi.js

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
1+
/**
2+
* Determines whether a contributor is eligible to be assigned
3+
* a Good First Issue (GFI).
4+
*
5+
* ELIGIBILITY RULES:
6+
* - Repository team members (triage / write / maintain / admin)
7+
* always bypass GFI eligibility checks.
8+
* - Spam-listed contributors may have at most
9+
* `MAX_OPEN_ISSUES_SPAM_LIST` open GFI assignments.
10+
* - All other contributors may have at most
11+
* `MAX_OPEN_ISSUES_NORMAL` open GFI assignments.
12+
*
13+
* IMPORTANT:
14+
* - This helper is policy-only.
15+
* - It does NOT assign issues.
16+
* - It does NOT post comments.
17+
* - Callers must route rejections via `rejectionRouter`.
18+
*
19+
* @param {Object} params
20+
* @param {import('@actions/github').GitHub} params.github
21+
* @param {string} params.owner
22+
* @param {string} params.repo
23+
* @param {string} params.username
24+
* @returns {Promise<{
25+
* eligible: boolean,
26+
* reason?: string,
27+
* context?: Object
28+
* }>}
29+
*/
130
const { isTeam } = require('../team/has-team');
231
const { isOnSpamList } = require('../counts/is-on-spam-list');
3-
const { countOpenAssignedIssues } = require('../counts/count-opened-assigned-issues');
32+
const { countOpenAssignedIssues } =
33+
require('../counts/count-opened-assigned-issues');
434
const REJECTION_REASONS = require('./rejection-reasons');
535

6-
// Eligibility is configurable to flex with project needs
36+
// ─────────────────────────────────────────────
37+
// Policy configuration
38+
// ─────────────────────────────────────────────
739
const MAX_OPEN_ISSUES_NORMAL = 2;
840
const MAX_OPEN_ISSUES_SPAM_LIST = 1;
941

@@ -13,10 +45,26 @@ const hasGfiEligibility = async ({
1345
repo,
1446
username,
1547
}) => {
48+
console.log('[has-gfi-eligibility] Start', {
49+
owner,
50+
repo,
51+
username,
52+
});
53+
54+
// ─────────────────────────────────────────────
55+
// Team members bypass all GFI restrictions
56+
// ─────────────────────────────────────────────
1657
if (await isTeam({ github, owner, repo, username })) {
58+
console.log('[has-gfi-eligibility] Bypass: team member', {
59+
username,
60+
});
61+
1762
return { eligible: true };
1863
}
1964

65+
// ─────────────────────────────────────────────
66+
// Spam list evaluation
67+
// ─────────────────────────────────────────────
2068
const isSpamListed = await isOnSpamList({
2169
github,
2270
owner,
@@ -28,14 +76,28 @@ const hasGfiEligibility = async ({
2876
? MAX_OPEN_ISSUES_SPAM_LIST
2977
: MAX_OPEN_ISSUES_NORMAL;
3078

79+
// ─────────────────────────────────────────────
80+
// Capacity check
81+
// ─────────────────────────────────────────────
3182
const openAssignedCount = await countOpenAssignedIssues({
3283
github,
3384
owner,
3485
repo,
3586
username,
3687
});
3788

89+
console.log('[has-gfi-eligibility] Capacity evaluation', {
90+
username,
91+
isSpamListed,
92+
openAssignedCount,
93+
maxAllowed,
94+
});
95+
3896
if (openAssignedCount >= maxAllowed) {
97+
console.log('[has-gfi-eligibility] Rejected: capacity exceeded', {
98+
username,
99+
});
100+
39101
return {
40102
eligible: false,
41103
reason: REJECTION_REASONS.CAPACITY,
@@ -47,6 +109,13 @@ const hasGfiEligibility = async ({
47109
};
48110
}
49111

112+
// ─────────────────────────────────────────────
113+
// Eligible
114+
// ─────────────────────────────────────────────
115+
console.log('[has-gfi-eligibility] Eligible', {
116+
username,
117+
});
118+
50119
return { eligible: true };
51120
};
52121

.github/scripts/lib/eligibility/has-eligibility-02-beginner.js

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
1+
/**
2+
* Determines whether a contributor is eligible to be assigned
3+
* a Beginner issue.
4+
*
5+
* ELIGIBILITY RULES:
6+
* - Team members bypass all checks
7+
* - Spam-listed users are never eligible
8+
* - Max open assignments enforced
9+
* - Must have completed at least N Good First Issues
10+
*
11+
* @param {Object} params
12+
* @param {import('@actions/github').GitHub} params.github
13+
* @param {string} params.owner
14+
* @param {string} params.repo
15+
* @param {string} params.username
16+
* @returns {Promise<{
17+
* eligible: boolean,
18+
* reason?: string,
19+
* context?: Object
20+
* }>}
21+
*/
122
const { isTeam } = require('../team/has-team');
223
const { isOnSpamList } = require('../counts/is-on-spam-list');
3-
const { hasCompletedGfi } = require('../counts/has-completed-n-01-gfi');
4-
const { countOpenAssignedIssues } = require('../counts/count-opened-assigned-issues');
24+
const { hasCompletedGfi } =
25+
require('../counts/has-completed-n-01-gfi');
26+
const { countOpenAssignedIssues } =
27+
require('../counts/count-opened-assigned-issues');
528
const REJECTION_REASONS = require('./rejection-reasons');
629

7-
// Configurable
30+
// ─────────────────────────────────────────────
31+
// Policy configuration
32+
// ─────────────────────────────────────────────
833
const MAX_OPEN_ASSIGNED_ISSUES = 2;
934
const REQUIRED_GFI_COUNT = 1;
10-
// Spam users are disabled for beginner issues
1135

1236
const hasBeginnerEligibility = async ({
1337
github,
@@ -21,39 +45,73 @@ const hasBeginnerEligibility = async ({
2145
username,
2246
});
2347

48+
// ─────────────────────────────────────────────
2449
// Team members bypass everything
50+
// ─────────────────────────────────────────────
2551
if (await isTeam({ github, owner, repo, username })) {
52+
console.log('[has-beginner-eligibility] Bypass: team member', {
53+
username,
54+
});
55+
2656
return { eligible: true };
2757
}
2858

59+
// ─────────────────────────────────────────────
2960
// Spam-listed users are never eligible
30-
if (await isOnSpamList({ github, owner, repo, username })) {
61+
// ─────────────────────────────────────────────
62+
const isSpamListed = await isOnSpamList({
63+
github,
64+
owner,
65+
repo,
66+
username,
67+
});
68+
69+
if (isSpamListed) {
70+
console.log('[has-beginner-eligibility] Rejected: spam listed', {
71+
username,
72+
});
73+
3174
return {
3275
eligible: false,
3376
reason: REJECTION_REASONS.SPAM,
3477
};
3578
}
3679

80+
// ─────────────────────────────────────────────
3781
// Capacity check
82+
// ─────────────────────────────────────────────
3883
const openAssignedCount = await countOpenAssignedIssues({
3984
github,
4085
owner,
4186
repo,
4287
username,
4388
});
4489

90+
console.log('[has-beginner-eligibility] Capacity evaluation', {
91+
username,
92+
openAssignedCount,
93+
maxAllowed: MAX_OPEN_ASSIGNED_ISSUES,
94+
});
95+
4596
if (openAssignedCount >= MAX_OPEN_ASSIGNED_ISSUES) {
97+
console.log('[has-beginner-eligibility] Rejected: capacity exceeded', {
98+
username,
99+
});
100+
46101
return {
47102
eligible: false,
48103
reason: REJECTION_REASONS.CAPACITY,
49104
context: {
50105
openAssignedCount,
51106
maxAllowed: MAX_OPEN_ASSIGNED_ISSUES,
107+
isSpamListed: false,
52108
},
53109
};
54110
}
55111

112+
// ─────────────────────────────────────────────
56113
// GFI prerequisite
114+
// ─────────────────────────────────────────────
57115
const hasRequiredGfi = await hasCompletedGfi({
58116
github,
59117
owner,
@@ -62,18 +120,34 @@ const hasBeginnerEligibility = async ({
62120
requiredCount: REQUIRED_GFI_COUNT,
63121
});
64122

123+
console.log('[has-beginner-eligibility] GFI prerequisite', {
124+
username,
125+
requiredGfiCount: REQUIRED_GFI_COUNT,
126+
satisfied: hasRequiredGfi,
127+
});
128+
65129
if (!hasRequiredGfi) {
130+
console.log('[has-beginner-eligibility] Rejected: missing GFI', {
131+
username,
132+
});
133+
66134
return {
67135
eligible: false,
68136
reason: REJECTION_REASONS.MISSING_GFI,
69137
context: {
70-
completedGfiCount: 0, // safe fallback
138+
requiredGfiCount: REQUIRED_GFI_COUNT,
71139
},
72140
};
73141
}
74142

143+
// ─────────────────────────────────────────────
144+
// Eligible
145+
// ─────────────────────────────────────────────
146+
console.log('[has-beginner-eligibility] Eligible', {
147+
username,
148+
});
149+
75150
return { eligible: true };
76151
};
77152

78153
module.exports = { hasBeginnerEligibility };
79-

0 commit comments

Comments
 (0)