Skip to content

Commit a67e80d

Browse files
committed
fix tests in ci tox
1 parent 5299290 commit a67e80d

File tree

5 files changed

+236
-34
lines changed

5 files changed

+236
-34
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Runs the performance tests for the MPL in an environment with the MPL installed
2+
version: 0.2
3+
4+
env:
5+
variables:
6+
# No TOXENV. This runs multiple environments.
7+
REGION: "us-west-2"
8+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
9+
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
10+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
11+
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
12+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
13+
arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
14+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >-
15+
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
16+
17+
phases:
18+
install:
19+
runtime-versions:
20+
python: 3.11
21+
build:
22+
commands:
23+
- cd /root/.pyenv/plugins/python-build/../.. && git pull && cd -
24+
- pyenv install --skip-existing 3.11.0
25+
- pyenv local 3.11.0
26+
- pip install --upgrade pip
27+
- pip install setuptools
28+
- pip install "tox < 4.0"
29+
# Assume special role to access keystore
30+
- TMP_ROLE=$(aws sts assume-role --role-arn "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2" --role-session-name "CB-Py312ExamplesMpl")
31+
- export TMP_ROLE
32+
- export AWS_ACCESS_KEY_ID=$(echo "${TMP_ROLE}" | jq -r '.Credentials.AccessKeyId')
33+
- export AWS_SECRET_ACCESS_KEY=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SecretAccessKey')
34+
- export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken')
35+
- aws sts get-caller-identity
36+
# Run MPL-specific tests with special role
37+
- cd performance_tests/
38+
- tox

codebuild/py312/performance_tests_mpl.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ phases:
3434
- export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken')
3535
- aws sts get-caller-identity
3636
# Run MPL-specific tests with special role
37-
- tox -e py312-mplperformancetests-mpl
37+
- cd performance_tests/
38+
- tox
File renamed without changes.

