From de2f33e4ca4c1de8b0ed0d7c5a6f90bc15bfc515 Mon Sep 17 00:00:00 2001 From: David Arthur Date: Tue, 31 Dec 2024 09:48:49 -0500 Subject: [PATCH 1/6] also remove needs-attention label --- .github/workflows/pr-reviewed.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/pr-reviewed.yml b/.github/workflows/pr-reviewed.yml index d39a7abf0a0c5..511048a7cdee2 100644 --- a/.github/workflows/pr-reviewed.yml +++ b/.github/workflows/pr-reviewed.yml @@ -57,6 +57,20 @@ jobs: issue_number: pull.number, name: "triage" }); + try { + github.rest.issues.removeLabel({ + owner: "apache", + repo: "kafka", + issue_number: pull.number, + name: "needs-attention" + }); + } catch (error) { + if (error.status === 404) { + console.log("PR did not have needs-attention label"); + } else { + console.error(error); + } + } } }); }); From f347c0b87db8d06f2c3d1121797976420d51ce71 Mon Sep 17 00:00:00 2001 From: David Arthur Date: Tue, 31 Dec 2024 09:55:35 -0500 Subject: [PATCH 2/6] add log line --- .github/workflows/pr-reviewed.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr-reviewed.yml b/.github/workflows/pr-reviewed.yml index 511048a7cdee2..05388dc3a1be8 100644 --- a/.github/workflows/pr-reviewed.yml +++ b/.github/workflows/pr-reviewed.yml @@ -64,6 +64,7 @@ jobs: issue_number: pull.number, name: "needs-attention" }); + console.log("Removing 'needs-attention' label from PR " + pull.number + " : " + pull.title); } catch (error) { if (error.status === 404) { console.log("PR did not have needs-attention label"); From 3d9bf24942bca6c4e6164b969269a67170b9f5da Mon Sep 17 00:00:00 2001 From: David Arthur Date: Tue, 31 Dec 2024 09:56:48 -0500 Subject: [PATCH 3/6] quote the label name --- .github/workflows/pr-reviewed.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-reviewed.yml b/.github/workflows/pr-reviewed.yml index 05388dc3a1be8..7863719ef4848 100644 --- a/.github/workflows/pr-reviewed.yml +++ b/.github/workflows/pr-reviewed.yml @@ -67,7 +67,7 @@ jobs: console.log("Removing 'needs-attention' label from PR " + pull.number + " : " + pull.title); } catch (error) { if (error.status === 404) { - console.log("PR did not have needs-attention label"); + console.log("PR did not have 'needs-attention' label"); } else { console.error(error); } From 6892d88140e31c80261076869016cd9ee9061e69 Mon Sep 17 00:00:00 2001 From: David Arthur Date: Thu, 2 Jan 2025 11:09:05 -0500 Subject: [PATCH 4/6] remove unnecessary logging --- .github/workflows/pr-reviewed.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pr-reviewed.yml b/.github/workflows/pr-reviewed.yml index 7863719ef4848..133d6e07b4b6d 100644 --- a/.github/workflows/pr-reviewed.yml +++ b/.github/workflows/pr-reviewed.yml @@ -66,9 +66,7 @@ jobs: }); console.log("Removing 'needs-attention' label from PR " + pull.number + " : " + pull.title); } catch (error) { - if (error.status === 404) { - console.log("PR did not have 'needs-attention' label"); - } else { + if (error.status !== 404) { console.error(error); } } From d8dffbe14cdb073e47fa5ecbec2233ed65fa2f5d Mon Sep 17 00:00:00 2001 From: David Arthur Date: Sat, 4 Jan 2025 16:23:29 -0500 Subject: [PATCH 5/6] search for needs-attention separately --- .github/workflows/pr-reviewed.yml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pr-reviewed.yml b/.github/workflows/pr-reviewed.yml index 133d6e07b4b6d..8304597ffb287 100644 --- a/.github/workflows/pr-reviewed.yml +++ b/.github/workflows/pr-reviewed.yml @@ -24,6 +24,9 @@ on: jobs: remove-triage: runs-on: ubuntu-latest + strategy: + matrix: + label: [triage, needs-attention] steps: - name: Env run: printenv @@ -35,8 +38,9 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | + console.log("Finding PRs with label '${{ matrix.label }}'"); github.paginate("GET /search/issues{?q}", { - q: "repo:apache/kafka label:triage is:pull-request" + q: "repo:apache/kafka label:${{ matrix.label }} is:pull-request" }) .then((pulls) => { pulls.forEach(pull => { @@ -50,26 +54,13 @@ jobs: }).then((resp) => { console.log("Found " + resp.data.length + " reviews for PR " + pull.number); if (resp.data.length > 0) { - console.log("Removing 'triage' label from PR " + pull.number + " : " + pull.title); + console.log("Removing '${{ matrix.label }}' label from PR " + pull.number + " : " + pull.title); github.rest.issues.removeLabel({ owner: "apache", repo: "kafka", issue_number: pull.number, - name: "triage" + name: "${{ matrix.label }}" }); - try { - github.rest.issues.removeLabel({ - owner: "apache", - repo: "kafka", - issue_number: pull.number, - name: "needs-attention" - }); - console.log("Removing 'needs-attention' label from PR " + pull.number + " : " + pull.title); - } catch (error) { - if (error.status !== 404) { - console.error(error); - } - } } }); }); From 8081077742c4d359f8d72c17442e2e0c0c263ead Mon Sep 17 00:00:00 2001 From: David Arthur Date: Wed, 8 Jan 2025 14:09:00 -0500 Subject: [PATCH 6/6] restructure workflows a bit --- .github/workflows/README.md | 11 ++++--- .../{pr-reviewed.yml => pr-labels-cron.yml} | 31 +++++++++++++++++-- .github/workflows/stale.yml | 16 ---------- 3 files changed, 35 insertions(+), 23 deletions(-) rename .github/workflows/{pr-reviewed.yml => pr-labels-cron.yml} (64%) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 29a72b188c05b..1087a3c1d6042 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -69,9 +69,11 @@ Unlike trunk, the PR builds _will_ utilize the Gradle cache. In order to get the attention of committers, we have a triage workflow for Pull Requests opened by non-committers. This workflow consists of two files: -* [pr-update.yml](pr-update.yml) When a PR is created, add the `triage` label if the PR - was opened by a non-committer. -* [pr-reviewed.yml](pr-reviewed.yml) Cron job to remove the `triage` label from PRs which have been reviewed +* [pr-update.yml](pr-update.yml) When a PR is created, add the `triage` label if + the PR was opened by a non-committer. +* [pr-labels-cron.yml](pr-labels-cron.yml) Cron job to add `needs-attention` label to community + PRs that have not been reviewed after 7 days. Also includes a cron job to + remove the `triage` and `needs-attention` labels from PRs which have been reviewed. _The pr-update.yml workflow includes pull_request_target!_ @@ -82,7 +84,8 @@ organization must be public. Here are the steps to take: * Find yourself * Change "Organization Visibility" to Public -Full documentation for this process can be found in GitHub's docs: https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-your-membership-in-organizations/publicizing-or-hiding-organization-membership +Full documentation for this process can be found in GitHub's docs: +https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-your-membership-in-organizations/publicizing-or-hiding-organization-membership If you are a committer and do not want your membership in the ASF org listed as public, you will need to remove the `triage` label manually. diff --git a/.github/workflows/pr-reviewed.yml b/.github/workflows/pr-labels-cron.yml similarity index 64% rename from .github/workflows/pr-reviewed.yml rename to .github/workflows/pr-labels-cron.yml index 8304597ffb287..5faaca72ed36b 100644 --- a/.github/workflows/pr-reviewed.yml +++ b/.github/workflows/pr-labels-cron.yml @@ -13,16 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Remove Triage Label +name: Fixup PR Labels on: workflow_dispatch: # Let us run manually schedule: - - cron: '0 3 * * *' # Run at 3:00 UTC nightly -- just before the "stale.yml" workflow + - cron: '0 3 * * *' # Run at 3:00 UTC nightly jobs: - remove-triage: + # This job removes the triage and needs-attention labels from any PRs that have been reviewed. Once reviewed, it is + # assumed that a PR does _not_ need extra attention from the committers, so these labels can be removed. + fixup-pr-labels: runs-on: ubuntu-latest strategy: matrix: @@ -65,3 +67,26 @@ jobs: }); }); }); + + # This job adds a 'needs-attention' label to any PR that has not been updated in 7 days and has been labeled with 'triage'. + # The idea here is to give committers a quick way to see which PRs have languished and need attention. + needs-attention: + runs-on: ubuntu-latest + needs: [fixup-pr-labels] + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/stale@v9 + with: + debug-only: ${{ inputs.dryRun || false }} + operations-per-run: ${{ inputs.operationsPerRun || 500 }} + days-before-stale: 7 + days-before-close: -1 + ignore-pr-updates: true + only-pr-labels: 'triage' + stale-pr-label: 'needs-attention' + stale-pr-message: | + A label of 'needs-attention' was automatically added to this PR in order to raise the + attention of the committers. Once this issue has been triaged, the `triage` label + should be removed to prevent this automation from happening again. diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 6ceb074f62c10..9382d4173e94c 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -35,22 +35,6 @@ permissions: pull-requests: write jobs: - needs-attention: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - debug-only: ${{ inputs.dryRun || false }} - operations-per-run: ${{ inputs.operationsPerRun || 500 }} - days-before-stale: 7 - days-before-close: -1 - ignore-pr-updates: true - only-pr-labels: 'triage' - stale-pr-label: 'needs-attention' - stale-pr-message: | - A label of 'needs-attention' was automatically added to this PR in order to raise the - attention of the committers. Once this issue has been triaged, the `triage` label - should be removed to prevent this automation from happening again. stale: runs-on: ubuntu-latest steps: