You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by av...@apache.org on 2020/09/02 16:54:37 UTC

[hadoop-ozone] 18/33: HDDS-4140. Auto-close /pending pull requests after 21 days of inactivity (#1344)

This is an automated email from the ASF dual-hosted git repository.

avijayan pushed a commit to branch HDDS-3698-upgrade
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git

commit fe73df4378aac003faa38318b194f5ab1b36bf77
Author: Elek, Márton <el...@users.noreply.github.com>
AuthorDate: Thu Aug 27 11:02:55 2020 +0200

    HDDS-4140. Auto-close /pending pull requests after 21 days of inactivity (#1344)
---
 .github/close-pending.sh                           | 41 ++++++++++++++++++++++
 .github/closing-message.txt                        |  7 ++++
 .github/comment-commands/close.sh                  | 10 ++----
 .github/comment-commands/pending.sh                |  1 +
 .../pending.sh => workflows/close-pending.yaml}    | 38 +++++++++-----------
 5 files changed, 67 insertions(+), 30 deletions(-)

diff --git a/.github/close-pending.sh b/.github/close-pending.sh
new file mode 100755
index 0000000..ae05001
--- /dev/null
+++ b/.github/close-pending.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+# 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.
+
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
+MESSAGE=$(cat $SCRIPT_DIR/closing-message.txt)
+
+while IFS= read -r number &&
+      IFS= read -r title; do
+      echo "Closing PR ($number): $title"
+      curl -s -o /dev/null \
+        -X POST \
+        --data "$(jq --arg body "$MESSAGE" -n '{body: $body}')" \
+        --header "authorization: Bearer $GITHUB_TOKEN" \
+        --header 'content-type: application/json' \
+        "https://api.github.com/repos/apache/hadoop-ozone/issues/$number/comments"
+
+      curl -s -o /dev/null \
+        -X PATCH \
+        --data '{"state": "close"}' \
+        --header "authorization: Bearer $GITHUB_TOKEN" \
+        --header 'content-type: application/json' \
+        "https://api.github.com/repos/apache/hadoop-ozone/pulls/$number"
+done < <(curl -H "Content-Type: application/json" \
+     --header "authorization: Bearer $GITHUB_TOKEN" \
+     "https://api.github.com/search/issues?q=repo:apache/hadoop-ozone+type:pr+updated:<$(date -d "-21 days" +%Y-%m-%d)+label:pending+is:open" \
+     | jq -r '.items[] | (.number,.title)')
diff --git a/.github/closing-message.txt b/.github/closing-message.txt
new file mode 100644
index 0000000..261eac2
--- /dev/null
+++ b/.github/closing-message.txt
@@ -0,0 +1,7 @@
+Thank you very much for the patch. I am closing this PR __temporarily__ as there was no activity recently and it is waiting for response from its author.
+
+It doesn't mean that this PR is not important or ignored: feel free to reopen the PR at any time.
+
+It only means that attention of committers is not required. We prefer to keep the review queue clean. This ensures PRs in need of review are more visible, which results in faster feedback for all PRs.
+
+If you need ANY help to finish this PR, please [contact the community](https://github.com/apache/hadoop-ozone#contact) on the mailing list or the slack channel."
diff --git a/.github/comment-commands/close.sh b/.github/comment-commands/close.sh
index 4624bd8..cb57b71 100755
--- a/.github/comment-commands/close.sh
+++ b/.github/comment-commands/close.sh
@@ -16,14 +16,8 @@
 
 #doc: Close pending pull request temporary
 # shellcheck disable=SC2124
-MESSAGE="Thank you very much for the patch. I am closing this PR __temporarily__ as there was no 
-activity recently and it is waiting for response from its author.
-
-It doesn't mean that this PR is not important or ignored: feel free to reopen the PR at any time.
-
-It only means that attention of committers is not required. We prefer to keep the review queue clean. This ensures PRs in need of review are more visible, which results in faster feedback for all PRs.
-
-If you need ANY help to finish this PR, please [contact the community](https://github.com/apache/hadoop-ozone#contact) on the mailing list or the slack channel."
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
+MESSAGE=$(cat $SCRIPT_DIR/../closing-message.txt)
 
 set +x #GITHUB_TOKEN
 curl -s -o /dev/null \
diff --git a/.github/comment-commands/pending.sh b/.github/comment-commands/pending.sh
index 08947f6..840ed82 100755
--- a/.github/comment-commands/pending.sh
+++ b/.github/comment-commands/pending.sh
@@ -20,6 +20,7 @@ MESSAGE="Marking this issue as un-mergeable as requested.
 
 Please use \`/ready\` comment when it's resolved.
 
+Please note that the PR will be closed after 21 days of inactivity from now. (But can be re-opened anytime later...)
 > $@"
 
 URL="$(jq -r '.issue.pull_request.url' "$GITHUB_EVENT_PATH")/reviews"
diff --git a/.github/comment-commands/pending.sh b/.github/workflows/close-pending.yaml
old mode 100755
new mode 100644
similarity index 51%
copy from .github/comment-commands/pending.sh
copy to .github/workflows/close-pending.yaml
index 08947f6..e335701
--- a/.github/comment-commands/pending.sh
+++ b/.github/workflows/close-pending.yaml
@@ -1,4 +1,3 @@
-#!/usr/bin/env bash
 # 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.
@@ -13,26 +12,21 @@
 # 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: close-prs
 
-#doc: Add a REQUESTED_CHANGE type review to mark issue non-mergeable: `/pending <reason>`
-# shellcheck disable=SC2124
-MESSAGE="Marking this issue as un-mergeable as requested.
-
-Please use \`/ready\` comment when it's resolved.
-
-> $@"
-
-URL="$(jq -r '.issue.pull_request.url' "$GITHUB_EVENT_PATH")/reviews"
-set +x #GITHUB_TOKEN
-curl -s -o /dev/null \
-  --data "$(jq --arg body "$MESSAGE" -n '{event: "REQUEST_CHANGES", body: $body}')" \
-  --header "authorization: Bearer $GITHUB_TOKEN" \
-  --header 'content-type: application/json' \
-  "$URL"
-
-curl -s -o /dev/null \
-  -X POST \
-  --data '{"labels": [ "pending" ]}' \
-  --header "authorization: Bearer $GITHUB_TOKEN" \
-  "$(jq -r '.issue.url' "$GITHUB_EVENT_PATH")/labels"
+on:
+  schedule:
+  - cron:  '0 0 * * *'
 
+jobs:
+  close-pending:
+    name: close-pending
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@master
+      - name: Execute close-pending script
+        if: github.repository == 'apache/hadoop-ozone'
+        run: ./.github/close-pending.sh
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-commits-help@hadoop.apache.org