Added custom coverage script
This commit is contained in:
parent
879ddfac10
commit
f129a36099
2 changed files with 31 additions and 2 deletions
6
runtests
6
runtests
|
@ -4,8 +4,10 @@ set -e
|
||||||
|
|
||||||
export PATH=env/bin:${PATH}
|
export PATH=env/bin:${PATH}
|
||||||
|
|
||||||
coverage run --source=project --omit='*/wsgi.py,*/settings.py,*/migrations/*.py,*__init__*' manage.py test $@
|
./scripts/check-coverage.py
|
||||||
flake8 project --ignore=E128,E501,E401 --exclude="migrations,settings,*/wsgi.py"
|
|
||||||
|
flake8 project scripts --ignore=E128,E501,E401 --exclude="migrations,settings,*/wsgi.py"
|
||||||
|
|
||||||
coverage html
|
coverage html
|
||||||
coverage report
|
coverage report
|
||||||
|
|
||||||
|
|
27
scripts/check-coverage.py
Executable file
27
scripts/check-coverage.py
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import coverage
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
RED = "\033[31m"
|
||||||
|
GREEN = "\033[32m"
|
||||||
|
YELLOW = "\033[33m"
|
||||||
|
NORMAL = "\033[0m"
|
||||||
|
PERCENTAGE = 95
|
||||||
|
|
||||||
|
cov = coverage.Coverage(
|
||||||
|
source=["project"],
|
||||||
|
omit=["*/wsgi.py", "*/settings.py", "*/migrations/*.py", "*/__init__*"]
|
||||||
|
)
|
||||||
|
|
||||||
|
cov.start()
|
||||||
|
print(YELLOW + "Running Tests..." + NORMAL)
|
||||||
|
subprocess.check_output(["manage.py", "test"])
|
||||||
|
cov.stop()
|
||||||
|
|
||||||
|
print(YELLOW + "Collecting Coverage..." + NORMAL)
|
||||||
|
covered = cov.report()
|
||||||
|
if covered <= PERCENTAGE:
|
||||||
|
print(RED + "ERROR: Your coverage needs to be higher. Current coverage: {}%. Required: {}%.".format(covered, PERCENTAGE) + NORMAL)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
print(GREEN + "Coverage Complete." + NORMAL)
|
Reference in a new issue