-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
57 lines (38 loc) · 1.57 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 nox
# The below setting make nox re-use any existing environment.
# If you find nox installing a lot of updates it makes sense to rebuild the environment.
# run: nox --no-reuse-existing-virtualenv
nox.options.reuse_existing_virtualenvs = True
PROJECT_FOLDER = "src"
@nox.session(python=False)
def fix_quality(session):
"""Fixes possible quality errors."""
if session.posargs and session.posargs[0] == "skip-sync":
skip_sync = True
else:
skip_sync = False
if not skip_sync:
session.run("poetry", "install", "--sync", external=True)
session.run("black", PROJECT_FOLDER)
session.run("black", "tests")
session.run("ruff", PROJECT_FOLDER, "--fix")
session.run("ruff", "tests", "--fix")
session.run("isort", PROJECT_FOLDER)
session.run("isort", "tests")
@nox.session
def quality(session):
"""This task also runs in the pipeline and should fail when something is wrong
or needs changing. So some of the checks (like black and isort) are set to check-and-fail
instead of automatically fixing it."""
session.run("poetry", "install", "--sync", external=True)
session.run("black", PROJECT_FOLDER, "--check")
session.run("black", "tests", "--check")
session.run("flake8", PROJECT_FOLDER)
session.run("flake8", "tests")
session.run("mypy", PROJECT_FOLDER)
session.run("isort", PROJECT_FOLDER, "--check-only")
session.run("isort", "tests", "--check-only")
@nox.session
def test(session):
session.run("poetry", "install", "--sync", external=True)
session.run("pytest", "tests")