Skip to content

Commit 85cd92e

Browse files
authored
build: remove AI from contributor pool report generator (#598)
* build: remove AI from contributor pool report generator * Fix commit message * Use GITHUB_TOKEN
1 parent 151f5e5 commit 85cd92e

File tree

3 files changed

+120
-82
lines changed

3 files changed

+120
-82
lines changed

.github/workflows/generate-contributor-pool.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ jobs:
88
generate-contributor-pool:
99

1010
permissions:
11-
models: read
1211
contents: write
1312
pull-requests: write
1413

1514
env:
1615
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
1816

1917
runs-on: ubuntu-latest
2018
steps:
@@ -33,8 +31,8 @@ jobs:
3331
- name: Create Pull Request
3432
uses: peter-evans/create-pull-request@v7
3533
with:
36-
commit-message: Add contributor pool report
37-
title: Add contributor pool report
34+
commit-message: "chore: Add contributor pool report"
35+
title: "chore: Add contributor pool report"
3836
branch: generate-contributor-pool-report
3937
branch-suffix: timestamp
4038
body: |
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Contributor Pool Report (06/01/2025 - 06/30/2025)
2+
3+
## xbinaryx (7)
4+
5+
1. [fix: skip HTML nodes in heading slugs for no-missing-link-fragments](https://github.com/eslint/markdown/pull/445) (💬 0 😐 0)
6+
Time to merge: 1 days, 2 hours
7+
8+
1. [fix: handle URL-encoded link fragments in no-missing-link-fragments rule](https://github.com/eslint/markdown/pull/437) (💬 2 😐 0)
9+
Time to merge: 3 days, 1 hours
10+
11+
1. [feat: add no-bare-urls rule](https://github.com/eslint/markdown/pull/418) (💬 2 😐 0)
12+
Time to merge: 8 days, 4 hours
13+
14+
1. [feat: add no-invalid-named-grid-areas rule](https://github.com/eslint/css/pull/169) (💬 0 😐 0)
15+
Time to merge: 17 days, 18 hours
16+
17+
1. [feat: add no-reversed-media-syntax rule](https://github.com/eslint/markdown/pull/398) (💬 1 😐 0)
18+
Time to merge: 19 days, 11 hours
19+
20+
1. [feat: add checkSiblingsOnly option to no-duplicate-headings rule](https://github.com/eslint/markdown/pull/393) (💬 1 😐 0)
21+
Time to merge: 8 days, 1 hours
22+
23+
1. [fix!: remove rollup and extraneous types](https://github.com/eslint/markdown/pull/383) (💬 11 😐 0)
24+
Time to merge: 31 days, 2 hours
25+
26+
## sethamus (4)
27+
28+
1. [feat: add `allowSeparateTypeImports` option to `no-duplicate-imports`](https://github.com/eslint/eslint/pull/19872) (💬 1 😐 0)
29+
Time to merge: 2 days, 15 hours
30+
31+
1. [feat: add auto-accessor fields support to class-methods-use-this](https://github.com/eslint/eslint/pull/19789) (💬 4 😐 0)
32+
Time to merge: 12 days, 10 hours
33+
34+
1. [feat: ignore type annotations in no-restricted-globals](https://github.com/eslint/eslint/pull/19781) (💬 1 😐 0)
35+
Time to merge: 6 days, 12 hours
36+
37+
1. [feat: add allowProperties option to no-restricted-properties](https://github.com/eslint/eslint/pull/19772) (💬 7 😐 0)
38+
Time to merge: 6 days, 2 hours
39+
40+
## TKDev7 (3)
41+
42+
1. [feat: add checkFootnoteDefinitions option to no-empty-definitions](https://github.com/eslint/markdown/pull/442) (💬 0 😐 0)
43+
Time to merge: 4 days, 1 hours
44+
45+
1. [fix: use `process.version` in `--env-info`](https://github.com/eslint/eslint/pull/19865) (💬 1 😐 0)
46+
Time to merge: 0 days, 20 hours
47+
48+
1. [feat: prune suppressions for non-existent files](https://github.com/eslint/eslint/pull/19825) (💬 2 😐 0)
49+
Time to merge: 4 days, 10 hours
50+
51+
## Pixel998 (2)
52+
53+
1. [feat: add JSON frontmatter support](https://github.com/eslint/code-explorer/pull/111) (💬 2 😐 0)
54+
Time to merge: 13 days, 21 hours
55+
56+
1. [feat: add JSON frontmatter support](https://github.com/eslint/markdown/pull/411) (💬 0 😐 0)
57+
Time to merge: 0 days, 22 hours
58+
59+
## SwetaTanwar (2)
60+
61+
1. [feat: added new rule table-column-count](https://github.com/eslint/markdown/pull/392) (💬 2 😐 1)
62+
Time to merge: 8 days, 5 hours
63+
64+
1. [feat: add no-missing-link-fragments rule](https://github.com/eslint/markdown/pull/380) (💬 6 😐 0)
65+
Time to merge: 22 days, 7 hours
66+
67+
## jgoz (1)
68+
69+
1. [feat: no-invalid-properties allowUnknownVariables option](https://github.com/eslint/css/pull/178) (💬 11 😐 0)
70+
Time to merge: 6 days, 9 hours
71+
72+
## fisker (1)
73+
74+
1. [feat: add ES2025 globals](https://github.com/eslint/eslint/pull/19835) (💬 2 😐 0)
75+
Time to merge: 0 days, 17 hours
76+
77+
## ota-meshi (1)
78+
79+
1. [feat: Add support for ES2026 `using` and `await using` declarations](https://github.com/eslint/js/pull/658) (💬 0 😐 0)
80+
Time to merge: 0 days, 14 hours
81+
82+
## remcohaszing (1)
83+
84+
1. [feat: allow global type declaration in `no-var`](https://github.com/eslint/eslint/pull/19714) (💬 6 😐 2)
85+
Time to merge: 28 days, 23 hours
86+
87+
88+
---
89+
90+
GitHub search URL: https://github.com/issues?q=org%3Aeslint%20type%3Apr%20label%3A%22contributor%20pool%22%20merged%3A2025-06-01..2025-06-30
91+
92+
Total PRs: 22
93+
94+
Date of report generation: 07/07/2025

scripts/generate-contributor-pool.js

Lines changed: 24 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,10 @@ const fs = require("fs");
1818
// Data
1919
//-----------------------------------------------------------------------------
2020

21-
const { GITHUB_TOKEN, OPENAI_API_KEY } = process.env;
21+
const { GITHUB_TOKEN } = process.env;
2222
const now = moment();
2323
const firstDayOfPreviousMonth = now.clone().subtract(1, "month").startOf("month");
2424
const lastDayOfPreviousMonth = firstDayOfPreviousMonth.clone().endOf("month");
25-
26-
const AI_URL = "https://api.openai.com/v1/chat/completions";
27-
const AI_MODEL = "gpt-4o-mini";
28-
29-
const PROMPT = `You will be given a JSON object where the keys are GitHub
30-
usernames and the values are arrays of pull request objects that were
31-
written by the user. Your task is to create a Markdown report of this
32-
activity.
33-
34-
For each user, create a heading like this:
35-
36-
<example>
37-
## GitHub username (pull request count)
38-
</example>
39-
40-
Under each heading, list each pull request in the following format:
41-
42-
<example>
43-
1. Pull request title linked to the PR URL
44-
A three-sentence summary of the pull request description ('body' field in the PR object).
45-
* **Time to merge:** X days, Y hours
46-
* **Effort Estimate:** X
47-
</example>
48-
49-
The effort estimate is the amount of effort it took for the author to complete the PR
50-
on a scale of 1 (not much work, very easy) to 5 (a lot of work). This should be
51-
based on the complexity of the changes, the amount of review comments, the overall
52-
size of the PR, the number of reactions, and the time taken to complete it.
53-
54-
The format of the JSON pull request object is as follows:
55-
56-
- user: The GitHub username of the pull request author
57-
- title: The pull request title
58-
- body: The pull request description in Markdown
59-
- html_url: The URL of the pull request
60-
- created_at: The date the pull request was created
61-
- closed_at: The date the pull request was merged
62-
- reactions: The total number of reactions on the pull request
63-
- comments: The total number of comments on the pull request
64-
65-
The title of the report should be "Contributor Pool Report for [Month] [Year]".
66-
67-
IMPORTANT: Every pull request in the JSON array must be included in the report.
68-
`;
69-
7025
const prKeys = new Set([
7126
"html_url",
7227
"title",
@@ -130,7 +85,6 @@ async function fetchGitHubSearchResults() {
13085
console.log(`Fetched ${allItems.length} PRs total\n`);
13186

13287
return allItems
133-
.filter(pr => pr.author_association !== "MEMBER")
13488
.map(pr => {
13589
const smallPr = {};
13690

@@ -149,42 +103,34 @@ async function fetchGitHubSearchResults() {
149103
}
150104

151105
/**
152-
* Fetches the AI model response based on the provided results.
153-
* @param {Object} grouped The array of PRs to be processed by the AI model.
154-
* @returns {Promise<string>} A promise that resolves to the AI-generated report.
106+
* Generates a report based on the grouped PRs.
107+
* @param {Object} grouped The grouped PRs by user.
108+
* @returns {string} The formatted report.
155109
*/
156-
async function fetchModelResponse(grouped) {
157-
158-
const response = await fetch(AI_URL, {
159-
method: "POST",
160-
headers: {
161-
"Content-Type": "application/json",
162-
Authorization: `Bearer ${OPENAI_API_KEY}`
163-
},
164-
body: JSON.stringify({
165-
model: AI_MODEL,
166-
messages: [
167-
{ role: "system", content: PROMPT },
168-
{ role: "user", content: JSON.stringify(grouped) }
169-
],
170-
temperature: 0.7
171-
})
172-
});
173-
174-
if (!response.ok) {
175-
console.log(await response.text());
176-
throw new Error(`AI model request failed with status ${response.status}`);
177-
}
110+
function generateReport(grouped) {
178111

179-
const data = await response.json();
112+
return `
113+
# Contributor Pool Report (${firstDayOfPreviousMonth.format("MM/DD/YYYY")} - ${lastDayOfPreviousMonth.format("MM/DD/YYYY")})
180114
181-
if (!data.choices || data.choices.length === 0) {
182-
throw new Error("No response from AI model");
183-
}
115+
${
116+
Object.entries(grouped).sort((a, b) => b[1].length - a[1].length).map(([user, prs]) => {
117+
118+
const prList = prs.map(pr => {
119+
const createdAt = moment(pr.created_at);
120+
const closedAt = moment(pr.closed_at);
121+
const duration = moment.duration(closedAt.diff(createdAt));
122+
const days = Math.floor(duration.asDays());
123+
const hours = duration.hours();
184124
185-
return data.choices[0].message.content;
125+
return `1. [${pr.title}](${pr.html_url}) (💬 ${pr.comments} 😐 ${pr.reactions}) \n Time to merge: ${days} days, ${hours} hours`;
126+
}).join("\n\n");
127+
128+
return `## ${user} (${prs.length})\n\n${prList}`;
129+
}).join("\n\n")
186130
}
131+
`.trimStart();
187132

133+
}
188134

189135
/**
190136
* Generates the transcript file output path.
@@ -208,7 +154,7 @@ function generateOutputPath(dateString) {
208154

209155
console.log(`Found ${results.length} contributor PRs merged.`);
210156

211-
const report = `${await fetchModelResponse(grouped)}\n\n---\n\nGitHub search URL: https://github.com/issues?q=${encodeURIComponent(query)}\n\nTotal PRs: ${results.length}\n\nDate of report generation: ${now.format("MM/DD/YYYY")}`;
157+
const report = `${generateReport(grouped)}\n\n---\n\nGitHub search URL: https://github.com/issues?q=${encodeURIComponent(query)}\n\nTotal PRs: ${results.length}\n\nDate of report generation: ${now.format("MM/DD/YYYY")}`;
212158
const dateString = now.clone().startOf("month").format("MM/DD/YYYY");
213159
const outputPath = generateOutputPath(dateString);
214160

0 commit comments

Comments
 (0)