-
Notifications
You must be signed in to change notification settings - Fork 85
/
tox.ini
403 lines (362 loc) · 13 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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
[tox]
envlist =
# <3.11: run all non-MPL tests
py{38,39,310}-{local,integ,accept,examples},
# >=3.11: run all tests with MPL installed and without MPL installed
# The `-mpl` suffix tells tox to install the MPL.
# In the case where the suffix IS NOT appended,
# this runs tests for the target version WITHOUT the MPL installed.
# In the case where the suffix IS appended,
# this runs tests for the target version WITH the MPL installed.
# This does not run any MPL-specific tests; it only runs non-MPL-specific
# tests in a test environment that also has the MPL.
py{311,312}-{local,integ,accept,examples}{,-mpl},
# >=3.11: Run ONLY the MPL-specific tests.
# These must be separate from the above target, since
# these require the `-mpl` suffix.
# The `mpl` prefix specifies a separate target,
# i.e. `mpllocal` instead of `local`.
# `mplXXX` contains tests using MPL components.
py{311,312}-mpl{local,examples}-mpl
nocmk,
bandit, doc8, readme, docs,
{flake8,pylint}{,-tests,-examples},
isort-check, black-check,
# prone to false positives
vulture
# Additional test environments:
#
# vulture :: Runs vulture. Prone to false-positives.
# linters :: Runs all linters over all source code.
# linters-tests :: Runs all linters over all tests.
# linters-examples :: Runs all linters over all examples and examples tests.
# Autoformatter helper environments:
#
# autoformat : Apply all autoformatters
#
# black-check : Check for "black" issues
# blacken : Fix all "black" issues
#
# isort-seed : Generate a known_third_party list for isort.
# NOTE: make the "known_third_party = " line in setup.cfg before running this
# NOTE: currently it incorrectly identifies this library too; make sure you remove it
# isort-check : Check for isort issues
# isort : Fix isort issues
# Operational helper environments:
#
# docs :: Builds Sphinx documentation.
# serve-docs :: Starts local webserver to serve built documentation.
# build :: Builds source and wheel dist files.
# test-release :: Builds dist files and uploads to testpypi pypirc profile.
# release :: Builds dist files and uploads to pypi pypirc profile.
# Reporting environments:
#
# coverage :: Runs code coverage, failing the build if coverage is below the configured threshold
[testenv:base-command]
commands = pytest --basetemp={envtmpdir} -l {posargs}
[testenv]
passenv =
# Identifies AWS KMS key id to use in integration tests
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID \
# Identifies a second AWS KMS key id to use in integration tests
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2 \
# Identifies AWS KMS MRK key id to use in integration tests
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1 \
# Identifies a related AWS KMS MRK key id to use in integration tests
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2 \
# Pass through AWS credentials
AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN \
# AWS Role access in CodeBuild is via the contaner URI
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI \
# Pass through AWS profile name (useful for local testing)
AWS_PROFILE \
# Pass through custom pip config file settings
PIP_CONFIG_FILE
sitepackages = False
deps =
-rdev_requirements/test-requirements.txt
# Install the MPL requirements if the `-mpl` suffix is present
mpl: -rrequirements_mpl.txt
commands =
local: {[testenv:base-command]commands} test/ -m local --ignore test/mpl/
# MPL unit tests require the MPL to be installed
mpllocal: {[testenv:base-command]commands} test/ -m local
integ: {[testenv:base-command]commands} test/ -m integ --ignore test/mpl/
accept: {[testenv:base-command]commands} test/ -m accept --ignore test/mpl/
examples: {[testenv:base-command]commands} examples/test/legacy/ -m examples
# MPL keyring examples require a special IAM role; run these separately under a separate set of permissions
mplexamples: {[testenv:base-command]commands} examples/test/ -m examples --ignore examples/test/legacy/
all: {[testenv:base-command]commands} test/ examples/test/legacy/ --ignore test/mpl/
mplall: {[testenv:base-command]commands} test/ examples/test/
manual: {[testenv:base-command]commands}
# Run code coverage on the unit tests
[testenv:coverage]
commands = {[testenv:base-command]commands} --cov aws_encryption_sdk test/ -m local --ignore test/mpl/
[testenv:mplcoverage-mpl]
commands = {[testenv:base-command]commands} --cov-config=.coveragercmpl --cov aws_encryption_sdk test/ -m local
# Verify that local tests work without environment variables present
[testenv:nocmk]
basepython = python3
sitepackages = False
#########################################################
# Do not pass through or set any environment variables! #
passenv =
setenv =
#########################################################
deps = -rdev_requirements/test-requirements.txt
commands = {[testenv:base-command]commands} test/ -m local --ignore test/mpl/
# Collect requirements for use in upstream tests
[testenv:freeze-upstream-requirements-base]
sitepackages = False
skip_install = True
recreate = True
deps =
commands = {toxinidir}/test/freeze-upstream-requirements.sh
# Freeze for Python 3.11
[testenv:freeze-upstream-requirements-py311]
basepython = python3.11
sitepackages = {[testenv:freeze-upstream-requirements-base]sitepackages}
skip_install = {[testenv:freeze-upstream-requirements-base]skip_install}
recreate = {[testenv:freeze-upstream-requirements-base]recreate}
deps = {[testenv:freeze-upstream-requirements-base]deps}
commands = {[testenv:freeze-upstream-requirements-base]commands} test/upstream-requirements-py311.txt
# Test frozen upstream requirements
[testenv:test-upstream-requirements-base]
sitepackages = False
recreate = True
commands = {[testenv:base-command]commands} test/ -m local --ignore test/mpl/
# Test frozen upstream requirements for Python 3.11
[testenv:test-upstream-requirements-py311]
basepython = python3.11
deps = -rtest/upstream-requirements-py311.txt
sitepackages = {[testenv:test-upstream-requirements-base]sitepackages}
recreate = {[testenv:test-upstream-requirements-base]recreate}
commands = {[testenv:test-upstream-requirements-base]commands}
# Linters
[testenv:flake8]
basepython = python3
deps = -rdev_requirements/linter-requirements.txt
commands =
flake8 src/aws_encryption_sdk/ setup.py
[testenv:flake8-tests]
basepython = {[testenv:flake8]basepython}
deps = -rdev_requirements/linter-requirements.txt
commands =
flake8 \
# Ignore F811 redefinition errors in tests (breaks with pytest-mock use)
# E203 is not PEP8 compliant https://github.com/ambv/black#slices
# W503 is not PEP8 compliant https://github.com/ambv/black#line-breaks--binary-operators
--ignore F811,E203,W503,D \
test/
[testenv:flake8-examples]
basepython = {[testenv:flake8]basepython}
deps = {[testenv:flake8]deps}
commands =
flake8 examples/src/
flake8 \
# Ignore D103 missing docstring errors in tests (test names should be self-documenting)
# E203 is not PEP8 compliant https://github.com/ambv/black#slices
# W503 is not PEP8 compliant https://github.com/ambv/black#line-breaks--binary-operators
--ignore D103,E203,W503 \
# copy-paste test for v3_default_cmm; intentionally not changing code
--per-file-ignores 'examples/test/legacy/v3_default_cmm.py: D205,D400,D401' \
examples/test/
[testenv:pylint]
basepython = python3
deps =
{[testenv]deps}
-rdev_requirements/linter-requirements.txt
commands =
pylint \
--rcfile=src/pylintrc \
--max-module-lines=1500 \
src/aws_encryption_sdk/ \
setup.py
--ignore-paths=src/aws_encryption_sdk/internal/mpl/
[testenv:pylint-examples]
basepython = {[testenv:pylint]basepython}
deps = {[testenv:pylint]deps}
commands =
pylint --rcfile=examples/src/pylintrc examples/src/
pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/
[testenv:pylint-tests]
basepython = {[testenv:pylint]basepython}
deps = {[testenv:pylint]deps}
commands =
pylint \
--rcfile=test/pylintrc \
test/unit/ \
test/functional/ \
test/integration/
[testenv:blacken-src]
basepython = python3
deps = -rdev_requirements/linter-requirements.txt
commands =
black --line-length 120 \
src/aws_encryption_sdk/ \
setup.py \
doc/conf.py \
test/ \
examples/ \
{posargs}
[testenv:blacken]
basepython = python3
deps =
{[testenv:blacken-src]deps}
commands =
{[testenv:blacken-src]commands}
[testenv:black-check]
basepython = python3
deps =
{[testenv:blacken]deps}
commands =
{[testenv:blacken-src]commands} --diff
[testenv:isort-seed]
basepython = python3
deps = -rdev_requirements/linter-requirements.txt
commands = seed-isort-config
[testenv:isort]
basepython = python3
deps = -rdev_requirements/linter-requirements.txt
commands = isort -rc \
src \
test \
# We do not include examples/test because of the need to modify sys.path for some imports
examples/src/ \
doc \
setup.py \
{posargs}
[testenv:isort-check]
basepython = python3
deps = {[testenv:isort]deps}
commands = {[testenv:isort]commands} -c
[testenv:autoformat]
basepython = python3
deps =
{[testenv:blacken]deps}
{[testenv:isort]deps}
commands =
{[testenv:blacken]commands}
{[testenv:isort]commands}
[testenv:doc8]
basepython = python3
deps =
-rdev_requirements/linter-requirements.txt
-rdev_requirements/doc-requirements.txt
commands = doc8 doc/index.rst README.rst CHANGELOG.rst
[testenv:readme]
basepython = python3
deps = -rdev_requirements/linter-requirements.txt
commands = python setup.py check -r -s
[testenv:bandit]
basepython = python3
deps = -rdev_requirements/linter-requirements.txt
commands = bandit -r src/aws_encryption_sdk/
# Prone to false positives: only run independently
[testenv:vulture]
basepython = python3
deps = -rdev_requirements/linter-requirements.txt
commands = vulture src/aws_encryption_sdk/
[testenv:linters]
basepython = python3
deps =
{[testenv:flake8]deps}
{[testenv:pylint]deps}
{[testenv:doc8]deps}
{[testenv:readme]deps}
{[testenv:bandit]deps}
commands =
{[testenv:flake8]commands}
{[testenv:pylint]commands}
{[testenv:doc8]commands}
{[testenv:readme]commands}
{[testenv:bandit]commands}
[testenv:linters-tests]
basepython = python3
deps =
{[testenv:flake8-tests]deps}
{[testenv:pylint-tests]deps}
commands =
{[testenv:flake8-tests]commands}
{[testenv:pylint-tests]commands}
[testenv:linters-examples]
basepython = python3
deps =
{[testenv:flake8-examples]deps}
{[testenv:pylint-examples]deps}
commands =
{[testenv:flake8-examples]commands}
{[testenv:pylint-examples]commands}
# Documentation
[testenv:docs]
basepython = python3
deps = -rdev_requirements/doc-requirements.txt
commands =
sphinx-build -E -c doc/ -b html doc/ doc/build/html
[testenv:serve-docs]
basepython = python3
skip_install = true
changedir = doc/build/html
deps =
commands =
python -m http.server {posargs}
# Release tooling
[testenv:park]
basepython = python3
skip_install = true
deps = -rdev_requirements/release-requirements.txt
commands = python setup.py park
[testenv:build]
basepython = python3
skip_install = true
deps = -rdev_requirements/release-requirements.txt
commands =
python setup.py sdist bdist_wheel
[testenv:release-base]
basepython = python3
skip_install = true
deps = -rdev_requirements/release-requirements.txt
passenv =
# Intentionally omit TWINE_REPOSITORY_URL from the passenv list,
# as this overrides other ways of setting the repository and could
# unexpectedly result in releasing to the wrong repo
{[testenv]passenv} \
TWINE_USERNAME \
TWINE_PASSWORD
commands =
{[testenv:build]commands}
[testenv:release-private]
basepython = python3
skip_install = true
deps = {[testenv:release-base]deps}
passenv =
{[testenv:release-base]passenv} \
TWINE_REPOSITORY_URL
setenv =
# Explicitly set the URL as the env variable value, which will cause us to
# throw an error if the variable is not set. Otherwise, omission of the
# env variable could cause us to unintentionally upload to the wrong repo
TWINE_REPOSITORY_URL = {env:TWINE_REPOSITORY_URL}
commands =
{[testenv:release-base]commands}
# Omitting an explicit repository will cause twine to use the repository
# specified in the environment variable
twine upload --skip-existing {toxinidir}/dist/*
[testenv:test-release]
basepython = python3
skip_install = true
deps = {[testenv:release-base]deps}
passenv =
{[testenv:release-base]passenv}
commands =
{[testenv:release-base]commands}
twine upload --skip-existing --repository testpypi {toxinidir}/dist/*
[testenv:release]
basepython = python3
skip_install = true
deps = {[testenv:release-base]deps}
passenv =
{[testenv:release-base]passenv}
commands =
{[testenv:release-base]commands}
twine upload --skip-existing --repository pypi {toxinidir}/dist/*