130 lines
3.5 KiB
Python
130 lines
3.5 KiB
Python
import shlex
|
|
from pathlib import Path
|
|
|
|
import nox
|
|
|
|
|
|
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,<3.3'):
|
|
session.install(
|
|
'-e',
|
|
'.',
|
|
f'django{django_version}',
|
|
'WebTest',
|
|
'django-mellon>=1.13',
|
|
'django-webtest',
|
|
'git+https://git.entrouvert.org/entrouvert/publik-django-templatetags.git',
|
|
'httmock',
|
|
'pytest!=5.3.3',
|
|
'responses',
|
|
'uwsgidecorators',
|
|
'git+https://git.entrouvert.org/entrouvert/debian-django-ckeditor.git',
|
|
*packages,
|
|
)
|
|
get_lasso3(session)
|
|
|
|
|
|
@nox.session()
|
|
@nox.parametrize('django', ['>=3.2,<3.3'])
|
|
def tests(session, django):
|
|
setup_venv(
|
|
session,
|
|
'pytest-cov',
|
|
'pytest-django',
|
|
'pytest-freezegun',
|
|
'pytest-xdist',
|
|
'mock<4',
|
|
'astroid<3',
|
|
'pyquery',
|
|
'psycopg2-binary',
|
|
'django-ratelimit<3',
|
|
'djangorestframework>=3.12,<3.13 ', # matching debian bullseye,
|
|
django_version=django,
|
|
)
|
|
|
|
session.run('python', 'manage.py', 'compilemessages')
|
|
|
|
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=combo/',
|
|
'--cov-config',
|
|
'.coveragerc',
|
|
'-v',
|
|
f'--junitxml=junit-coverage.django-{django}.xml',
|
|
]
|
|
|
|
if not session.interactive:
|
|
args += ['-v', '--numprocesses', '6']
|
|
|
|
args += session.posargs + ['tests/']
|
|
|
|
session.run(
|
|
*args,
|
|
env={
|
|
'DJANGO_SETTINGS_MODULE': 'combo.settings',
|
|
'COMBO_SETTINGS_FILE': 'tests/settings.py',
|
|
'SETUPTOOLS_USE_DISTUTILS': 'stdlib',
|
|
'DB_ENGINE': 'django.db.backends.postgresql_psycopg2',
|
|
},
|
|
)
|
|
|
|
|
|
@nox.session
|
|
def pylint(session):
|
|
setup_venv(session, 'pylint<3', 'pylint-django', 'nox')
|
|
pylint_command = ['pylint', '--jobs', '6', '-f', 'parseable', '--rcfile', 'pylint.rc']
|
|
|
|
if not session.posargs:
|
|
pylint_command += ['combo/', 'tests/', 'noxfile.py']
|
|
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 js_tests(session):
|
|
session.install('nodeenv')
|
|
session.run('nodeenv', '--prebuilt', '--python-virtualenv')
|
|
session.run('npm', 'install', 'vite', 'vitest', 'happy-dom', '@vitest/coverage-v8')
|
|
session.run(
|
|
'npx',
|
|
'vitest',
|
|
'--run',
|
|
'--coverage',
|
|
)
|