提交 12cdc905 编写于 作者: Y Yan Chunwei 提交者: GitHub

feature/add big file check (#55)

上级 065b615a
......@@ -23,3 +23,9 @@
entry: bash ./.clang_format.hook -i
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto)$
- repo: git://github.com/guykisel/pre-commit-reject-large-files
sha: da21f6dac1aa20aa53598b145c5c0013cdd40d65
hooks:
- id: reject-large-files
args: [--max-filesize=1000000]
......@@ -3,4 +3,4 @@ set -ex
export PYTHONPATH="/home/superjom/project/VisualDL/build/visualdl/logic:/home/superjom/project/VisualDL/visualdl/python"
python lib_test.py
python lib_test.py -v
#!/bin/bash
set -ex
export PYTHONPATH="$(pwd)/..:/home/superjom/project/VisualDL/build/visualdl/logic:/home/superjom/project/VisualDL/visualdl/python"
export FLASK_APP=visual_dl.py
export FLASK_DEBUG=1
python visual_dl.py --logdir ./tmp/mock --host 172.23.233.68 --port 8043
......@@ -5,6 +5,7 @@ mode=$1
readonly cur=$(pwd)
readonly core_path=$cur/build/visualdl/logic
readonly python_path=$cur/visualdl/python
readonly max_file_size=1000000 # 1MB
export PYTHONPATH="${core_path}:${python_path}"
......@@ -46,11 +47,28 @@ server_test() {
python lib_test.py
}
# check the size of files in the repo.
# reject PR that has some big data included.
bigfile_reject() {
cd $cur
# it failed to exclude .git, remove it first.
rm -rf .git
local largest_file=$(find . -path .git -prune -o -printf '%s %p\n' | sort -nr | head -n1)
local size=$(echo $largest_file | awk '{print $1}')
if [ "$size" -ge "$max_file_size" ]; then
echo $largest_file
echo "file size exceed $max_file_size"
echo "Should not add large data or binary file."
exit -1
fi
}
echo "mode" $mode
if [ $mode = "backend" ]; then
backend_test
elif [ $mode = "all" ]; then
bigfile_reject
frontend_test
backend_test
server_test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册