performance_tests/tox.ini

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
[tox]
2+
envlist =
3+
# The performance tests only work for python 3.11 and 3.12
4+
py{311,312}-performance_tests-mpl
5+
bandit, readme
6+
# TODO: Activate doc8 after finalizing README.rst
7+
; bandit, doc8, readme
8+
9+
# Additional test environments:
10+
#
11+
# linters :: Runs all linters over all source code.
12+
# linters-tests :: Runs all linters over all tests.
13+
14+
# Autoformatter helper environments:
15+
#
16+
# autoformat : Apply all autoformatters
17+
#
18+
# black-check : Check for "black" issues
19+
# blacken : Fix all "black" issues
20+
#
21+
# isort-seed : Generate a known_third_party list for isort.
22+
# NOTE: make the "known_third_party = " line in setup.cfg before running this
23+
# NOTE: currently it incorrectly identifies this library too; make sure you remove it
24+
# isort-check : Check for isort issues
25+
# isort : Fix isort issues
26+
27+
# Operational helper environments:
28+
#
29+
# build :: Builds source and wheel dist files.
30+
# test-release :: Builds dist files and uploads to testpypi pypirc profile.
31+
# release :: Builds dist files and uploads to pypi pypirc profile.
32+
33+
[testenv:base-command]
34+
commands = pytest test/
35+
deps =
36+
click
37+
38+
39+
[testenv]
40+
passenv =
41+
# Pass through AWS credentials
42+
AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN \
43+
# AWS Role access in CodeBuild is via the contaner URI
44+
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI \
45+
# Pass through AWS profile name (useful for local testing)
46+
AWS_PROFILE
47+
sitepackages = False
48+
deps =
49+
-rrequirements.txt
50+
# Install the MPL requirements if the `-mpl` suffix is present
51+
mpl: -rrequirements_mpl.txt
52+
..
53+
commands =
54+
# awses_local: {[testenv:base-command]commands}
55+
performance_tests: {[testenv:base-command]commands}
56+
57+
# mypy
58+
[testenv:mypy-coverage]
59+
commands =
60+
# Make mypy linecoverage report readable by coverage
61+
python -c \
62+
"t = open('.coverage', 'w');\
63+
c = open('build/coverage.json').read();\
64+
t.write('!coverage.py: This is a private format, don\'t read it directly!\n');\
65+
t.write(c);\
66+
t.close()"
67+
coverage report -m
68+
69+
[testenv:mypy-common]
70+
basepython = python3
71+
deps =
72+
coverage
73+
mypy>=0.600
74+
mypy_extensions
75+
typing>=3.6.2
76+
77+
[testenv:mypy-py3]
78+
basepython = {[testenv:mypy-common]basepython}
79+
deps = {[testenv:mypy-common]deps}
80+
commands =
81+
python -m mypy \
82+
--linecoverage-report build \
83+
src/aws_encryption_sdk_performance_tests/ \
84+
{posargs}
85+
{[testenv:mypy-coverage]commands}
86+
87+
[testenv:blacken-src]
88+
basepython = python3
89+
deps = -r../dev_requirements/linter-requirements.txt
90+
commands =
91+
black --line-length 120 \
92+
src/aws_encryption_sdk_performance_tests/ \
93+
setup.py \
94+
test/ \
95+
{posargs}
96+
97+
98+
[testenv:blacken]
99+
basepython = python3
100+
deps =
101+
{[testenv:blacken-src]deps}
102+
commands =
103+
{[testenv:blacken-src]commands}
104+
105+
[testenv:black-check]
106+
basepython = python3
107+
deps =
108+
{[testenv:blacken]deps}
109+
commands =
110+
{[testenv:blacken-src]commands} --diff
111+
112+
[testenv:isort-seed]
113+
basepython = python3
114+
deps = -r../dev_requirements/linter-requirements.txt
115+
commands = seed-isort-config
116+
117+
[testenv:isort]
118+
basepython = python3
119+
deps = -r../dev_requirements/linter-requirements.txt
120+
commands = isort -rc \
121+
src \
122+
test \
123+
setup.py \
124+
{posargs}
125+
126+
[testenv:isort-check]
127+
basepython = python3
128+
deps = {[testenv:isort]deps}
129+
commands = {[testenv:isort]commands} -c
130+
131+
[testenv:autoformat]
132+
basepython = python3
133+
deps =
134+
{[testenv:blacken]deps}
135+
{[testenv:isort]deps}
136+
..
137+
commands =
138+
{[testenv:blacken]commands}
139+
{[testenv:isort]commands}
140+
141+
[testenv:doc8]
142+
basepython = python3
143+
deps = -r../dev_requirements/linter-requirements.txt
144+
commands = doc8 README.rst
145+
146+
[testenv:bandit]
147+
basepython = python3
148+
deps = -r../dev_requirements/linter-requirements.txt
149+
commands = bandit -r src/aws_encryption_sdk_performance_tests/
150+
151+
[testenv:linters]
152+
basepython = python3
153+
deps =
154+
{[testenv:doc8]deps}
155+
{[testenv:bandit]deps}
156+
commands =
157+
{[testenv:doc8]commands}
158+
{[testenv:bandit]commands}
159+
160+
# Release tooling
161+
[testenv:park]
162+
basepython = python3
163+
skip_install = true
164+
deps = -r../dev_requirements/release-requirements.txt
165+
commands = python setup.py park
166+
167+
[testenv:build]
168+
basepython = python3
169+
skip_install = true
170+
deps =
171+
-r../dev_requirements/release-requirements.txt
172+
commands =
173+
python setup.py sdist bdist_wheel
174+
175+
[testenv:test-release]
176+
basepython = python3
177+
skip_install = true
178+
deps =
179+
{[testenv:build]deps}
180+
twine
181+
commands =
182+
{[testenv:build]commands}
183+
twine upload --skip-existing --repository testpypi dist/*
184+
185+
[testenv:release]
186+
basepython = python3
187+
skip_install = true
188+
deps =
189+
{[testenv:build]deps}
190+
twine
191+
commands =
192+
{[testenv:build]commands}
193+
twine upload --skip-existing --repository pypi dist/*

tox.ini

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
envlist =
33
# <3.11: run all non-MPL tests
4-
py{37,38,39,310}-{local,integ,accept,examples},
4+
py{38,39,310}-{local,integ,accept,examples},
55
# >=3.11: run all tests with MPL installed and without MPL installed
66
# The `-mpl` suffix tells tox to install the MPL.
77
# In the case where the suffix IS NOT appended,
@@ -17,10 +17,10 @@ envlist =
1717
# The `mpl` prefix specifies a separate target,
1818
# i.e. `mpllocal` instead of `local`.
1919
# `mplXXX` contains tests using MPL components.
20-
py{311,312}-mpl{local,examples,performancetests}-mpl
20+
py{311,312}-mpl{local,examples}-mpl
2121
nocmk,
2222
bandit, doc8, readme, docs,
23-
{flake8,pylint}{,-tests,-examples,-performancetests},
23+
{flake8,pylint}{,-tests,-examples},
2424
isort-check, black-check,
2525
# prone to false positives
2626
vulture
@@ -92,7 +92,6 @@ commands =
9292
examples: {[testenv:base-command]commands} examples/test/legacy/ -m examples
9393
# MPL keyring examples require a special IAM role; run these separately under a separate set of permissions
9494
mplexamples: {[testenv:base-command]commands} examples/test/ -m examples --ignore examples/test/legacy/
95-
performancetests: {[testenv:base-command]commands} performance_tests/test/ -m examples
9695
all: {[testenv:base-command]commands} test/ examples/test/legacy/ --ignore test/mpl/
9796
mplall: {[testenv:base-command]commands} test/ examples/test/
9897
manual: {[testenv:base-command]commands}
@@ -176,18 +175,6 @@ commands =
176175
--ignore D103,E203,W503 \
177176
examples/test/
178177

179-
[testenv:flake8-performancetests]
180-
basepython = {[testenv:flake8]basepython}
181-
deps = {[testenv:flake8]deps}
182-
commands =
183-
flake8 performance_tests/src/
184-
flake8 \
185-
# Ingore D103 missing docstring errors in tests (test names should be self-documenting)
186-
# E203 is not PEP8 compliant https://github.com/ambv/black#slices
187-
# W503 is not PEP8 compliant https://github.com/ambv/black#line-breaks--binary-operators
188-
--ignore D103,E203,W503 \
189-
performance_tests/test/
190-
191178
[testenv:pylint]
192179
basepython = python3
193180
deps =
@@ -208,13 +195,6 @@ commands =
208195
pylint --rcfile=examples/src/pylintrc examples/src/
209196
pylint --rcfile=examples/test/pylintrc --disable R0801 examples/test/
210197

211-
[testenv:pylint-performancetests]
212-
basepython = {[testenv:pylint]basepython}
213-
deps = {[testenv:pylint]deps}
214-
commands =
215-
pylint --rcfile=performance_tests/pylintrc performance_tests/src/
216-
pylint --rcfile=performance_tests/pylintrc --disable R0801 performance_tests/test/
217-
218198
[testenv:pylint-tests]
219199
basepython = {[testenv:pylint]basepython}
220200
deps = {[testenv:pylint]deps}
@@ -235,7 +215,6 @@ commands =
235215
doc/conf.py \
236216
test/ \
237217
examples/ \
238-
performance_tests/ \
239218
{posargs}
240219

241220

@@ -340,15 +319,6 @@ commands =
340319
{[testenv:flake8-examples]commands}
341320
{[testenv:pylint-examples]commands}
342321

343-
[testenv:linters-performance-tests]
344-
basepython = python3
345-
deps =
346-
{[testenv:flake8-performancetests]deps}
347-
{[testenv:pylint-performancetests]deps}
348-
commands =
349-
{[testenv:flake8-performancetests]commands}
350-
{[testenv:pylint-performancetests]commands}
351-
352322
# Documentation
353323
[testenv:docs]
354324
basepython = python3

0 commit comments

Comments
 (0)