From 558fca6a9bd0b8ed9aa40c605b07aa40d769250d Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Tue, 1 Dec 2026 14:30:47 +0100 Subject: [PATCH 1/7] GH-55884: [CI] Auto close untriaged PRs after 3 days --- .github/workflows/triage.yml | 119 +++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 .github/workflows/triage.yml diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml new file mode 100644 index 00000000000..a8d8fda7599 --- /dev/null +++ b/.github/workflows/triage.yml @@ -0,0 +1,119 @@ +# 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: + pull_request_target: + types: + - opened + schedule: + - cron: "15 */6 * * *" + workflow_dispatch: + +permissions: + contents: read + +jobs: + label: + name: Label First-Time PRs + if: github.event_name == 'pull_request_target' + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/github-script@v9 + with: + script: | + const TRUSTED = new Set(['OWNER', 'MEMBER', 'COLLABORATOR', 'CONTRIBUTOR']); + const EXEMPT_USERS = new Set(['dependabot[bot]', 'github-actions[bot]']); + + const pr = context.payload.pull_request; + if (TRUSTED.has(pr.author_association) || EXEMPT_USERS.has(pr.user?.login)) { + return; + } + + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + labels: ['Status: Needs triage'], + }); + + close: + name: Close Untriaged PRs + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/github-script@v9 + with: + script: | + const LABEL = 'Status: Needs triage'; + const WINDOW_MS = 3 * 24 * 60 * 60 * 1000; + const now = Date.now(); + + const items = await github.paginate(github.rest.issues.listForRepo, { + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + labels: LABEL, + per_page: 100, + }); + + for (const item of items) { + if (!item.pull_request) continue; + + const createdAt = Date.parse(item.created_at); + if (now - createdAt < WINDOW_MS) continue; + + const events = await github.paginate(github.rest.issues.listEvents, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: item.number, + per_page: 100, + }); + + let labeledAt = null; + for (const event of events) { + if (event.event === 'labeled' && event.label?.name === LABEL) { + const ts = Date.parse(event.created_at); + if (labeledAt === null || ts > labeledAt) labeledAt = ts; + } + } + + if (now - (labeledAt ?? createdAt) < WINDOW_MS) continue; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: item.number, + body: `This pull request has been automatically closed because it remained in \`${LABEL}\` for more than 3 days without being triaged by a maintainer. If you believe this was closed in error, please leave a comment so a maintainer can review and reopen it.`, + }); + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: item.number, + state: 'closed', + }); + } From f2515418c9c72938398748ac9b712bf17addfd0c Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Tue, 1 Dec 2026 14:47:59 +0100 Subject: [PATCH 2/7] Use scheduled workflow instead of pull_request_target --- .github/workflows/triage.yml | 116 +++++++++++++++++------------------ 1 file changed, 56 insertions(+), 60 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index a8d8fda7599..ec1ab1a6a55 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -18,22 +18,18 @@ name: PR Triage on: - pull_request_target: - types: - - opened schedule: - - cron: "15 */6 * * *" + - cron: "15 * * * *" workflow_dispatch: permissions: contents: read jobs: - label: - name: Label First-Time PRs - if: github.event_name == 'pull_request_target' + triage: + name: Label and Close Untriaged PRs runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 15 permissions: issues: write pull-requests: write @@ -41,40 +37,60 @@ jobs: - 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 pr = context.payload.pull_request; - if (TRUSTED.has(pr.author_association) || EXEMPT_USERS.has(pr.user?.login)) { - return; - } - - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pr.number, - labels: ['Status: Needs triage'], - }); + const lastLabeledAt = async (issue_number) => { + const events = await github.paginate(github.rest.issues.listEvents, { + ...repo, + issue_number, + per_page: 100, + }); + let ts = null; + for (const e of events) { + if (e.event === 'labeled' && e.label?.name === LABEL) { + const t = Date.parse(e.created_at); + if (ts === null || t > ts) ts = t; + } + } + return ts; + }; - close: - name: Close Untriaged PRs - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - timeout-minutes: 15 - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/github-script@v9 - with: - script: | - const LABEL = 'Status: Needs triage'; - const WINDOW_MS = 3 * 24 * 60 * 60 * 1000; - const now = Date.now(); + // 1. Label recent PRs opened by first-time contributors + 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 lastLabeledAt(pr.number)) !== null + ) { + continue; + } + await github.rest.issues.addLabels({ + ...repo, + issue_number: pr.number, + labels: [LABEL], + }); + } + if (done) break; + } + // 2. Close PRs still in 'Status: Needs triage' after 3 days const items = await github.paginate(github.rest.issues.listForRepo, { - owner: context.repo.owner, - repo: context.repo.repo, + ...repo, state: 'open', labels: LABEL, per_page: 100, @@ -82,37 +98,17 @@ jobs: for (const item of items) { if (!item.pull_request) continue; - const createdAt = Date.parse(item.created_at); - if (now - createdAt < WINDOW_MS) continue; - - const events = await github.paginate(github.rest.issues.listEvents, { - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: item.number, - per_page: 100, - }); - - let labeledAt = null; - for (const event of events) { - if (event.event === 'labeled' && event.label?.name === LABEL) { - const ts = Date.parse(event.created_at); - if (labeledAt === null || ts > labeledAt) labeledAt = ts; - } - } - - if (now - (labeledAt ?? createdAt) < WINDOW_MS) continue; + if (now - createdAt < 3 * DAY_MS) continue; + if (now - ((await lastLabeledAt(item.number)) ?? createdAt) < 3 * DAY_MS) continue; await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, + ...repo, issue_number: item.number, body: `This pull request has been automatically closed because it remained in \`${LABEL}\` for more than 3 days without being triaged by a maintainer. If you believe this was closed in error, please leave a comment so a maintainer can review and reopen it.`, }); - await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, + ...repo, pull_number: item.number, state: 'closed', }); From f841ebeff6559050fc5ebd79ecf6ab18eb89cb01 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 2 Dec 2026 11:08:41 +0100 Subject: [PATCH 3/7] Use 5-day window and remove triage label on auto-close --- .github/workflows/triage.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index ec1ab1a6a55..4d08cefd828 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -41,6 +41,7 @@ jobs: 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 CLOSE_AFTER_DAYS = 5; const now = Date.now(); const repo = context.repo; @@ -88,7 +89,7 @@ jobs: if (done) break; } - // 2. Close PRs still in 'Status: Needs triage' after 3 days + // 2. Close PRs still in 'Status: Needs triage' after CLOSE_AFTER_DAYS days const items = await github.paginate(github.rest.issues.listForRepo, { ...repo, state: 'open', @@ -99,17 +100,22 @@ jobs: for (const item of items) { if (!item.pull_request) continue; const createdAt = Date.parse(item.created_at); - if (now - createdAt < 3 * DAY_MS) continue; - if (now - ((await lastLabeledAt(item.number)) ?? createdAt) < 3 * DAY_MS) continue; + if (now - createdAt < CLOSE_AFTER_DAYS * DAY_MS) continue; + if (now - ((await lastLabeledAt(item.number)) ?? createdAt) < CLOSE_AFTER_DAYS * DAY_MS) continue; await github.rest.issues.createComment({ ...repo, issue_number: item.number, - body: `This pull request has been automatically closed because it remained in \`${LABEL}\` for more than 3 days without being triaged by a maintainer. If you believe this was closed in error, please leave a comment so a maintainer can review and reopen it.`, + body: `This pull request has been automatically closed because it remained in \`${LABEL}\` for more than ${CLOSE_AFTER_DAYS} days without being triaged by a maintainer. If you believe this was closed in error, please leave a comment so a maintainer can review and reopen it.`, }); await github.rest.pulls.update({ ...repo, pull_number: item.number, state: 'closed', }); + await github.rest.issues.removeLabel({ + ...repo, + issue_number: item.number, + name: LABEL, + }); } From a0361983e6b1aecee7af4d9cecee68499df1cbf6 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 2 Dec 2026 11:36:11 +0100 Subject: [PATCH 4/7] Improve auto-close message and suggest discussing on issue --- .github/workflows/triage.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 4d08cefd828..3b9d38d4ecf 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -106,7 +106,11 @@ jobs: await github.rest.issues.createComment({ ...repo, issue_number: item.number, - body: `This pull request has been automatically closed because it remained in \`${LABEL}\` for more than ${CLOSE_AFTER_DAYS} days without being triaged by a maintainer. If you believe this was closed in error, please leave a comment so a maintainer can review and reopen it.`, + body: [ + `Thank you for your contribution! This pull request has been automatically closed because it remained in \`${LABEL}\` for more than ${CLOSE_AFTER_DAYS} days without being picked up for review.`, + '', + 'This is due to limited maintainer triage and review capacity and is not necessarily a rejection of your change. We encourage you to discuss the motivation and approach with Arrow maintainers on the linked GitHub issue (or open a new issue if one does not exist yet). Once a maintainer picks it up, this PR can be reopened—feel free to leave a comment here if you believe it was closed in error.', + ].join('\n'), }); await github.rest.pulls.update({ ...repo, From 19ca739752d9b923571d88a10e31c8cd3a9141e1 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Wed, 2 Dec 2026 13:06:19 +0100 Subject: [PATCH 5/7] Close expired PRs before labeling and tighten auto-close message --- .github/workflows/triage.yml | 60 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 3b9d38d4ecf..feb3b554b9e 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -61,35 +61,7 @@ jobs: return ts; }; - // 1. Label recent PRs opened by first-time contributors - 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 lastLabeledAt(pr.number)) !== null - ) { - continue; - } - await github.rest.issues.addLabels({ - ...repo, - issue_number: pr.number, - labels: [LABEL], - }); - } - if (done) break; - } - - // 2. Close PRs still in 'Status: Needs triage' after CLOSE_AFTER_DAYS days + // 1. Close PRs still in 'Status: Needs triage' after CLOSE_AFTER_DAYS days const items = await github.paginate(github.rest.issues.listForRepo, { ...repo, state: 'open', @@ -109,7 +81,7 @@ jobs: body: [ `Thank you for your contribution! This pull request has been automatically closed because it remained in \`${LABEL}\` for more than ${CLOSE_AFTER_DAYS} days without being picked up for review.`, '', - 'This is due to limited maintainer triage and review capacity and is not necessarily a rejection of your change. We encourage you to discuss the motivation and approach with Arrow maintainers on the linked GitHub issue (or open a new issue if one does not exist yet). Once a maintainer picks it up, this PR can be reopened—feel free to leave a comment here if you believe it was closed in error.', + `Due to limited maintainer review capacity, first-time pull requests that are not triaged within ${CLOSE_AFTER_DAYS} 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.`, ].join('\n'), }); await github.rest.pulls.update({ @@ -123,3 +95,31 @@ jobs: name: LABEL, }); } + + // 2. Label recent PRs opened by first-time contributors + 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 lastLabeledAt(pr.number)) !== null + ) { + continue; + } + await github.rest.issues.addLabels({ + ...repo, + issue_number: pr.number, + labels: [LABEL], + }); + } + if (done) break; + } From d6a80807d10dd248dda2bab2c673a44944fa2d29 Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 3 Dec 2026 11:54:10 +0100 Subject: [PATCH 6/7] Restrict to apache/arrow, bump window to 7 days, and use actions/stale --- .github/workflows/triage.yml | 73 ++++++++++++------------------------ 1 file changed, 25 insertions(+), 48 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index feb3b554b9e..2f564b7941d 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -28,75 +28,52 @@ permissions: 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: - - uses: actions/github-script@v9 + - 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 CLOSE_AFTER_DAYS = 5; const now = Date.now(); const repo = context.repo; - const lastLabeledAt = async (issue_number) => { + const wasEverLabeled = async (issue_number) => { const events = await github.paginate(github.rest.issues.listEvents, { ...repo, issue_number, per_page: 100, }); - let ts = null; - for (const e of events) { - if (e.event === 'labeled' && e.label?.name === LABEL) { - const t = Date.parse(e.created_at); - if (ts === null || t > ts) ts = t; - } - } - return ts; + return events.some((e) => e.event === 'labeled' && e.label?.name === LABEL); }; - // 1. Close PRs still in 'Status: Needs triage' after CLOSE_AFTER_DAYS days - const items = await github.paginate(github.rest.issues.listForRepo, { - ...repo, - state: 'open', - labels: LABEL, - per_page: 100, - }); - - for (const item of items) { - if (!item.pull_request) continue; - const createdAt = Date.parse(item.created_at); - if (now - createdAt < CLOSE_AFTER_DAYS * DAY_MS) continue; - if (now - ((await lastLabeledAt(item.number)) ?? createdAt) < CLOSE_AFTER_DAYS * DAY_MS) continue; - - await github.rest.issues.createComment({ - ...repo, - issue_number: item.number, - body: [ - `Thank you for your contribution! This pull request has been automatically closed because it remained in \`${LABEL}\` for more than ${CLOSE_AFTER_DAYS} days without being picked up for review.`, - '', - `Due to limited maintainer review capacity, first-time pull requests that are not triaged within ${CLOSE_AFTER_DAYS} 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.`, - ].join('\n'), - }); - await github.rest.pulls.update({ - ...repo, - pull_number: item.number, - state: 'closed', - }); - await github.rest.issues.removeLabel({ - ...repo, - issue_number: item.number, - name: LABEL, - }); - } - - // 2. Label recent PRs opened by first-time contributors let done = false; for await (const { data: prs } of github.paginate.iterator( github.rest.pulls.list, @@ -111,7 +88,7 @@ jobs: TRUSTED.has(pr.author_association) || EXEMPT_USERS.has(pr.user?.login) || pr.labels.some((l) => l.name === LABEL) || - (await lastLabeledAt(pr.number)) !== null + (await wasEverLabeled(pr.number)) ) { continue; } From e3a29ef071aba972c516af21aae92750c40fd5dc Mon Sep 17 00:00:00 2001 From: Rok Mihevc Date: Thu, 3 Dec 2026 13:22:07 +0100 Subject: [PATCH 7/7] Use lowercase 'Status: needs triage' label to match convention --- .github/workflows/triage.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 2f564b7941d..1d6de803d05 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -38,13 +38,13 @@ jobs: - name: Close untriaged PRs uses: actions/stale@v11 with: - only-pr-labels: "Status: Needs triage" + 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. + 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" + labels-to-remove-when-stale: "Status: needs triage" days-before-pr-stale: 7 days-before-pr-close: 0 ignore-pr-updates: true @@ -58,7 +58,7 @@ jobs: uses: actions/github-script@v9 with: script: | - const LABEL = 'Status: Needs triage'; + 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;