|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +failed_num=0 |
| 18 | +echo_list=() |
| 19 | +approval_line=`curl -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/PaddlePaddle/PaddleNLP/pulls/${PR_ID}/reviews?per_page=10000` |
| 20 | + |
| 21 | +function add_failed(){ |
| 22 | + failed_num=`expr $failed_num + 1` |
| 23 | + echo_list="${echo_list[@]}$1" |
| 24 | +} |
| 25 | + |
| 26 | +function check_approval(){ |
| 27 | + person_num=`echo $@|awk '{for (i=2;i<=NF;i++)print $i}'` |
| 28 | + echo ${person_num} |
| 29 | + APPROVALS=`echo ${approval_line}|python check_pr_approval.py $1 $person_num` |
| 30 | + echo ${APPROVALS} |
| 31 | + if [[ "${APPROVALS}" == "FALSE" && "${echo_line}" != "" ]]; then |
| 32 | + add_failed "${failed_num}. ${echo_line}" |
| 33 | + fi |
| 34 | +} |
| 35 | + |
| 36 | +echo_line="The PaddleNLP repository will be switched to the PaddleFormers repository soon, so the PR needs to be merged into PaddleFormers first and the PR link should be filled in the current PR description area. Then please contact From00 for approval." |
| 37 | +check_approval 1 From00 |
| 38 | + |
| 39 | +if [ -n "${echo_list}" ];then |
| 40 | + echo "**************************************************************" |
| 41 | + echo "Please find RD for approval." |
| 42 | + echo -e "${echo_list[@]}" |
| 43 | + echo "There are ${failed_num} approved errors." |
| 44 | + echo "**************************************************************" |
| 45 | + exit 1 |
| 46 | +else |
| 47 | + echo "**************************************************************" |
| 48 | + echo "CI APPROVAL PASSED." |
| 49 | + echo "**************************************************************" |
| 50 | + exit 0 |
| 51 | +fi |
0 commit comments