未验证 提交 ac14d108 编写于 作者: S silingtong123 提交者: GitHub

add a CI rule: You must have Superjomn approval for change 20+ files or add...

add a CI rule:  You must have Superjomn approval for change 20+ files or add than 1000+ lines of content  (#3727)

* test=develop, add a CI rule

* test=develop, remove the debug messages
上级 9a38fa1a
#!/bin/bash
if [ -z ${BRANCH} ]; then
BRANCH="develop"
fi
LITE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../.." && pwd )"
approval_line=`curl -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/PaddlePaddle/Paddle-Lite/pulls/${GIT_PR_ID}/reviews?per_page=10000`
git_files=`git diff --numstat upstream/$BRANCH| wc -l`
git_count=`git diff --numstat upstream/$BRANCH| awk '{sum+=$1}END{print sum}'`
failed_num=0
echo_list=()
function add_failed(){
failed_num=`expr $failed_num + 1`
echo_list="${echo_list[@]}$1"
}
function check_approval(){
person_num=`echo $@|awk '{for (i=2;i<=NF;i++)print $i}'`
APPROVALS=`echo ${approval_line}|python ${LITE_ROOT}/lite/tools/check_pr_approval.py $1 $person_num`
if [[ "${APPROVALS}" == "FALSE" && "${echo_line}" != "" ]]; then
add_failed "${failed_num}. ${echo_line}"
fi
}
if [[ $git_files -gt 19 || $git_count -gt 999 ]];then
echo_line="You must have Superjomn (Yunchunwei) approval for change 20+ files or add than 1000+ lines of content.\n"
check_approval 1 328693
fi
if [ -n "${echo_list}" ];then
echo "****************"
echo -e "${echo_list[@]}"
echo "There are ${failed_num} approved errors."
echo "****************"
fi
if [ -n "${echo_list}" ]; then
exit 1
fi
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed 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.
from __future__ import print_function
import sys
import json
def check_approval(count, required_reviewers):
json_buff = ""
for line in sys.stdin:
json_buff = "".join([json_buff, line])
json_resp = json.loads(json_buff)
# print(type(json_resp))
# print(json_resp)
approves = 0
approved_user_ids = []
for review in json_resp:
if review["state"] == "APPROVED":
approves += 1
approved_user_ids.append(review["user"]["id"])
# convert to int
required_reviewers_int = set()
for rr in required_reviewers:
required_reviewers_int.add(int(rr))
if len(set(approved_user_ids) & required_reviewers_int) >= count:
print("TRUE")
else:
print("FALSE")
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1].isdigit():
check_approval(int(sys.argv[1]), sys.argv[2:])
else:
print(
"Usage: python check_pr_approval.py [count] [required reviewer id] ..."
)
......@@ -5,6 +5,7 @@ set -ex
TESTS_FILE="./lite_tests.txt"
LIBS_FILE="./lite_libs.txt"
CUDNN_ROOT="/usr/local/cudnn"
LITE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../../" && pwd )"
readonly ADB_WORK_DIR="/data/local/tmp"
readonly common_flags="-DWITH_LITE=ON -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=OFF -DWITH_PYTHON=OFF -DWITH_TESTING=ON -DLITE_WITH_ARM=OFF"
......@@ -277,11 +278,19 @@ function test_server {
done
}
function assert_api_spec_approvals() {
/bin/bash ${LITE_ROOT}/lite/tools/check_api_approvals.sh
if [ "$?" != 0 ];then
exit 1
fi
}
# Build the code and run lite server tests. This is executed in the CI system.
function build_test_server {
mkdir -p ./build
cd ./build
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/third_party/install/mklml/lib"
assert_api_spec_approvals
cmake_x86_for_CI
build
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册