From a6511632ad96788b4d0aebde0890ed973112e323 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Wed, 14 Aug 2019 20:28:23 -0400 Subject: [PATCH] closes #3407 - Added code coverage reporting to the CI pipeline --- .gitignore | 1 + .travis.yml | 1 + CHANGELOG.md | 8 ++++++++ scripts/cibuild.sh | 10 +++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d859bad28..e02e72710 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ fabfile.py gunicorn_config.py .DS_Store .vscode +.coverage diff --git a/.travis.yml b/.travis.yml index 29fa87b64..872121c21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ python: install: - pip install -r requirements.txt - pip install pycodestyle + - pip install coverage before_script: - psql --version - psql -U postgres -c 'SELECT version();' diff --git a/CHANGELOG.md b/CHANGELOG.md index eaf8cd930..5216d32a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +v2.7.0 (FUTURE) + +## Housekeeping + +* [#3407](https://github.com/netbox-community/netbox/issues/3407) - Added code coverage reporting to the CI pipeline + +--- + v2.6.3 (FUTURE) ## Bug Fixes diff --git a/scripts/cibuild.sh b/scripts/cibuild.sh index c0a49b5ef..282000b0a 100755 --- a/scripts/cibuild.sh +++ b/scripts/cibuild.sh @@ -41,13 +41,21 @@ sed -i -e "s/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \['*'\]/g" $CONFIG sed -i -e "s/SECRET_KEY = ''/SECRET_KEY = 'netboxci'/g" $CONFIG # Run NetBox tests -./netbox/manage.py test netbox/ +coverage run --source="netbox/" netbox/manage.py test netbox/ RC=$? if [[ $RC != 0 ]]; then echo -e "\n$(info) one or more tests failed, failing build." EXIT=$RC fi +# Show code coverage report +coverage report --skip-covered --omit *migrations* +RC=$? +if [[ $RC != 0 ]]; then + echo -e "\n$(info) failed to generate code coverage report." + EXIT=$RC +fi + # Show build duration END=$(date +%s) echo "$(info) exiting with code $EXIT after $(($END - $START)) seconds."