forked from aws/aws-parallelcluster-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
179 lines (162 loc) · 4.27 KB
/
tox.ini
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
[tox]
toxworkdir=.tox
skipsdist=True
envlist =
py{36,37,38,39}
code-linters
# Default testenv. Used to run tests on all python versions.
[testenv]
deps = -rtest/unit/requirements.txt
setenv = PYTHONPATH = {toxinidir}/files/default:cookbooks/aws-parallelcluster-config/files/default:cookbooks/aws-parallelcluster-slurm/files/default/head_node_slurm
commands =
py.test -l -v --basetemp={envtmpdir} --html=report.html --cov=files/default test/unit
# Section used to define common variables used by multiple testenvs.
[vars]
code_dirs =
cookbooks/aws-parallelcluster-config/files/default/dcv/ \
cookbooks/aws-parallelcluster-slurm/files/default/head_node_slurm/slurm/ \
test/unit/
##############################
### AUTO-FORMATTER ###
##############################
# black is a code formatter for python: https://github.com/ambv/black.
# The following target formats python files with black formatter.
[testenv:black]
basepython = python3
skip_install = true
deps =
black
commands =
black -l 120 \
{[vars]code_dirs} \
{posargs}
# Checks that python files are correctly formatted.
[testenv:black-check]
basepython = python3
skip_install = true
deps =
{[testenv:black]deps}
commands =
{[testenv:black]commands} --check --diff
# isort is an imports sorter for python: https://github.com/timothycrosley/isort
# The following target sorts the import according to .isort.cfg file.
# Pin isort to the last release prior to 5.0.0, which resulted in import
# statements being flagged as improperly sorted where previously they were
# not. See https://timothycrosley.github.io/isort/docs/major_releases/introducing_isort_5/.
[testenv:isort]
basepython = python3
skip_install = true
deps =
isort
seed-isort-config
commands =
isort -w 120 \
{[vars]code_dirs} \
{posargs}
# Checks that python imports are correctly sorted.
[testenv:isort-check]
basepython = python3
skip_install = true
deps = {[testenv:isort]deps}
commands = {[testenv:isort]commands} --check --diff
# Reformats code with black and isort.
[testenv:autoformat]
basepython = python3
skip_install = true
deps =
{[testenv:isort]deps}
{[testenv:black]deps}
commands =
{[testenv:isort]commands}
{[testenv:black]commands}
#############################
### LINTERS ###
#############################
# flake8 python linter: https://github.com/PyCQA/flake8.
# flake8 config is located in .flake8 file
[testenv:flake8]
basepython = python3
skip_install = true
deps =
flake8
flake8-docstrings
flake8-bugbear
flake8-mypy
# flake8-import-order # delegated to isort
flake8-colors
pep8-naming
commands =
flake8 \
{[vars]code_dirs} \
{posargs}
# bandit security linter for python: https://github.com/PyCQA/bandit
[testenv:bandit]
basepython = python3
skip_install = true
deps =
bandit
commands =
bandit -r \
-c .bandit.ini \
{[vars]code_dirs} \
{posargs}
# Pylint linter for python: https://www.pylint.org/
# Pylint config is located in .pylintrc file.
[testenv:pylint]
basepython = python3
deps =
pyflakes
pylint
commands =
pylint \
{[vars]code_dirs} \
{posargs}
# Vulture finds unused code in python: https://github.com/jendrikseipp/vulture
[testenv:vulture]
basepython = python3
skip_install = true
deps =
vulture
commands =
vulture \
{[vars]code_dirs} \
{posargs}
# Static type checker for Python: http://mypy-lang.org/
[testenv:mypy]
basepython = python3
deps =
mypy
commands =
mypy \
{[vars]code_dirs} \
{posargs}
# semgrep is used to check for security issues
# https://semgrep.dev/
[testenv:semgrep]
basepython = python3
deps =
semgrep
commands =
semgrep \
--config p/r2c-security-audit \
--config p/secrets \
--exclude 'third-party/**' \
--error
# Target that groups all code linters to run in Travis.
[testenv:code-linters]
basepython = python3
skip_install = true
deps =
{[testenv:black-check]deps}
{[testenv:isort-check]deps}
{[testenv:flake8]deps}
{[testenv:bandit]deps}
{[testenv:semgrep]deps}
# {[testenv:pylint]deps}
commands =
{[testenv:black-check]commands}
{[testenv:isort-check]commands}
{[testenv:flake8]commands}
{[testenv:bandit]commands}
{[testenv:semgrep]commands}
# {[testenv:pylint]commands}