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

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e5f4ae9de [Improve](CI)Check PR approve status (#20172)
5e5f4ae9de is described below

commit 5e5f4ae9defcd10b2365df9fe65039766e9c0bce
Author: Calvin Kirs <acm_mas...@163.com>
AuthorDate: Tue May 30 20:45:16 2023 +0800

    [Improve](CI)Check PR approve status (#20172)
    
    After discussion in the doris community @apache/doris-committers , we limit 
the PR to be merged only after at least two people approve it.↳
    
    We can try to run it for a while first, and if everyone gives good 
feedback, we can use this as a mandatory check.
    
    Since the merge must be approved by at least one committer, we only need to 
judge whether there are two approves, and we don't need to care about the 
identity of the approve.
    When there is a request change, if the other party is a committer, the 
committer dismiss is required when merging, which is enforced by github, so we 
don't need to care.
---
 .github/workflows/pr-approve-status.yml | 62 +++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/.github/workflows/pr-approve-status.yml 
b/.github/workflows/pr-approve-status.yml
new file mode 100644
index 0000000000..2a6a64355d
--- /dev/null
+++ b/.github/workflows/pr-approve-status.yml
@@ -0,0 +1,62 @@
+# 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: Need_2_Approval
+
+on:
+  pull_request_review:
+    types: [submitted]
+jobs:
+  Need_2_Approval:
+    runs-on: ubuntu-latest
+    timeout-minutes: 3
+    steps:
+      - uses: actions/checkout@v3
+      - run: |
+          pr_num=${{ github.event.pull_request.number }}
+          echo $pr_num
+          if [ -z "$pr_num" ]; then
+              echo "PR number is not set"
+              exit 1
+          fi
+          response=$(curl -s  -H "Authorization: token ${{ 
secrets.GITHUB_TOKEN }} "  
"https://api.github.com/repos/apache/doris/pulls/${pr_num}/reviews";)
+          # shellcheck disable=SC2207
+          reviewers=($(echo $response | jq -r '.[] | .user.login'))
+          # shellcheck disable=SC2207
+          statuses=($(echo $response | jq -r '.[] | .state'))
+          echo "${reviewers[@]}"
+          echo "${statuses[@]}"
+          approves=()
+          reviewers_unique=()
+          for ((i=${#reviewers[@]}-1;i>=0;i--)); do
+              # shellcheck disable=SC2076
+              # shellcheck disable=SC2199
+              if [[ ! "${reviewers_unique[@]}" =~ "${reviewers[$i]}" ]]; then
+                  reviewers_unique+=( "${reviewers[$i]}" )
+                  if [ "${statuses[$i]}" == "APPROVED" ]; then
+                      approves+=( "${reviewers[$i]}" )
+                  fi
+              fi
+          done
+          echo "${approves[@]}"
+          if [ ${#approves[@]} -lt 2 ]; then
+              echo "PR ${pr_num} has not been approved by at least 2 reviewers"
+              # shellcheck disable=SC2242
+              exit 1
+          fi
+          echo "Thanks for your contribution to Doris."
+          exit 0


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to