This commit is contained in:
parent
71d23268da
commit
ffb4754696
|
@ -9,7 +9,7 @@ pipeline {
|
|||
stages {
|
||||
stage('Unit Tests') {
|
||||
steps {
|
||||
sh 'tox -rv'
|
||||
sh 'nox'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
|
|
22
getlasso3.sh
22
getlasso3.sh
|
@ -1,22 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Get venv site-packages path
|
||||
DSTDIR=`python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'`
|
||||
|
||||
# Get not venv site-packages path
|
||||
# Remove first path (assuming that is the venv path)
|
||||
NONPATH=`echo $PATH | sed 's/^[^:]*://'`
|
||||
SRCDIR=`PATH=$NONPATH python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'`
|
||||
|
||||
# Clean up
|
||||
rm -f $DSTDIR/lasso.*
|
||||
rm -f $DSTDIR/_lasso.*
|
||||
|
||||
# Link
|
||||
ln -sv /usr/lib/python3/dist-packages/lasso.py $DSTDIR/
|
||||
for SOFILE in /usr/lib/python3/dist-packages/_lasso.cpython-*.so
|
||||
do
|
||||
ln -sv $SOFILE $DSTDIR/
|
||||
done
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,115 @@
|
|||
import os
|
||||
import shlex
|
||||
from functools import partial
|
||||
from pathlib import Path
|
||||
|
||||
import nox
|
||||
|
||||
nox.options.sessions = ['tests', 'pylint', 'codestyle']
|
||||
|
||||
|
||||
def get_lasso3(session):
|
||||
src_dir = Path('/usr/lib/python3/dist-packages/')
|
||||
venv_dir = Path(session.virtualenv.location)
|
||||
for dst_dir in venv_dir.glob('lib/**/site-packages'):
|
||||
files_to_link = [src_dir / 'lasso.py'] + list(src_dir.glob('_lasso.cpython-*.so'))
|
||||
|
||||
for src_file in files_to_link:
|
||||
dst_file = dst_dir / src_file.name
|
||||
if dst_file.exists():
|
||||
dst_file.unlink()
|
||||
session.log('%s => %s', dst_file, src_file)
|
||||
dst_file.symlink_to(src_file)
|
||||
|
||||
|
||||
def setup_venv(session, *packages, django_version='3.2'):
|
||||
session.install(
|
||||
'-e',
|
||||
'.',
|
||||
'WebTest',
|
||||
'django-webtest',
|
||||
f'django=={django_version}',
|
||||
'git+https://git.entrouvert.org/entrouvert/debian-django-ckeditor.git',
|
||||
'git+https://git.entrouvert.org/publik-django-templatetags.git',
|
||||
'pyquery',
|
||||
'pytest!=5.3.3',
|
||||
*packages,
|
||||
)
|
||||
get_lasso3(session)
|
||||
|
||||
|
||||
@nox.session()
|
||||
@nox.parametrize('django', ['3.2'])
|
||||
def tests(session, django):
|
||||
setup_venv(
|
||||
session,
|
||||
'django-filter>=2.4,<2.5',
|
||||
'django-mellon>=1.13',
|
||||
'psycopg2-binary',
|
||||
'pytest-cov',
|
||||
'pytest-django',
|
||||
'pytest-freezegun',
|
||||
django_version=django,
|
||||
)
|
||||
|
||||
args = ['py.test']
|
||||
if '--coverage' in session.posargs or not session.interactive:
|
||||
while '--coverage' in session.posargs:
|
||||
session.posargs.remove('--coverage')
|
||||
args += [
|
||||
'--cov-report',
|
||||
'xml',
|
||||
'--cov-report',
|
||||
'html',
|
||||
'--cov=lingo/',
|
||||
'--cov-config',
|
||||
'.coveragerc',
|
||||
'-v',
|
||||
f'--junitxml=junit-coverage.django-{django}.xml',
|
||||
]
|
||||
|
||||
args += session.posargs
|
||||
|
||||
session.run(
|
||||
*args,
|
||||
env={
|
||||
'DJANGO_SETTINGS_MODULE': 'lingo.settings',
|
||||
'LINGO_SETTINGS_FILE': 'tests/settings.py',
|
||||
'SETUPTOOLS_USE_DISTUTILS': 'stdlib',
|
||||
'DB_ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'BRANCH_NAME': os.environ.get('BRANCH_NAME', ''),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@nox.session
|
||||
def pylint(session):
|
||||
setup_venv(session, 'pylint<3', 'pylint-django')
|
||||
pylint_command = ['pylint', '-f', 'parseable', '--rcfile', 'pylint.rc']
|
||||
|
||||
if not session.posargs:
|
||||
pylint_command += ['lingo/', 'tests/']
|
||||
else:
|
||||
pylint_command += session.posargs
|
||||
|
||||
if not session.interactive:
|
||||
session.run(
|
||||
'bash',
|
||||
'-c',
|
||||
f'{shlex.join(pylint_command)} | tee pylint.out ; test $PIPESTATUS -eq 0',
|
||||
external=True,
|
||||
)
|
||||
else:
|
||||
session.run(*pylint_command)
|
||||
|
||||
|
||||
@nox.session
|
||||
def codestyle(session):
|
||||
session.install('pre-commit')
|
||||
session.run('pre-commit', 'run', '--all-files', '--show-diff-on-failure')
|
||||
|
||||
|
||||
@nox.session()
|
||||
def bandit(session):
|
||||
session.install('bandit')
|
||||
session.run('bandit', '-r', 'lingo')
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e -x
|
||||
env
|
||||
|
||||
pylint -f parseable --rcfile pylint.rc "$@" | tee pylint.out; test $PIPESTATUS -eq 0
|
Loading…
Reference in New Issue