jenkins: adopt authentic way of doing tox.ini and Jenkinsfile
This commit is contained in:
parent
6e4cef6d5c
commit
af2513e56e
|
@ -2,19 +2,28 @@
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
options { disableConcurrentBuilds() }
|
||||||
|
environment {
|
||||||
|
TMPDIR = "/tmp/$BUILD_TAG"
|
||||||
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Unit Tests') {
|
stage('Unit Tests') {
|
||||||
steps {
|
steps {
|
||||||
sh 'tox -rv'
|
sh "mkdir ${env.TMPDIR}"
|
||||||
|
sh """
|
||||||
|
virtualenv -p python3 ${env.TMPDIR}/venv/
|
||||||
|
${env.TMPDIR}/venv/bin/pip install tox "virtualenv<=20.0.5" "importlib-resources<=1.0.2"
|
||||||
|
PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off ${env.TMPDIR}/venv/bin/tox -r"""
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
utils = new Utils()
|
utils = new Utils()
|
||||||
utils.publish_coverage('coverage.xml')
|
utils.publish_coverage('coverage.xml')
|
||||||
utils.publish_coverage_native()
|
utils.publish_coverage_native('index.html')
|
||||||
|
utils.publish_pylint('pylint.out')
|
||||||
}
|
}
|
||||||
junit 'junit.xml'
|
mergeJunitResults()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +45,7 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
success {
|
success {
|
||||||
|
sh "rm -rf ${env.TMPDIR}"
|
||||||
cleanWs()
|
cleanWs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
pylint -f parseable "$@" > pylint.out || /bin/true
|
|
@ -172,7 +172,7 @@ olap = olap
|
||||||
|
|
||||||
with (wcs_dir / 'wcs.cfg').open('w') as fd:
|
with (wcs_dir / 'wcs.cfg').open('w') as fd:
|
||||||
fd.write(u'''[main]
|
fd.write(u'''[main]
|
||||||
app_dir = %s\n''' % wcs_dir)
|
app_dir = %s\n''' % (str(wcs_dir).replace('%', '%%')))
|
||||||
|
|
||||||
with (wcs_dir / 'local_settings.py').open('w') as fd:
|
with (wcs_dir / 'local_settings.py').open('w') as fd:
|
||||||
fd.write(u'''
|
fd.write(u'''
|
||||||
|
@ -230,7 +230,7 @@ orig = olap
|
||||||
key = olap
|
key = olap
|
||||||
schema = olap
|
schema = olap
|
||||||
cubes_slug = olap-slug
|
cubes_slug = olap-slug
|
||||||
'''.format(wcs=wcs, model_dir=model_dir, dsn=postgres_db.dsn))
|
'''.format(wcs=wcs, model_dir=str(model_dir).replace('%', '%%'), dsn=postgres_db.dsn))
|
||||||
|
|
||||||
from wcs_olap import cmd
|
from wcs_olap import cmd
|
||||||
import sys
|
import sys
|
||||||
|
|
56
tox.ini
56
tox.ini
|
@ -5,29 +5,51 @@
|
||||||
|
|
||||||
[tox]
|
[tox]
|
||||||
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/wcs-olap/{env:BRANCH_NAME:}
|
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/wcs-olap/{env:BRANCH_NAME:}
|
||||||
envlist = py3-coverage
|
envlist = py3
|
||||||
|
|
||||||
|
[tox:jenkins]
|
||||||
|
envlist =
|
||||||
|
pylint
|
||||||
|
py3
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
usedevelop = true
|
usedevelop = true
|
||||||
setenv =
|
setenv =
|
||||||
coverage: COVERAGE=--junit-xml=junit.xml --cov=wcs_olap --cov-report xml --cov-report html
|
COVERAGE={tty::--cov=wcs_olap --cov-branch --cov-append --cov-report xml --cov-report html}
|
||||||
WCS_MANAGE=wcs/manage.py
|
JUNIT={tty::-o junit_suite_name={envname} --junit-xml=junit-{envname}.xml}
|
||||||
|
WCS_MANAGE=wcs/manage.py
|
||||||
|
PGDATABASE=postgres
|
||||||
deps =
|
deps =
|
||||||
coverage
|
pytest
|
||||||
pytest
|
pytest-cov
|
||||||
pytest-cov
|
pytest-random
|
||||||
pytest-random
|
httmock
|
||||||
quixote>=3
|
|
||||||
psycopg2-binary
|
# w.c.s. dependencies, as it cannot b installed through pip
|
||||||
vobject
|
quixote>=3
|
||||||
pyproj
|
psycopg2-binary
|
||||||
django-ratelimit<3
|
vobject
|
||||||
gadjo
|
pyproj
|
||||||
httmock
|
django-ratelimit<3
|
||||||
django>=1.11,<1.12
|
gadjo
|
||||||
|
django>=1.11,<1.12
|
||||||
|
passenv=
|
||||||
|
BRANCH_NAME
|
||||||
|
# support for pg_virtualenv
|
||||||
|
PGPORT
|
||||||
|
PGHOST
|
||||||
|
PGUSER
|
||||||
|
PGPASSWORD
|
||||||
commands =
|
commands =
|
||||||
./get_wcs.sh
|
./get_wcs.sh
|
||||||
py.test {env:COVERAGE:} {posargs:--random-group tests}
|
py.test {tty:--sw:} {env:JUNIT:} {env:COVERAGE:} {posargs:--random-group tests}
|
||||||
|
|
||||||
|
[testenv:pylint]
|
||||||
|
basepython = python3
|
||||||
|
deps =
|
||||||
|
pylint
|
||||||
|
commands =
|
||||||
|
/bin/bash -c "./pylint.sh wcs_olap"
|
||||||
|
|
||||||
[pytest]
|
[pytest]
|
||||||
junit_family=xunit2
|
junit_family=xunit2
|
||||||
|
|
Loading…
Reference in New Issue