forked from aws/aws-parallelcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtox.ini
More file actions
276 lines (250 loc) · 6.39 KB
/
tox.ini
File metadata and controls
276 lines (250 loc) · 6.39 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
[tox]
toxworkdir=../.tox
envlist =
py{39,310,311,312}-{cov,nocov}
code-linters
cfn-{tests,lint,format-check}
# Default testenv. Used to run tests on all python versions.
[testenv]
passenv =
CI
GITHUB_*
usedevelop =
cov: true
nocov: false
allowlist_externals =
bash
deps =
setuptools
-rtests/requirements.txt
extras =
awslambda
commands =
bash ./tests/pcluster/test.sh
nocov: pytest -n auto -l -v --basetemp={envtmpdir} --html=report.html --ignore=src tests/
cov: python setup.py clean --all build_ext --force --inplace
cov: pytest -n auto -l -v --basetemp={envtmpdir} --html=report.html --cov=src --cov-report=xml --cov-append tests/
# Section used to define common variables used by multiple testenvs.
[vars]
code_dirs =
setup.py \
src/ \
tests/ \
../cloudformation/ \
../tests/ \
../util/
##############################
### 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 \
--exclude=custom_resources_code/crhelper \
{[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.
[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-import-order # delegated to isort
flake8-colors
pep8-naming
commands =
flake8 \
setup.py \
src/ \
tests/ \
../cloudformation/ \
../tests/integration-tests/ \
../util/ \
{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 \
--exclude ../tests,tests,../cloudformation/tests \
{[vars]code_dirs} \
{posargs}
# checks that README file is well-formed.
[testenv:readme]
basepython = python3
skip_install = true
deps =
readme_renderer
commands =
python setup.py check -r -s
# Pylint linter for python: https://www.pylint.org/
# Pylint config is located in .pylintrc file.
[testenv:pylint]
basepython = python3
deps =
setuptools
pyflakes
pylint
commands =
pylint \
setup.py \
src/pcluster \
--ignore=src/awsbatch,src/pcluster/api/models \
{posargs}
# Vulture finds unused code in python: https://github.com/jendrikseipp/vulture
[testenv:vulture]
basepython = python3
skip_install = true
deps =
vulture
commands =
vulture \
setup.py \
src/ \
../util/ \
{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 \
--config p/default \
--config p/owasp-top-ten \
--config p/dockerfile \
--exclude 'tests/**' \
--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:pylint]deps}
{[testenv:bandit]deps}
{[testenv:semgrep]deps}
# {[testenv:readme]deps}
commands =
{[testenv:black-check]commands}
{[testenv:isort-check]commands}
{[testenv:flake8]commands}
{[testenv:pylint]commands}
{[testenv:bandit]commands}
{[testenv:semgrep]commands}
# {[testenv:readme]commands}
##############################
### CLOUDFORMATION ###
##############################
# Validate CloudFormation yaml/json templates: https://github.com/awslabs/cfn-python-lint.
[testenv:cfn-lint]
basepython = python3
skip_install = true
changedir =
../cloudformation
deps = cfn-lint
commands =
cfn-lint --info networking/*.cfn.json
cfn-lint --non-zero-exit-code error */*.yaml
# Validates that cfn json templates are correctly formatted.
[testenv:cfn-format-check]
basepython = python3
skip_install = true
deps =
cfn-flip
changedir =
../cloudformation
commands =
python utils/cfn_formatter.py -c --format json *.cfn.json
python utils/cfn_formatter.py -c --format json networking/*.cfn.json
# Formats all cfn.json files.
[testenv:cfn-format]
basepython = python3
skip_install = true
deps =
cfn-flip
changedir =
../cloudformation
commands =
python utils/cfn_formatter.py --format json *.cfn.json
python utils/cfn_formatter.py --format json networking/*.cfn.json
# Runs tests for cfn templates.
[testenv:cfn-tests]
basepython = python3
skip_install = true
changedir =
../cloudformation/tests
deps =
-r ../cloudformation/tests/requirements.txt
commands =
py.test -l --basetemp={envtmpdir}
#############################
### TOOLING ###
#############################
# Creates a source and built distribution in the dist directory.
# Very handy when you want to package the cli and test on a different machine.
# Simply grab the tar.gz file outputted by the build and run a pip install aws-parallelcluster.tar.gz.
[testenv:build]
basepython = python3
skip_install = true
deps =
wheel
setuptools
commands =
python setup.py -q sdist bdist_wheel