From 62c9ddccadb2fab29c6a22830c08f3fa036ef7f7 Mon Sep 17 00:00:00 2001 From: Hunor Csomortáni Date: Aug 16 2018 12:17:59 +0000 Subject: [PATCH 1/2] Jenkins: run unit tests and archive coverage report Signed-off-by: Hunor Csomortáni --- diff --git a/Jenkinsfile b/Jenkinsfile index 86f3ac6..d8a5019 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,8 +14,11 @@ node('master'){ timestamps { node('fedora-27') { checkout scm - sh 'sudo dnf -y builddep greenwave.spec' - sh 'sudo dnf -y install python3-flake8 python3-pylint python3-sphinx python3-sphinxcontrib-httpdomain' + sh ''' + sudo dnf -y builddep greenwave.spec + sudo dnf -y install python3-flake8 python3-pylint python3-sphinx \ + python3-sphinxcontrib-httpdomain python3-pytest-cov + ''' /* Needed to get the latest /etc/mock/fedora-28-x86_64.cfg */ sh 'sudo dnf -y update mock-core-configs' stage('Invoke Flake8') { @@ -24,6 +27,27 @@ node('fedora-27') { stage('Invoke Pylint') { sh 'pylint-3 --reports=n greenwave' } + stage('Run unit tests') { + // Yes, this is also done while building the RPM, but we need coverage + sh ''' + rm -rf htmlcov coverage.xml + pytest-3 greenwave/tests/ \ + --cov-config .coveragerc --cov=greenwave \ + --cov-report term --cov-report xml --cov-report html + ''' + archiveArtifacts artifacts: 'htmlcov/**,coverage.xml' + step([ + $class: 'CoberturaPublisher', + autoUpdateHealth: false, + autoUpdateStability: false, + coberturaReportFile: 'coverage.xml', + failUnhealthy: false, + failUnstable: false, + maxNumberOfBuilds: 0, + onlyStable: false, + zoomCoverageChart: false + ]) + } stage('Build Docs') { sh 'DEV=true GREENWAVE_CONFIG=$(pwd)/conf/settings.py.example make -C docs html' archiveArtifacts artifacts: 'docs/_build/html/**' From bdfb8d1c4f75f08dcdacc5258dca6bf5aa6ae7b2 Mon Sep 17 00:00:00 2001 From: Hunor Csomortáni Date: Aug 16 2018 12:17:59 +0000 Subject: [PATCH 2/2] Exclude boilerplate code from coverage measurement Lowering fail_under to 50%. Signed-off-by: Hunor Csomortáni --- diff --git a/.coveragerc b/.coveragerc index 54010cd..9f1c8ce 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,10 +4,11 @@ include = greenwave/* [report] -fail_under = 55 +fail_under = 50 exclude_lines = pragma: no cover if __name__ == .__main__.: omit = greenwave/tests/* - + greenwave/logger.py + greenwave/wsgi.py