Skip to content

MNT Add GitHub Action to close PR linked to not-ready issue - #34506

Merged
lesteve merged 10 commits into
scikit-learn:mainfrom
virchan:issues/34252_autoclose_immature_prs
Aug 10, 2026
Merged

lesteve merged 10 commits into
scikit-learn:mainfrom
virchan:issues/34252_autoclose_immature_prs

Conversation

@virchan

@virchan virchan commented Jul 18, 2026

Copy link
Copy Markdown
Member

Reference Issues/PRs

Closes #34252.

What does this implement/fix? Explain your changes.

This PR adds a GitHub Actions workflow that closes pull requests opened by first-time contributors when they are linked to an issue that is not yet ready for pull requests.

I used Claude to help me develop the early drafts of this implementation. The workflow uses closingIssuesReferences from the GraphQL API to retrieve the issue linked to the pull request. I also tested it in a separate repo to confirm that it:

  • Explain why the PR is being closed.
  • Close the PR.

AI usage disclosure

I used AI assistance for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Research and understanding

Any other comments?

N/A

@AnneBeyer

Copy link
Copy Markdown
Member

Thank you for the PR @virchan!
One thought (without having looked at the code in detail yet):
We already have an action welcoming first time contributors (.github/workflows/welcome-first-time-contributor.yml). Do you think it could make sense to integrate this check into that one (to post the welcome comment or close the PR in the same action?)

@virchan virchan added the workflow Development workflow changes label Jul 18, 2026
@virchan

virchan commented Jul 19, 2026

Copy link
Copy Markdown
Member Author

We already have an action welcoming first time contributors (.github/workflows/welcome-first-time-contributor.yml). Do you think it could make sense to integrate this check into that one (to post the welcome comment or close the PR in the same action?)

This is a good idea! Let's do it!

@lesteve

lesteve commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Thanks for the PR! I agree this is one of the many small pain points we have 😉.

Without looking at the diff.

Pros:

  • I don't think it's a good use of our time to tell people manually "please don't do that". It's tiring eventually to do it repeatedly.
  • it only applies to new contributor PR IIRC and I guess they are likely the main offenders

Cons:

  • if the label is accurate it's fine to close it, but maybe we forgot to remove the "Needs triage" label and this is closed by mistake.
    • if the person comments in the PR to say "hmmm I think this is a mistake it shouldn't have been closed", chances are very high that nobody will see this. The volume of PRs is too high and the average quality too low IMO for us to actually even look 15 minutes at each PR separately.
    • if the person comments in the issue it adds more noise in the issue and we may not want this
  • when the PR is closed by mistake by a bot, it gives off bad vibes IMO. For example lately I got a stale bot comment in a perfectly fine PR without review Fix gallery binder setup scikit-image/scikit-image#8016 (comment). This feels bad. I understand the rationale (managing the high volume of issues/PRs) and sometimes I wish we had something like a stale bot in scikit-learn (but this is way too controversial I think). So as always it's complicated 😅 ...

@virchan

virchan commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

Cons:

  • if the label is accurate it's fine to close it, but maybe we forgot to remove the "Needs triage" label and this is closed by mistake.

    • if the person comments in the PR to say "hmmm I think this is a mistake it shouldn't have been closed", chances are very high that nobody will see this. The volume of PRs is too high and the average quality too low IMO for us to actually even look 15 minutes at each PR separately.
    • if the person comments in the issue it adds more noise in the issue and we may not want this
  • when the PR is closed by mistake by a bot, it gives off bad vibes IMO. For example lately I got a stale bot comment in a perfectly fine PR without review Fix gallery binder setup scikit-image/scikit-image#8016 (comment). This feels bad. I understand the rationale (managing the high volume of issues/PRs) and sometimes I wish we had something like a stale bot in scikit-learn (but this is way too controversial I think). So as always it's complicated 😅 ...

These are fair points. I'm hoping that 14bff09 addresses some of these concerns. We can also revise the bot's comment here if needed.

@virchan

virchan commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

I created the linked issue not ready label.

@lesteve lesteve left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I am fine with closing the PR directly, since this only happens for first-time-contributor and only if the PR uses fix #issueNumber.

I posted a few comments, but I am fine trying this out and adapting it as we go.

I'll wait a bit more in case an other maintainer wants to express an other opinion on the approach.

Edit: now that I have read the discussion in #34252, it seems like there is some consensus on the approach.

@lesteve lesteve added this to Labs Aug 3, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Labs Aug 3, 2026
@lesteve lesteve moved this from Todo to PR waiting for reviews in Labs Aug 3, 2026
@lesteve lesteve moved this from PR waiting for reviews to In progress in Labs Aug 4, 2026

@lesteve lesteve left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR and tackling my suggestions!

I tested it on my fork and this seems to work fine. See test PR: lesteve#47.

Since there seemed to be consensus on the approach in the linked issue, let's merge to start using this and tweak it as we go.

@lesteve lesteve changed the title MNT add GitHub Action to close PR linked to not-ready issue MNT Add GitHub Action to close PR linked to not-ready issue Aug 10, 2026
@lesteve
lesteve merged commit 5d3ef8c into scikit-learn:main Aug 10, 2026
38 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in Labs Aug 10, 2026
@virchan

virchan commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Thank you everyone for your time! 🫡

@lesteve

lesteve commented Aug 14, 2026

Copy link
Copy Markdown
Member

This seems to work fine 🎉, first "linked issue not ready" PR closed: #34743 (comment)

@virchan

virchan commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

I'd like the linting job not to run at all if we decide to close the PR. Might be a nice follow-up.

@lesteve

lesteve commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

I'd like the linting job not to run at all if we decide to close the PR

I would say YAGNI. If you are looking for CI tasks that makes our life easier, let me know! I may have some ideas for you 😉.

@virchan

virchan commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

If you are looking for CI tasks that makes our life easier, let me know! I may have some ideas for you 😉.

Sign me up please! 😄

@virchan
virchan deleted the issues/34252_autoclose_immature_prs branch August 14, 2026 23:46
@lesteve

lesteve commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

#34723 would be a good one if you feel like it.

I also have some ideas how to make the automated issue opening more useful but I need to write it up as an issue. To give you some kind of a teaser:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC Automatically close pull requests linked to issues that are not ready for contributions

3 participants