-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
83 lines (72 loc) · 2.7 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright (c) 2020 Jorge Chamorro Padiel, Luis Liñán Villafranca. All rights
# reserved.
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>
"""Nox test automation file."""
from typing import List
import nox
requirements: List[str] = ["-r", "requirements.txt"]
test_requirements: List[str] = [
*requirements,
"pytest==5.4.3",
"pytest-cov==2.10.0",
]
format_requirements: List[str] = ["black==19.10b0", "isort==4.3.21"]
lint_requirements: List[str] = [
*requirements,
*format_requirements,
"pylint==2.5.3",
"mypy==0.782",
"flake8==3.8.3",
"pycodestyle==2.6.0",
]
python_target_files = ["etsiit_bot/", "tests/"]
python = ["3.6", "3.7", "3.8"]
nox.options.reuse_existing_virtualenvs = True
nox.options.stop_on_first_error = False
###############################################################################
# Linting
###############################################################################
@nox.session(name="lintpy")
def lint_python(session):
"""Lint Python source code."""
session.log("# Linting Python files...")
session.install(*lint_requirements)
session.run("pylint", *python_target_files)
session.run("mypy", *python_target_files)
session.run("flake8", *python_target_files)
session.run("pycodestyle", *python_target_files)
session.run("black", "-l", "79", "--check", "--diff", *python_target_files)
session.run("isort", "-rc", "--check-only", "--diff", *python_target_files)
@nox.session(name="lintmd")
def lint_markdown(session):
"""Lint Markdown files."""
session.log("# Linting Markdown files...")
session.run("mdl", "--style", ".mdl.rb", ".", external=True)
###############################################################################
# Formating
###############################################################################
@nox.session(name="format")
def python_format(session):
"""Format Python source code."""
session.log("# Formating Python files...")
session.install(*format_requirements)
session.run("black", "-l", "79", *python_target_files)
session.run("isort", *python_target_files)
###############################################################################
# Testing
###############################################################################
@nox.session(python=python)
def tests(session):
"""Run python tests."""
session.log("# Running tests...")
session.install(*test_requirements)
session.run(
"pytest",
env={
"REPO_ROOT": "REPO_ROOT_dummy",
"TELEGRAM_TOKEN": "TELEGRAM_TOKEN_dummy",
"PROJECT_NAME": "PROJECT_NAME_dummy",
"PORT": "123",
},
)