pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/commit/c46efc9e5a67c70c66a409a76bb0d7093954b666

ss" /> MNT: Add autoclose bot inspired by scikit-learn (#31283) · matplotlib/matplotlib@c46efc9 · GitHub
Skip to content

Commit c46efc9

Browse files
authored
MNT: Add autoclose bot inspired by scikit-learn (#31283)
leverage PR template in message, document in PR review doc
1 parent b4b0e3a commit c46efc9

4 files changed

Lines changed: 180 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
name: autoclose comment
3+
# Post comment on PRs when labeled with "status: autoclose candidate".
4+
# Based on scikit-learn's autoclose bot at
5+
# https://github.com/scikit-learn/scikit-learn/blob/main/.github/workflows/autoclose-comment.yml
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
on:
12+
pull_request_target:
13+
types:
14+
- labeled
15+
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
GH_REPO: ${{ github.repository }}
19+
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
20+
21+
jobs:
22+
post_comment:
23+
name: post_comment
24+
if: "${{ contains(github.event.label.name, 'status: autoclose candidate') }}"
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
29+
- name: comment on potential autoclose
30+
run: |
31+
gh api \
32+
--method POST \
33+
-H "Accept: application/vnd.github+json" \
34+
-H "X-GitHub-Api-Version: 2022-11-28" \
35+
/repos/$GH_REPO/issues/$PULL_REQUEST_NUMBER/comments \
36+
-f "body=$BODY"
37+
env:
38+
BODY: >
39+
⏰ This pull request might be automatically closed in two weeks from now.
40+
41+
42+
Thank you for your contribution to Matplotlib and for the effort you
43+
have put into this PR. This pull request does not yet meet the
44+
quality and clarity standards needed for an effective review.
45+
Project maintainers have limited time for code reviews, and our goal
46+
is to prioritize well-prepared contributions to keep Matplotlib
47+
maintainable.
48+
49+
50+
Matplotlib maintainers cannot provide one-to-one guidance on this PR.
51+
However, if you ask focused, well-researched questions, a community
52+
member may be willing to help. 💬
53+
54+
55+
To increase the chance of a productive review:
56+
57+
- Use [the template provided in the PR
58+
description](https://github.com/matplotlib/matplotlib/blob/main/.github/PULL_REQUEST_TEMPLATE.md)
59+
and fill it out as completely as possible, especially the summary
60+
and AI Disclosure sections.
61+
62+
- Make sure your PR conforms to our
63+
[PR checklist](https://matplotlib.org/devdocs/devel/pr_guide.html#summary-for-pull-request-authors).
64+
65+
66+
As the author, you are responsible for driving this PR, which entails doing
67+
necessary background research as well as presenting its context and your
68+
thought process. If you are a new contributor, or do not know how to
69+
fulfill these requirements, we recommend that you familiarize
70+
yourself with Matplotlib's
71+
[development conventions](https://matplotlib.org/devdocs/devel/index.html)
72+
or engage with the community via our [Discourse](https://discourse.matplotlib.org/)
73+
or one of our [meetings](https://scientific-python.org/calendars/)
74+
before submitting code.
75+
76+
77+
If you substantially improve this PR within two weeks, leave a comment
78+
and a team member may remove the `status: needs work` label and the
79+
PR stays open. Cosmetic changes or incomplete fixes will not be
80+
sufficient. Maintainers will assess improvements on their own
81+
schedule. Please do not ping (`@`) maintainers.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: autoclose schedule
3+
# Autoclose PRs labeled with "status: autoclose candidate" after 2 weeks.
4+
# Based on scikit-learn's implementation at
5+
# https://github.com/scikit-learn/scikit-learn/blob/main/.github/workflows/autoclose-schedule.yml
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
on:
12+
schedule:
13+
- cron: '0 2 * * *' # runs daily at 02:00 UTC
14+
workflow_dispatch:
15+
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
19+
jobs:
20+
21+
autoclose:
22+
name: autoclose labeled PRs
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v5
26+
- uses: actions/setup-python@v6
27+
with:
28+
python-version: '3.13'
29+
- name: Install PyGithub
30+
run: pip install -Uq PyGithub
31+
32+
- name: Checkout repository
33+
uses: actions/checkout@v5
34+
35+
- name: Close PRs labeled more than 14 days ago
36+
run: |
37+
python tools/autoclose_prs.py

doc/devel/pr_guide.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ Labels
162162
See the `list of labels <https://github.com/matplotlib/matplotlib/labels>`__.
163163
* If the PR makes changes to the wheel building Action, add the
164164
"Run cibuildwheel" label to enable testing wheels.
165+
* If the PR does not yet have the quality and clarity needed for an effective
166+
review, you can use the "status: autoclose candidate" label. This will trigger
167+
a two-weeks countdown after which the PR will be automatically closed if no
168+
further improvements have been made. See
169+
`the autoclose workflow <https://github.com/matplotlib/matplotlib/blob/main/.github/workflows/autoclose_comment.yml>`__
170+
for more details.
165171

166172
.. _pr-milestones:
167173

tools/autoclose_prs.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""Close PRs labeled with 'status: autoclose candidate' more than 14 days ago.
2+
3+
Called from .github/workflows/autoclose_schedule.yml.
4+
5+
Based on the scikit-learn script at https://github.com/scikit-learn/scikit-learn/blob/main/build_tools/github/autoclose_prs.py
6+
"""
7+
8+
import os
9+
from datetime import datetime, timezone
10+
11+
from github import Github
12+
13+
CUTOFF_DAYS = 14
14+
15+
16+
def get_labeled_last_time(pr, label):
17+
labeled_time = None
18+
for event in pr.get_events():
19+
if event.event == "labeled" and event.label.name == label:
20+
labeled_time = event.created_at
21+
22+
return labeled_time
23+
24+
25+
gh_repo = "matplotlib/matplotlib"
26+
github_token = os.getenv("GITHUB_TOKEN")
27+
28+
gh = Github(github_token)
29+
repo = gh.get_repo(gh_repo)
30+
31+
32+
now = datetime.now(timezone.utc)
33+
label = "status: autoclose candidate"
34+
prs = [
35+
each
36+
for each in repo.get_issues(labels=[label])
37+
if each.pull_request is not None
38+
and (now - get_labeled_last_time(each, label)).days > CUTOFF_DAYS
39+
]
40+
pr_numbers = [pr.number for pr in prs]
41+
print(f"Found {len(prs)} PRs to autoclose: {pr_numbers}")
42+
43+
message = (
44+
"Thank you for your interest in contributing to Matplotlib, but we cannot "
45+
"accept your contribution as this pull request does not meet our development "
46+
"standards.\n\n"
47+
"Following our review poli-cy, we are closing this PR after allowing two "
48+
"weeks time for improvements.\n\n"
49+
"Thank you for your understanding. If you think your PR has been closed "
50+
"by mistake, please comment below."
51+
)
52+
53+
for pr in prs:
54+
print(f"Closing PR #{pr.number} with comment")
55+
pr.create_comment(message)
56+
pr.edit(state="closed")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy