From 7881d7c6d0a497fe296b78bbf44c759cf6b7ca32 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 12 May 2020 23:08:31 +0200 Subject: [PATCH] Jenkinsfile: use virtualenv to install tox --- Jenkinsfile | 10 +++++++--- tests/settings.py | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 991ceac..68d1e9a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,8 +5,11 @@ pipeline { stages { stage('Unit Tests') { steps { - sh 'env' - 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 { always { @@ -16,7 +19,7 @@ pipeline { utils.publish_coverage_native('index.html') utils.publish_pylint('pylint.out') } - junit '*_results.xml' + mergeJunitResults() } } } @@ -38,6 +41,7 @@ pipeline { } } success { + sh "rm -rf ${env.TMPDIR}" cleanWs() } } diff --git a/tests/settings.py b/tests/settings.py index 2700c9a..063bbef 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -2,15 +2,19 @@ import os ALLOWED_HOSTS = ['localhost'] LANGUAGE_CODE = 'en' + DATABASES = { 'default': { 'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.sqlite3'), - 'TEST': { - 'NAME': 'a2-test', - }, + 'NAME': 'authentic2', } } +if 'postgres' in DATABASES['default']['ENGINE']: + for key in ('PGPORT', 'PGHOST', 'PGUSER', 'PGPASSWORD'): + if key in os.environ: + DATABASES['default'][key[2:]] = os.environ[key] + A2_RBAC_MANAGED_CONTENT_TYPES = () A2_RBAC_ROLE_ADMIN_RESTRICT_TO_OU_USERS = True