1
Fork 0

Added custom coverage script

This commit is contained in:
Jake Howard 2016-01-09 22:56:48 +00:00
parent 879ddfac10
commit f129a36099
2 changed files with 31 additions and 2 deletions

View file

@ -4,8 +4,10 @@ set -e
export PATH=env/bin:${PATH}
coverage run --source=project --omit='*/wsgi.py,*/settings.py,*/migrations/*.py,*__init__*' manage.py test $@
flake8 project --ignore=E128,E501,E401 --exclude="migrations,settings,*/wsgi.py"
./scripts/check-coverage.py
flake8 project scripts --ignore=E128,E501,E401 --exclude="migrations,settings,*/wsgi.py"
coverage html
coverage report

27
scripts/check-coverage.py Executable file
View 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)