From b9a02d2bef71acb1c29925525ecb75c4591cf0c4 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 11 2017 02:55:18 +0000 Subject: [PATCH 1/6] Jenkinsfile: split rpmlint into its out stage --- diff --git a/Jenkinsfile b/Jenkinsfile index 313cd36..71edcc4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,6 @@ node('rcm-tools-jslave-rhel-7') { mkdir -p mock-result/el7 flock /etc/mock/epel-7-x86_64.cfg \ /usr/bin/mock --resultdir=mock-result/el7 -r epel-7-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm - rpmlint -f rpmlint-config.py mock-result/el7/*.rpm """ archiveArtifacts artifacts: 'mock-result/el7/**' }, @@ -39,12 +38,21 @@ node('rcm-tools-jslave-rhel-7') { mkdir -p mock-result/f25 flock /etc/mock/fedora-25-x86_64.cfg \ /usr/bin/mock --resultdir=mock-result/f25 -r fedora-25-x86_64 --clean --rebuild rpmbuild-output/*.src.rpm - rpmlint -f rpmlint-config.py mock-result/f25/*.rpm """ archiveArtifacts artifacts: 'mock-result/f25/**' }, ) } + stage('Invoke Rpmlint') { + parallel ( + 'EPEL7': { + sh 'rpmlint -f rpmlint-config.py mock-result/el7/*.rpm' + }, + 'F25': { + sh 'rpmlint -f rpmlint-config.py mock-result/f25/*.rpm' + }, + ) + } } catch (e) { currentBuild.result = "FAILED" /* Can't use GIT_BRANCH because of this issue https://issues.jenkins-ci.org/browse/JENKINS-35230 */ From 239989ee3a19e8c2af572c05cef4a138038d7860 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 11 2017 02:55:54 +0000 Subject: [PATCH 2/6] Jenkinsfile: run pylint --- diff --git a/Jenkinsfile b/Jenkinsfile index 71edcc4..575f920 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,6 +16,9 @@ node('rcm-tools-jslave-rhel-7') { stage('Invoke Flake8') { sh 'flake8' } + stage('Invoke Pylint') { + sh 'pylint --reports=n waiverdb' + } stage('Build SRPM') { sh './rpmbuild.sh -bs' archiveArtifacts artifacts: 'rpmbuild-output/**' diff --git a/pylintrc b/pylintrc new file mode 100644 index 0000000..16e4ba8 --- /dev/null +++ b/pylintrc @@ -0,0 +1,2 @@ +[MESSAGES CONTROL] +disable=R,C,no-member,fixme From c6c70f9c4ae727bb7497a8e3951465161589f04a Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 11 2017 06:12:20 +0000 Subject: [PATCH 3/6] Jenkinsfile: build docs We need Sphinx >= 1.3 which is not available in RHEL7, so it's easiest if we just switch to running on a Fedora 25 slave instead. --- diff --git a/Jenkinsfile b/Jenkinsfile index 575f920..272922b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ * GNU General Public License for more details. */ -node('rcm-tools-jslave-rhel-7') { +node('fedora') { try { checkout scm stage('Invoke Flake8') { @@ -19,6 +19,10 @@ node('rcm-tools-jslave-rhel-7') { stage('Invoke Pylint') { sh 'pylint --reports=n waiverdb' } + stage('Build Docs') { + sh 'make -C docs html' + archiveArtifacts artifacts: 'docs/_build/html/**' + } stage('Build SRPM') { sh './rpmbuild.sh -bs' archiveArtifacts artifacts: 'rpmbuild-output/**' diff --git a/docs/Makefile b/docs/Makefile index e57b761..6ce88f5 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,7 +2,7 @@ # # You can set these variables from the command line. -SPHINXOPTS = +SPHINXOPTS = -W SPHINXBUILD = sphinx-build SPHINXPROJ = WaiverDB SOURCEDIR = . diff --git a/docs/conf.py b/docs/conf.py index 15c5ef7..0b714e2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -104,7 +104,7 @@ html_theme = 'alabaster' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = [] # -- Options for HTMLHelp output ------------------------------------------ From 12e077c3775b4dbc6b3a2aa96fe2f7ef456c161b Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 11 2017 06:12:20 +0000 Subject: [PATCH 4/6] Jenkinsfile: run rpmdeplint --- diff --git a/Jenkinsfile b/Jenkinsfile index 272922b..77c7fc7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -60,6 +60,30 @@ node('fedora') { }, ) } + stage('Invoke Rpmdeplint') { + parallel ( + 'EPEL7': { + sh """ + rpmdeplint check \ + --repo rhel7,http://pulp.dist.prod.ext.phx2.redhat.com/content/dist/rhel/server/7/7Server/x86_64/os/ \ + --repo rhel7-optional,http://pulp.dist.prod.ext.phx2.redhat.com/content/dist/rhel/server/7/7Server/x86_64/optional/os/ \ + --repo rhel7-extras,http://pulp.dist.prod.ext.phx2.redhat.com/content/dist/rhel/server/7/7Server/x86_64/extras/os/ \ + --repo epel7,http://dl.fedoraproject.org/pub/epel/7/x86_64/ \ + --arch x86_64 \ + mock-result/el7/*.noarch.rpm + """ + }, + 'F25': { + sh """ + rpmdeplint check \ + --repo fedora,http://dl.fedoraproject.org/pub/fedora/linux/releases/25/Everything/x86_64/os/ \ + --repo updates,http://dl.fedoraproject.org/pub/fedora/linux/updates/25/x86_64/ \ + --arch x86_64 \ + mock-result/f25/*.noarch.rpm + """ + }, + ) + } } catch (e) { currentBuild.result = "FAILED" /* Can't use GIT_BRANCH because of this issue https://issues.jenkins-ci.org/browse/JENKINS-35230 */ From 97f1183c9aa55a50d02c1bf5f6351e16ef199a33 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 11 2017 06:12:20 +0000 Subject: [PATCH 5/6] ensure build dependencies are installed in Jenkins Now that we are using disposable Jenkins slaves, we can just install packages we need. Both pylint and sphinx want to import the waiverdb code which means all the runtime dependencies also need to be present. --- diff --git a/Jenkinsfile b/Jenkinsfile index 77c7fc7..e362253 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,6 +13,8 @@ node('fedora') { try { checkout scm + sh 'sudo dnf -y builddep waiverdb.spec' + sh 'sudo dnf -y install python2-flake8 pylint python2-sphinx python-sphinxcontrib-httpdomain' stage('Invoke Flake8') { sh 'flake8' } From edac20ba789f1682f98c9988fa210ab5c38ed1ed Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 11 2017 06:32:47 +0000 Subject: [PATCH 6/6] Jenkinsfile: push Docker container after build Also changed it to use a specific Docker tag, based on the application version, instead of defaulting to "latest". That way we can deploy and test the newly built container *before* we tag it as "latest". --- diff --git a/Jenkinsfile b/Jenkinsfile index e362253..1888f97 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -102,10 +102,20 @@ node('rcm-tools-jslave-rhel-7-docker') { stage('Build Docker container') { unarchive mapping: ['mock-result/el7/': '.'] def el7_rpm = findFiles(glob: 'mock-result/el7/**/*.noarch.rpm')[0] - /* Note that the docker.build step has some magic to guess the - * Dockerfile used, which will break if the build directory (here ".") - * is not the final argument in the string. */ - def image = docker.build 'waiverdb', "--build-arg waiverdb_rpm=$el7_rpm ." + def appversion = sh(returnStdout: true, script: """ + rpm2cpio ${el7_rpm} | \ + cpio --quiet --extract --to-stdout ./usr/lib/python2.7/site-packages/waiverdb\\*.egg-info/PKG-INFO | \ + awk '/^Version: / {print \$2}' + """).trim() + docker.withRegistry( + 'https://docker-registry.engineering.redhat.com/', + 'docker-registry-factory2-builder-sa-credentials') { + /* Note that the docker.build step has some magic to guess the + * Dockerfile used, which will break if the build directory (here ".") + * is not the final argument in the string. */ + def image = docker.build "factory2/waiverdb:${appversion}", "--build-arg waiverdb_rpm=$el7_rpm ." + image.push() + } } } catch (e) { currentBuild.result = "FAILED"