mirror of
https://github.com/open-mmlab/mmocr.git
synced 2025-06-03 21:54:47 +08:00
[CI] Force py files being added/modified to meet our UT and docstr coverage requirements
This commit is contained in:
parent
b5c5ddd3e0
commit
6f3aed95a6
7
.dev_scripts/covignore.cfg
Normal file
7
.dev_scripts/covignore.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
# Each line should be the relative path to the root directory
|
||||
# of this repo. Support regular expression as well.
|
||||
# For example:
|
||||
# mmocr/models/textdet/postprocess/utils.py
|
||||
# .*/utils.py
|
||||
|
||||
.*/__init__.py
|
37
.dev_scripts/diff_coverage_test.sh
Executable file
37
.dev_scripts/diff_coverage_test.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
readarray -t IGNORED_FILES < $( dirname "$0" )/covignore.cfg
|
||||
|
||||
REPO=${1:-"origin"}
|
||||
BRANCH=${2:-"refactor_dev"}
|
||||
|
||||
git fetch $REPO $BRANCH
|
||||
|
||||
PY_FILES=""
|
||||
for FILE_NAME in $(git diff --name-only ${REPO}/${BRANCH}); do
|
||||
# Only test python files in mmocr/ existing in current branch, and not ignored in covignore.cfg
|
||||
if [ ${FILE_NAME: -3} == ".py" ] && [ ${FILE_NAME:0:6} == "mmocr/" ] && [ -f "$FILE_NAME" ]; then
|
||||
IGNORED=false
|
||||
for IGNORED_FILE_NAME in "${IGNORED_FILES[@]}"; do
|
||||
# Skip blank lines
|
||||
if [ -z "$IGNORED_FILE_NAME" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "${IGNORED_FILE_NAME::1}" != "#" ] && [[ "$FILE_NAME" =~ $IGNORED_FILE_NAME ]]; then
|
||||
echo "$IGNORED_FILE_NAME"
|
||||
IGNORED=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$IGNORED" = false ]; then
|
||||
PY_FILES="$PY_FILES $FILE_NAME"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Only test the coverage when PY_FILES are not empty, otherwise they will test the entire project
|
||||
if [ ! -z "${PY_FILES}" ]
|
||||
then
|
||||
coverage report --fail-under 80 -m $PY_FILES
|
||||
interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-magic --ignore-regex "__repr__" --fail-under 95 $PY_FILES
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user