Quelle label_new_contributor.yml Sprache: unbekannt
|
|
Spracherkennung für: .yml vermutete Sprache: Masm {Masm[54] CS[42] Delphi[36]} [Methode: maximale Elemente, drei Dimensionen]
name: Label New Contributors
# Written with ChatGPT: https://chat.openai.com/share/3777ceb1-d722- 4705-bacd-ba3f04 b387be
on:
pull_request_target:
types:
- opened
# Limit permissions for GITHUB_TOKEN for the entire workflow
permissions:
contents: read
pull-requests: write # Only allow PR comments/labels
# All other permissions are implicitly 'none'
jobs:
label-and-report-new-contributor:
runs-on: ubuntu-latest
# Don't run on forks, where we wouldn't have permissions to add the label anyway.
if: github.repository == 'leanprover-community/mathlib4'
permissions:
checks: write
pull-requests: write
contents: read
steps:
- name: Label PR and report count
id: contributor-check
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const MIN_MERGED = 5;
const creator = context.payload.sender.login;
const { owner, repo } = context.repo;
core.setOutput('should_welcome', 'false');
console.log(`Checking closed issues for user: ${creator}`);
let mergedByBorsPRs = [];
let totalIssuesChecked = 0;
// The issues listing sometimes returns no issues for a user who has closed issues.
// A new contributor also has no closed issues, so list again before the PR gets the label.
async function* listClosedIssues() {
const MAX_ATTEMPTS = 3;
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
let found = false;
const params = { owner, repo, creator, state: 'closed', per_page: 100 };
for await (const response of github.paginate.iterator(github.rest.issues.listForRepo, params)) {
found ||= response.data.length > 0;
yield response;
}
if (found || attempt === MAX_ATTEMPTS) {
return;
}
console.log('Found no closed issues, listing them again in 5 seconds');
await new Promise(resolve => setTimeout(resolve, 5000));
}
}
// Paginate through issues, stopping when we have more than MIN_MERGED qualifying PRs
for await (const response of listClosedIssues()) {
totalIssuesChecked += response.data.length;
// Filter this page for PRs with "[Merged by Bors] -" in the title
const pageMatches = response.data.filter(item =>
item.pull_request && item.title.startsWith('[Merged by Bors] -')
);
mergedByBorsPRs.push(...pageMatches);
console.log(`Checked ${totalIssuesChecked} closed issues, found ${mergedByBorsPRs.length} PRs merged by Bors so far`);
// Stop early if we've found more than MIN_MERGED
if (mergedByBorsPRs.length > MIN_MERGED) {
console.log(`Found more than ${MIN_MERGED} PRs, stopping pagination early`);
break;
}
}
const pullRequestCount = mergedByBorsPRs.length;
console.log(`Found ${pullRequestCount} PRs merged by Bors`);
// Determine if the creator has MIN_MERGED or fewer merged pull requests
if (pullRequestCount <= MIN_MERGED) {
console.log('Adding "new-contributor" label...');
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner,
repo,
labels: ['new-contributor']
});
core.setOutput('should_welcome', 'true');
}
console.log('Creating check run with a message about the PR count by this author...');
const message = `Found ${pullRequestCount} merged PRs by ${creator}.`;
await github.rest.checks.create({
owner,
repo,
name: 'New Contributor Check',
head_sha: context.payload.pull_request.head.sha,
status: 'completed',
conclusion: 'neutral',
output: {
title: message,
summary: message,
},
});
- name: Post welcome comment for new contributor
if: steps.contributor-check.outputs.should_welcome == 'true'
uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5
with:
header: 'New Contributor Welcome'
message: |
## Welcome new contributor!
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). In particular, we kindly remind contributors that we have [guidelines](https://leanprover-community.github.io/contribute/index.html#use-of-ai) regarding the use of AI when making pull requests.
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/how-to-contribute.html#lifecycle-of-a-pr). The review dashboard has [a dedicated webpage](https://leanprover-community.github.io/queueboard/on_the_queue.html?search=${{ github.event.pull_request.number }}) which shows whether your PR is on the review queue, and (if not), why.
If you haven't already done so, please come to [Zulip](https://leanprover.zulipchat.com/) and join the Lean community.
Thank you again for joining our community.
[Dauer der Verarbeitung: 0.6 Sekunden, vorverarbeitet 2026-11-18]
|
2026-11-24
|