forked from PaddlePaddle/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_api_cn.sh
84 lines (74 loc) · 2.71 KB
/
check_api_cn.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -x
function install_paddle() {
# try to download paddle, and install
PADDLE_WHL=https://paddle-fluiddoc-ci.bj.bcebos.com/python/dist/paddlepaddle_gpu-0.0.0-cp38-cp38-linux_x86_64.whl
if [ ${BRANCH} = 'release/2.1' ] ; then
PADDLE_WHL=https://paddle-fluiddoc-ci.bj.bcebos.com/python/dist/paddlepaddle_gpu-2.1.0-cp38-cp38-linux_x86_64.whl
fi
pip install --no-cache-dir -i https://mirror.baidu.com/pypi/simple ${PADDLE_WHL}
# if failed, build paddle
if [ $? -ne 0 ];then
build_paddle
fi
}
function build_paddle() {
git clone --depth=1 https://github.com/PaddlePaddle/Paddle.git
mkdir Paddle/build
cd Paddle/build
cmake .. -DPY_VERSION=3.8 -DWITH_GPU=ON -DWITH_COVERAGE=OFF -DWITH_TESTING=OFF -DCMAKE_BUILD_TYPE=Release
make -j`nproc`
pip install -U python/dist/paddlepaddle_gpu-0.0.0-cp38-cp38-linux_x86_64.whl
cd -
}
need_check_files=""
function find_need_check_files() {
git_files=`git diff --numstat upstream/$BRANCH | awk '{print $NF}'`
for file in `echo $git_files`;do
grep "code-block" ../$file
if [ $? -eq 0 ] ;then
echo $file | grep "docs/api/paddle/.*_cn.rst"
if [ $? -eq 0 ];then
api_file=`echo $file | sed 's#docs/api/##g'`
grep -w "${api_file}" ${DIR_PATH}/api_white_list.txt
if [ $? -ne 0 ];then
need_check_files="${need_check_files} $file"
fi
fi
fi
done
}
need_check_cn_doc_files=`git diff --numstat upstream/$BRANCH | awk '{print $NF}' | grep "docs/api/paddle/.*_cn.rst" | sed 's#docs/##g'`
echo $need_check_cn_doc_files
find_need_check_files
if [ "$need_check_files" = "" -a "$need_check_cn_doc_files" = "" ]
then
echo "need check files is empty, skip chinese api check"
else
echo "need check files is not empty, begin to build and install paddle"
install_paddle
if [ $? -ne 0 ];then
echo "install paddle error"
exit 5
fi
if [ "${need_check_files}" != "" ]; then
for file in $need_check_files;do
python chinese_samplecode_processor.py ../$file
if [ $? -ne 0 ];then
echo "chinese sample code failed, the file is ${file}"
exit 5
fi
done
fi
#if [ "${need_check_cn_doc_files}" != "" ];then
# cd ../docs/paddle/api
# python gen_doc.py
# cd -
# for file in $need_check_cn_doc_files; do
# cat ../docs/api/en_cn_files_diff | awk '{print $1}' | grep ${file}
# if [ $? -eq 0 ];then
# echo "Chinese doc file exist, but the Englist doc does not exist, the Chinese file is ${file}"
# fi
# done
#fi
fi