Jenkinsfile: use pg_virtualenv to isolate the postgres database (#74887)
gitea/zoo/pipeline/head This commit looks good Details

This commit is contained in:
Benjamin Dauvergne 2023-02-27 11:40:14 +01:00
parent 0440e461be
commit 9bdd837ecd
4 changed files with 12 additions and 2 deletions

2
Jenkinsfile vendored
View File

@ -5,7 +5,7 @@ pipeline {
stages { stages {
stage('Unit Tests') { stage('Unit Tests') {
steps { steps {
sh 'tox -rv' sh 'pg_virtualenv -o fsync=off tox -rv'
} }
post { post {
always { always {

0
tests/__init__.py Normal file
View File

8
tests/settings.py Normal file
View File

@ -0,0 +1,8 @@
import os
from zoo.settings import *
# integrate with pg_virtualenv by getting pg configuration from environment variables
for key in ('PGPORT', 'PGHOST', 'PGUSER', 'PGPASSWORD'):
if key in os.environ:
DATABASES['default'][key[2:]] = os.environ[key]

View File

@ -10,8 +10,10 @@ envlist =
py3-dj32 py3-dj32
[testenv] [testenv]
passenv=
PG*
setenv = setenv =
DJANGO_SETTINGS_MODULE=zoo.settings DJANGO_SETTINGS_MODULE=tests.settings
SETUPTOOLS_USE_DISTUTILS=stdlib SETUPTOOLS_USE_DISTUTILS=stdlib
JUNIT={tty::--junitxml=junit-{envname}.xml} JUNIT={tty::--junitxml=junit-{envname}.xml}
COVERAGE={tty::--cov-report xml --cov-report html --cov=zoo/} COVERAGE={tty::--cov-report xml --cov-report html --cov=zoo/}