未验证 提交 14e8602a 编写于 作者: H huzhiqiang 提交者: GitHub

[CI] Add approval check for CI tasks (#3842)

上级 d9c3ae01
#!/bin/bash
set -x
set +x
#####################################################################################################
# 1. global variables, you can change them according to your requirements
#####################################################################################################
......
......@@ -5,13 +5,14 @@ if [ -z ${BRANCH} ]; then
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=()
# approval list
Superjomn=328693
DannyIsFunny=45189361
function add_failed(){
failed_num=`expr $failed_num + 1`
echo_list="${echo_list[@]}$1"
......@@ -24,20 +25,96 @@ function check_approval(){
add_failed "${failed_num}. ${echo_line}"
fi
}
####################################################################################################
# Check 1: You must have Superjomn's (Yunchunwei) approval for changing
# 20+ files or adding more than 1000+ lines of content
####################################################################################################
function CheckModifiedFileNums() {
git_files=`git diff --numstat upstream/$BRANCH| wc -l`
git_count=`git diff --numstat upstream/$BRANCH| awk '{sum+=$1}END{print sum}'`
if [[ $git_files -gt 19 || $git_count -gt 999 ]];then
echo_line="You must have Superjomn's (Yunchunwei) approval for changing 20+ files or adding more than 1000+ lines of content.\n"
check_approval 1 $Superjomn
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
}
####################################################################################################
# Check 2: You must have Superjomn's (Yunchunwei) approval for increasing
# size of dynamic lib for 10+ kb
####################################################################################################
function CheckLibSizeDiff() {
# step1: record lib size of current branch
lite/tools/build_android.sh --arch=armv8 --toolchain=gcc --android_stl=c++_static --with_log=OFF
current_size=`stat -c%s build.lite.android.armv8.gcc/inference_lite_lib.android.armv8/cxx/lib/libpaddle_light_api_shared.so`
# step2: record lib size of current develop branch
git checkout develop
git clean -f . && git checkout .
git fetch upstream && git merge upstream/develop
lite/tools/build_android.sh --arch=armv8 --toolchain=gcc --android_stl=c++_static --with_log=OFF
develop_size=`stat -c%s build.lite.android.armv8.gcc/inference_lite_lib.android.armv8/cxx/lib/libpaddle_light_api_shared.so`
if [ -n "${echo_list}" ];then
# step3: if diff_size > 10485, special approval is needed
diff_size=$[$current_size - $develop_size]
if [ $diff_size -gt 10485 ]; then
echo_line="Your PR has increased basic inference lib for $diff_size Byte, exceeding maximum requirement of 10485 Byte (0.01M). You need Superjomn's (Yunchunwei) approval or you can contact DannyIsFunny(HuZhiqiang).\n"
check_approval 1 $Superjomn $DannyIsFunny
fi
if [ -n "${echo_list}" ];then
echo "****************"
echo -e "${echo_list[@]}"
echo "There are ${failed_num} approved errors."
echo "****************"
fi
fi
if [ -n "${echo_list}" ]; then
if [ -n "${echo_list}" ]; then
exit 1
fi
fi
}
####################################################################################################
# Main functions
####################################################################################################
function main {
if [ -z "$1" ]; then
# at least on argument is needed
echo "Error: at least on argument is needed!"
exit 1
fi
# Parse command line.
for i in "$@"; do
case $i in
check_modified_file_nums)
# modified files num can not exceed 20 +
CheckModifiedFileNums
exit 0
;;
check_lib_size_diff)
# size diff can not exceed 10K +
CheckLibSizeDiff
exit 0
;;
*)
# unknown option
echo "Error: unsupported input argument!"
exit 1
;;
esac
done
}
main $@
......@@ -279,7 +279,7 @@ function test_server {
}
function assert_api_spec_approvals() {
/bin/bash ${LITE_ROOT}/lite/tools/check_api_approvals.sh
/bin/bash ${LITE_ROOT}/lite/tools/check_api_approvals.sh check_modified_file_nums
if [ "$?" != 0 ];then
exit 1
fi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册