From f39f94848fb95eb4866e04885bb197b34d264797 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Mar 07 2018 03:27:26 +0000 Subject: Jenkinsfile: run unit tests Previously, this wasn't necessary as a separate step because the RPM build was running unit tests in %check. However this is no longer the case since the unit tests require a local Postgres. --- diff --git a/Jenkinsfile b/Jenkinsfile index 14d2270..e379283 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,16 +7,32 @@ try { // massive try{} catch{} around the entire build for failure notifications node('fedora') { checkout scm - sh 'sudo dnf -y builddep waiverdb.spec' - sh 'sudo dnf -y install python3-flake8 python3-pylint python3-sphinx python3-sphinxcontrib-httpdomain' - /* Needed for mock EPEL7 builds: https://bugzilla.redhat.com/show_bug.cgi?id=1528272 */ - sh 'sudo dnf -y install dnf-utils' + stage('Prepare') { + sh 'sudo dnf -y builddep waiverdb.spec' + sh 'sudo dnf -y install python3-flake8 python3-pylint python3-pytest python3-sphinx python3-sphinxcontrib-httpdomain' + /* Needed for mock EPEL7 builds: https://bugzilla.redhat.com/show_bug.cgi?id=1528272 */ + sh 'sudo dnf -y install dnf-utils' + /* Unit tests need local Postgres */ + sh """ + sudo dnf -y install postgresql-server + sudo postgresql-setup --initdb + sudo systemctl enable --now postgresql + sudo -u postgres createuser --superuser $USER + """ + } stage('Invoke Flake8') { sh 'flake8' } stage('Invoke Pylint') { sh 'pylint-3 --reports=n waiverdb' } + stage('Run unit tests') { + sh """ + createdb waiverdb + cp conf/settings.py.example conf/settings.py + py.test-3 -v tests/ + """ + } stage('Build Docs') { sh 'make -C docs html' archiveArtifacts artifacts: 'docs/_build/html/**'