-
Notifications
You must be signed in to change notification settings - Fork 1
/
noxfile.py
57 lines (41 loc) · 1.51 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import shutil
import nox
nox.options.reuse_existing_virtualenvs = True
PYTHON_VERSIONS = ['pypy3', '3.8', '3.9', '3.10', '3.11', '3.12']
CI_ENVIRONMENT = 'GITHUB_ACTIONS' in os.environ
@nox.session(python=PYTHON_VERSIONS[-1])
def lint(session):
"""Performs pep8 and security checks."""
source_code = 'ws'
session.run('poetry', 'install', '--only', 'lint')
session.run('ruff', 'check', source_code)
session.run('ruff', 'format', '.')
session.run('bandit', '-r', source_code)
@nox.session(python=PYTHON_VERSIONS[-1])
def safety(session):
"""Checks vulnerabilities of the installed packages."""
session.run('poetry', 'install', '--only', 'audit')
session.run('safety', 'check')
@nox.session(python=PYTHON_VERSIONS)
def tests(session):
"""Runs the test suite."""
session.run('poetry', 'install', '--with', 'test')
session.run('pytest')
@nox.session(python=PYTHON_VERSIONS[-1])
def docs(session):
"""Builds the documentation."""
session.run('poetry', 'install', '--only', 'docs')
session.run('mkdocs', 'build', '--clean')
@nox.session(python=False)
def deploy(session):
"""
Deploys on pypi.
"""
if 'POETRY_PYPI_TOKEN_PYPI' not in os.environ:
session.error('you must specify your pypi token api to deploy your package')
session.run('poetry', 'publish', '--build')
@nox.session(python=False)
def clean(*_):
"""Since nox take a bit of memory, this command helps to clean nox environment."""
shutil.rmtree('.nox', ignore_errors=True)