Repository navigation
GH-55884: [CI] Auto close untriaged PRs after 7 days #55885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rok
wants to merge
7
commits into
apache:main
Choose a base branch
from
rok:reduce_agent_spam_pr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+102
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
558fca6
GH-55884: [CI] Auto close untriaged PRs after 3 days
rok f251541
Use scheduled workflow instead of pull_request_target
rok f841ebe
Use 5-day window and remove triage label on auto-close
rok a036198
Improve auto-close message and suggest discussing on issue
rok 19ca739
Close expired PRs before labeling and tighten auto-close message
rok d6a8080
Restrict to apache/arrow, bump window to 7 days, and use actions/stale
rok e3a29ef
Use lowercase 'Status: needs triage' label to match convention
rok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| name: PR Triage | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "15 * * * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| triage: | ||
| name: Label and Close Untriaged PRs | ||
| if: github.repository == 'apache/arrow' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| issues: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Close untriaged PRs | ||
| uses: actions/stale@v11 | ||
| with: | ||
| only-pr-labels: "Status: needs triage" | ||
| stale-pr-label: "Status: closed-untriaged" | ||
| stale-pr-message: |- | ||
| Thank you for your contribution! This pull request has been automatically closed because it remained in `Status: needs triage` for more than 7 days without being picked up for review. | ||
|
|
||
| Due to limited maintainer review capacity, first-time pull requests that are not triaged within 7 days are closed automatically. This is not necessarily a rejection of your change. If you would like to pursue it further, please discuss the problem and approach on the linked GitHub issue (or on the [dev@arrow.apache.org](https://lists.apache.org/list.html?dev@arrow.apache.org) mailing list for broader changes) rather than commenting here. Please do not `@`-mention individual maintainers to request a review or reopen. | ||
| labels-to-remove-when-stale: "Status: needs triage" | ||
| days-before-pr-stale: 7 | ||
| days-before-pr-close: 0 | ||
| ignore-pr-updates: true | ||
| remove-pr-stale-when-updated: false | ||
| # exclude issues | ||
| days-before-issue-stale: -1 | ||
| days-before-issue-close: -1 | ||
| operations-per-run: 100 | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Label untriaged PRs | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| script: | | ||
| const LABEL = 'Status: needs triage'; | ||
| const TRUSTED = new Set(['OWNER', 'MEMBER', 'COLLABORATOR', 'CONTRIBUTOR']); | ||
| const EXEMPT_USERS = new Set(['dependabot[bot]', 'github-actions[bot]']); | ||
| const DAY_MS = 24 * 60 * 60 * 1000; | ||
| const now = Date.now(); | ||
| const repo = context.repo; | ||
|
|
||
| const wasEverLabeled = async (issue_number) => { | ||
| const events = await github.paginate(github.rest.issues.listEvents, { | ||
| ...repo, | ||
| issue_number, | ||
| per_page: 100, | ||
| }); | ||
| return events.some((e) => e.event === 'labeled' && e.label?.name === LABEL); | ||
| }; | ||
|
|
||
| let done = false; | ||
| for await (const { data: prs } of github.paginate.iterator( | ||
| github.rest.pulls.list, | ||
| { ...repo, state: 'open', sort: 'created', direction: 'desc', per_page: 100 } | ||
| )) { | ||
| for (const pr of prs) { | ||
| if (now - Date.parse(pr.created_at) > DAY_MS) { | ||
| done = true; | ||
| break; | ||
| } | ||
| if ( | ||
| TRUSTED.has(pr.author_association) || | ||
| EXEMPT_USERS.has(pr.user?.login) || | ||
| pr.labels.some((l) => l.name === LABEL) || | ||
| (await wasEverLabeled(pr.number)) | ||
| ) { | ||
| continue; | ||
| } | ||
| await github.rest.issues.addLabels({ | ||
| ...repo, | ||
| issue_number: pr.number, | ||
| labels: [LABEL], | ||
| }); | ||
| } | ||
| if (done) break; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add
if: github.repository == 'apache/arrow’to avoid running this on fork repositories?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, good point!