Skip to content

Commit ea886cc

Browse files
khwilsonkim-em
andcommitted
ci: More information for new contributors (#35109)
Currently, mathlib adds a "new-contributor" tag to PRs from folks with fewer than 5 PRs merged. However, this is more of a flag to reviewers and doesn't directly provide information to the new contributors. This PR introduces a flow where when the "new-contributor" tag is added to a PR, a comment is also added reminding the new contributor to read the Lifecycle of a PR document and notes some common pitfalls (in particular, that tag management is performed via PR comments). Co-authored-by: Kevin H Wilson <[email protected]> Co-authored-by: Kim Morrison <[email protected]>
1 parent ae6b7e9 commit ea886cc

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

.github/workflows/label_new_contributor.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Label New Contributors
22

33
# Written with ChatGPT: https://chat.openai.com/share/3777ceb1-d722-4705-bacd-ba3f04b387be
44

5-
on:
5+
on:
66
pull_request_target:
77
types:
88
- opened
@@ -50,7 +50,7 @@ jobs:
5050
totalIssuesChecked += response.data.length;
5151
5252
// Filter this page for PRs with "[Merged by Bors] -" in the title
53-
const pageMatches = response.data.filter(item =>
53+
const pageMatches = response.data.filter(item =>
5454
item.pull_request && item.title.startsWith('[Merged by Bors] -')
5555
);
5656
@@ -77,6 +77,47 @@ jobs:
7777
repo,
7878
labels: ['new-contributor']
7979
});
80+
81+
// Check if we already posted a welcome comment (idempotency)
82+
const WELCOME_MARKER = '<!-- mathlib-welcome-comment -->';
83+
let alreadyWelcomed = false;
84+
for await (const response of github.paginate.iterator(
85+
github.rest.issues.listComments,
86+
{
87+
issue_number: context.issue.number,
88+
owner,
89+
repo,
90+
per_page: 100,
91+
}
92+
)) {
93+
if (response.data.some(c => c.body.includes(WELCOME_MARKER))) {
94+
alreadyWelcomed = true;
95+
break;
96+
}
97+
}
98+
99+
if (!alreadyWelcomed) {
100+
console.log('Posting welcome comment for new contributor...');
101+
const body = [
102+
WELCOME_MARKER,
103+
'## Welcome new contributor!',
104+
'Thank you for contributing to Mathlib! If you haven\'t done so already, please review our [contribution guidelines](https://leanprover-community.github.io/contribute/index.html), as well as the [style guide](https://leanprover-community.github.io/contribute/style.html) and [naming conventions](https://leanprover-community.github.io/contribute/naming.html).',
105+
'',
106+
'We use a [review queue](https://leanprover-community.github.io/queueboard/review_dashboard.html) to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn\'t have a green checkmark), has the `awaiting-author` tag, or another reason described in the [Lifecycle of a PR](https://leanprover-community.github.io/contribute/index.html#lifecycle-of-a-pr).',
107+
'',
108+
'If you haven\'t already done so, please come to [https://leanprover.zulipchat.com/](https://leanprover.zulipchat.com/), introduce yourself, and mention your new PR.',
109+
'',
110+
'Thank you again for joining our community.',
111+
].join('\n');
112+
await github.rest.issues.createComment({
113+
issue_number: context.issue.number,
114+
owner,
115+
repo,
116+
body,
117+
});
118+
} else {
119+
console.log('Welcome comment already exists, skipping.');
120+
}
80121
}
81122
82123
console.log('Creating check run with a message about the PR count by this author...');

0 commit comments

Comments
 (0)