davidradl commented on code in PR #26723:
URL: https://github.com/apache/flink/pull/26723#discussion_r2173928861


##########
.github/workflows/community-review.sh:
##########
@@ -0,0 +1,470 @@
+#!/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.
+################################################################################
+#
+# Community review GitHub Action - sets the community review labels on PRs to 
show case
+# community review activity. See Flip-518 for details
+set -e
+
+# =============================================================================
+# Global variables
+# =============================================================================
+REPO_OWNER=apache
+REPO_NAME=flink
+LGTM_LABEL="community-reviewed-LGTM"
+COMMUNITY_REVIEW_LABEL="community-reviewed"
+USER_CACHE_FILENAME="user_cache.txt"
+
+# =============================================================================
+# Community review script - is passed a github token that it uses for 
authentication
+# -  gets all of the open PRs from the Flink Github repo. As the API calls 
have a limit,
+# extra calls will be made to get the rest of the PR pages, and review as 
required.
+# - For each PR the reviews state and whether the reviewers is the committer 
decides whether
+# or not a label is applied to PR. The 2 labels that this script can add are:
+#    - community-reviewed-LGTM - set if there have been 2 approves by 
non-committers, no committer reviews and
+#      no changes requested
+#    - community-reviewed - set if a non-committer has reviewed the PR.
+#  Note only one of the above labels should be present on a PR.
+# =============================================================================
+main() {
+  local token="${1?missing token}"
+  local GET_PRS_TEMPLATE='{
+  "query":
+    "query {
+      repository(owner: \"{{REPO_OWNER}}\" name: \"{{REPO_NAME}}\") {
+        pullRequests(first:100, {{AFTER_CURSOR}} states: [OPEN]) {
+          edges {
+            node {
+              number
+              isDraft
+              timelineItems(first: 100, itemTypes: [PULL_REQUEST_REVIEW]) {
+                nodes {
+                  ... on PullRequestReview {
+                    author {
+                      login
+                    }
+                    state
+                    createdAt
+                 }
+                }
+                pageInfo {
+                  endCursor
+                  hasNextPage
+                }
+              }
+            }
+            cursor
+          }
+          pageInfo {
+            endCursor
+            hasNextPage
+          }
+        }
+      }
+    }"
+  }'
+  # prepare payload template
+  local payloadTemplate
+  payloadTemplate="$(echo "$GET_PRS_TEMPLATE" | tr -d '\n')"  # the query 
should be a one-liner, without newlines
+  payloadTemplate="$(replace_template_value "$payloadTemplate" "REPO_OWNER" 
"${REPO_OWNER}")"
+  payloadTemplate="$(replace_template_value "$payloadTemplate" "REPO_NAME" 
"${REPO_NAME}")"
+  local pullRequests="[]"
+  local hasNextPage=true
+  local cursor=""
+  local payload
+  
+  echo "=== Community review GitHub Action ==="
+  while [ "$hasNextPage" = "true" ]

Review Comment:
   changed as suggested



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to