Skip to content

Commit

Permalink
nox file
Browse files Browse the repository at this point in the history
  • Loading branch information
BinarSkugga committed Oct 10, 2023
1 parent 7cdc958 commit 03794e4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
ignore = E501
exclude =
.git,
.nox,
.pytest_cache,
__pycache__,
build,
dist,
*_pb2.py
44 changes: 44 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import sys

import nox
from nox import Session

IN_CI = 'GITLAB_CI' in os.environ
PARALLEL = os.environ.get('TEST_PARALLEL', 'false') == 'true'
# Only reuse virtualenvs in local testing
nox.options.reuse_existing_virtualenvs = not IN_CI
environment = {**os.environ}


@nox.session()
def lint(session):
session.install('flake8')
session.run('flake8', 'src')
session.run('flake8', 'tests')


@nox.session
def safety(session):
session.install('wheel==0.38.*')
session.install('safety')
session.run('safety', 'check', '--full-report')


@nox.session()
def tests(session: Session):
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + os.sep + 'src')

session.run(sys.executable, "-m", "pip", "install", "-U", "pip")
session.run(sys.executable, 'setup.py', 'install', env={**environment, 'PYTHONPATH': os.pathsep.join(sys.path)})

if PARALLEL:
session.install('pytest-xdist')
num_proc = os.environ.get('TEST_NUM_PROCESSES', '8')
num_proc = int(num_proc) if num_proc != 'auto' else 'auto'
session.run('pytest', '--cov-config=.coveragerc', '--dist=loadfile', f'--numprocesses={num_proc}',
'--tx', 'popen//python=python', '--cov=src', '--junitxml=tests/report.xml', 'tests',
env={**environment, 'PYTHONPATH': os.pathsep.join(sys.path)})
else:
session.run('pytest', 'tests', env={**environment, 'PYTHONPATH': os.pathsep.join(sys.path)})

Empty file added tests/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_dummy():
assert not False

0 comments on commit 03794e4

Please sign in to comment.