Jenkinsfile: use pgvirtualenv
This commit is contained in:
parent
a8cdbf3dfc
commit
ea13b6f87f
|
@ -6,10 +6,16 @@ pipeline {
|
|||
disableConcurrentBuilds()
|
||||
timeout(time: 20, unit: 'MINUTES')
|
||||
}
|
||||
environment {
|
||||
TMPDIR = "${sh(returnStdout: true, script: "mktemp -d").trim()}"
|
||||
}
|
||||
stages {
|
||||
stage('Unit Tests') {
|
||||
steps {
|
||||
sh 'tox -r'
|
||||
sh """
|
||||
python3 -m venv ${env.TMPDIR}/venv/
|
||||
${env.TMPDIR}/venv/bin/pip install tox
|
||||
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 --workdir ${env.TMPDIR}/tox/"""
|
||||
}
|
||||
post {
|
||||
always {
|
||||
|
@ -41,6 +47,7 @@ pipeline {
|
|||
}
|
||||
}
|
||||
cleanup {
|
||||
sh "rm -rf ${env.TMPDIR}"
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,11 @@ DATABASES = {
|
|||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'TEST': {
|
||||
'NAME': 'barbacompta-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-')[:45],
|
||||
'NAME': 'barbacompta-test',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
for key in ('PGPORT', 'PGHOST', 'PGUSER', 'PGPASSWORD'):
|
||||
if key in os.environ:
|
||||
DATABASES['default']['TEST'][key[2:]] = os.environ[key]
|
||||
|
|
Loading…
Reference in New Issue