Skip to content

Commit 27bb2c0

Browse files
authored
chore: fix all CI and start migration to GitHub Actions (#139)
* chore: force tox to update pip * chore: update isort configuration to 5.0.0 * chore: autoformat * chore: hypothesis.HealthCheck.hung_test is deprecated * chore: flake8 linting * chore: update pylint and flake8 configs * chore: linting fixes * chore: update default Python envlist - remove 3.4 - add 3.8 * chore: Python 2 lists do not have copy() * chore: address all pylint issues aside from TODO references * chore: unlock mypy version * chore: fix type annotation syntax errors * chore: move TODOs into GitHub issues * chore: move test TODOs to GitHub issues * chore: autoformat * chore: rework moto use - fixes issues with multiple service mocks in Python 2 - module scope avoids resetting the mocked service for tests that use multiple mocked tables * chore: force nocmk environment to black all environment variables * chore: add GitHub Actions workflows * chore: move sourcebuildcheck and nocmk into upstream-py3 job * chore: add ci-requirements.txt * chore: work around bug in Python 2 Hypothesis behavior by only running fast tests for Python 2 * chore: fix sourcebuildcheck script - The ls command was getting a relative path when the script ran but a bare filename in manual checks. * chore: pruning known runs from Travis that fail due to known infrastructure issues
1 parent 1d24752 commit 27bb2c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+473
-224
lines changed
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow runs static analysis checks on pull requests.
2+
name: static analysis
3+
4+
on:
5+
pull_request:
6+
push:
7+
# Run once a day
8+
schedule:
9+
- cron: '0 0 * * *'
10+
11+
jobs:
12+
analysis:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
category:
18+
# Disabled pending completion of integration
19+
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
20+
# - mypy-py2
21+
# - mypy-py3
22+
- bandit
23+
- doc8
24+
- readme
25+
- docs
26+
- flake8
27+
- pylint
28+
- flake8-tests
29+
- flake8-examples
30+
- pylint-tests
31+
- pylint-examples
32+
- black-check
33+
steps:
34+
- uses: actions/checkout@v2
35+
- uses: actions/setup-python@v1
36+
with:
37+
python-version: 3.x
38+
- run: |
39+
python -m pip install --upgrade pip
40+
pip install --upgrade -r ci-requirements.txt
41+
- name: check
42+
env:
43+
TOXENV: ${{ matrix.category }}
44+
run: tox -- -vv

.github/workflows/ci_tests.yaml

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# This workflow runs tests on pull requests.
2+
name: tests
3+
4+
on:
5+
pull_request:
6+
push:
7+
# Run once a day
8+
schedule:
9+
- cron: '0 0 * * *'
10+
11+
jobs:
12+
# Hypothesis no longer supports Python 2 and
13+
# there is a bug that appears with our slow tests
14+
# only on Python 2.
15+
# Until we also drop Python 2 support,
16+
# the workaround is just that we don't run the slow tests
17+
# on Python 2.
18+
py2-tests:
19+
runs-on: ${{ matrix.platform.os }}
20+
strategy:
21+
fail-fast: true
22+
matrix:
23+
platform:
24+
- os: ubuntu-latest
25+
architecture: x64
26+
- os: windows-latest
27+
architecture: x64
28+
# x86 builds are only meaningful for Windows
29+
- os: windows-latest
30+
architecture: x86
31+
- os: macos-latest
32+
architecture: x64
33+
category:
34+
- local-fast
35+
# These require credentials.
36+
# Enable them once we sort how to provide them.
37+
# - integ-fast
38+
# - examples
39+
steps:
40+
- uses: actions/checkout@v2
41+
- uses: actions/setup-python@v1
42+
with:
43+
python-version: 2.7
44+
architecture: ${{ matrix.platform.architecture }}
45+
- run: |
46+
python -m pip install --upgrade pip
47+
pip install --upgrade -r ci-requirements.txt
48+
- name: run test
49+
env:
50+
TOXENV: ${{ matrix.category }}
51+
run: tox -- -vv
52+
tests:
53+
runs-on: ${{ matrix.platform.os }}
54+
strategy:
55+
fail-fast: true
56+
matrix:
57+
platform:
58+
- os: ubuntu-latest
59+
architecture: x64
60+
- os: windows-latest
61+
architecture: x64
62+
# x86 builds are only meaningful for Windows
63+
- os: windows-latest
64+
architecture: x86
65+
- os: macos-latest
66+
architecture: x64
67+
python:
68+
- 3.5
69+
- 3.6
70+
- 3.7
71+
- 3.8
72+
- 3.x
73+
category:
74+
- local-slow
75+
# These require credentials.
76+
# Enable them once we sort how to provide them.
77+
# - integ-slow
78+
# - examples
79+
steps:
80+
- uses: actions/checkout@v2
81+
- uses: actions/setup-python@v1
82+
with:
83+
python-version: ${{ matrix.python }}
84+
architecture: ${{ matrix.platform.architecture }}
85+
- run: |
86+
python -m pip install --upgrade pip
87+
pip install --upgrade -r ci-requirements.txt
88+
- name: run test
89+
env:
90+
TOXENV: ${{ matrix.category }}
91+
run: tox -- -vv
92+
upstream-py3:
93+
runs-on: ubuntu-latest
94+
strategy:
95+
fail-fast: true
96+
matrix:
97+
category:
98+
- nocmk
99+
- sourcebuildcheck
100+
- test-upstream-requirements-py37
101+
steps:
102+
- uses: actions/checkout@v2
103+
- uses: actions/setup-python@v1
104+
with:
105+
python-version: 3.7
106+
- run: |
107+
python -m pip install --upgrade pip
108+
pip install --upgrade -r ci-requirements.txt
109+
- name: run test
110+
env:
111+
TOXENV: ${{ matrix.category }}
112+
run: tox -- -vv
113+
upstream-py2:
114+
runs-on: ubuntu-latest
115+
strategy:
116+
fail-fast: true
117+
matrix:
118+
category:
119+
- test-upstream-requirements-py27
120+
steps:
121+
- uses: actions/checkout@v2
122+
- uses: actions/setup-python@v1
123+
with:
124+
python-version: 2.7
125+
- run: |
126+
python -m pip install --upgrade pip
127+
pip install --upgrade -r ci-requirements.txt
128+
- name: run test
129+
env:
130+
TOXENV: ${{ matrix.category }}
131+
run: tox -- -vv

.travis.yml

+7-10
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@ sudo: false
22
language: python
33
matrix:
44
include:
5+
# Hypothesis no longer supports Python 2 and
6+
# there is a bug that appears with our slow tests
7+
# only on Python 2.
8+
# Until we also drop Python 2 support,
9+
# the workaround is just that we don't run the slow tests
10+
# on Python 2.
511
# CPython 2.7
612
- python: 2.7
7-
env: TOXENV=py27-travis-local-slow
13+
env: TOXENV=py27-travis-local-fast
814
- python: 2.7
915
env: TOXENV=py27-travis-integ-slow
10-
- python: 2.7
11-
env: TOXENV=py27-travis-isolation
12-
# CPython 3.4
13-
- python: 3.4
14-
env: TOXENV=py34-travis-local-slow
15-
- python: 3.4
16-
env: TOXENV=py34-travis-integ-slow
17-
- python: 3.4
18-
env: TOXENV=py34-travis-isolation
1916
# CPython 3.5
2017
- python: 3.5
2118
env: TOXENV=py35-travis-local-slow

ci-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tox

setup.cfg

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ log_level=DEBUG
3232

3333
# Flake8 Configuration
3434
[flake8]
35-
max_complexity = 10
35+
max_complexity = 11
3636
max_line_length = 120
3737
import_order_style = google
3838
application_import_names = dynamodb_encryption_sdk
@@ -61,6 +61,5 @@ multi_line_output = 3
6161
include_trailing_comma = True
6262
force_grid_wrap = 0
6363
combine_as_imports = True
64-
not_skip = __init__.py
6564
known_first_party = dynamodb_encryption_sdk
6665
known_third_party =attr,aws_kms_encrypted_client,aws_kms_encrypted_item,aws_kms_encrypted_resource,aws_kms_encrypted_table,boto3,botocore,cryptography,dynamodb_encryption_sdk,functional_test_utils,functional_test_vector_generators,hypothesis,hypothesis_strategies,integration_test_utils,mock,most_recent_provider_encrypted_table,moto,mypy_extensions,pytest,pytest_mock,setuptools,six,wrapped_rsa_encrypted_table,wrapped_symmetric_encrypted_table

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_version():
2323
def get_requirements():
2424
"""Reads the requirements file."""
2525
requirements = read("requirements.txt")
26-
return [r for r in requirements.strip().splitlines()]
26+
return requirements.strip().splitlines()
2727

2828

2929
setup(

src/dynamodb_encryption_sdk/encrypted/client.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def __getattr__(self, name):
9696

9797
def paginate(self, **kwargs):
9898
# type: (**Any) -> Iterator[Dict]
99-
# TODO: narrow this down
99+
# narrow this down
100+
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
100101
"""Create an iterator that will paginate through responses from the underlying paginator,
101102
transparently decrypting any returned items.
102103
"""

src/dynamodb_encryption_sdk/encrypted/item.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def decrypt_dynamodb_item(item, crypto_config):
171171
:rtype: dict
172172
"""
173173
unique_actions = set([crypto_config.attribute_actions.default_action.name])
174-
unique_actions.update(set([action.name for action in crypto_config.attribute_actions.attribute_actions.values()]))
174+
unique_actions.update({action.name for action in crypto_config.attribute_actions.attribute_actions.values()})
175175

176176
if crypto_config.attribute_actions.take_no_actions:
177177
# If we explicitly have been told not to do anything to this item, just copy it.

src/dynamodb_encryption_sdk/encrypted/resource.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
@attr.s(init=False)
4343
class EncryptedTablesCollectionManager(object):
44-
# pylint: disable=too-few-public-methods
44+
# pylint: disable=too-few-public-methods,too-many-instance-attributes
4545
"""Tables collection manager that provides :class:`EncryptedTable` objects.
4646
4747
https://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.ServiceResource.tables
@@ -119,7 +119,7 @@ def _transform_table(self, method, **kwargs):
119119

120120
@attr.s(init=False)
121121
class EncryptedResource(object):
122-
# pylint: disable=too-few-public-methods
122+
# pylint: disable=too-few-public-methods,too-many-instance-attributes
123123
"""High-level helper class to provide a familiar interface to encrypted tables.
124124
125125
>>> import boto3

src/dynamodb_encryption_sdk/encrypted/table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
@attr.s(init=False)
4444
class EncryptedTable(object):
45-
# pylint: disable=too-few-public-methods
45+
# pylint: disable=too-few-public-methods,too-many-instance-attributes
4646
"""High-level helper class to provide a familiar interface to encrypted tables.
4747
4848
>>> import boto3

src/dynamodb_encryption_sdk/identifiers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def __gt__(self, other):
3535
def __lt__(self, other):
3636
# type: (CryptoAction) -> bool
3737
"""Define CryptoAction equality."""
38-
return self.value < other.value
38+
return self.value < other.value # pylint: disable=comparison-with-callable
3939

4040
def __eq__(self, other):
4141
# type: (CryptoAction) -> bool
4242
"""Define CryptoAction equality."""
43-
return self.value == other.value
43+
return self.value == other.value # pylint: disable=comparison-with-callable
4444

4545

4646
class EncryptionKeyType(Enum):

src/dynamodb_encryption_sdk/internal/crypto/authentication.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
3030
from typing import Text # noqa pylint: disable=unused-import
31+
3132
from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import
3233
except ImportError: # pragma: no cover
3334
# We only actually need these imports when running the mypy checks
@@ -55,7 +56,8 @@ def sign_item(encrypted_item, signing_key, crypto_config):
5556
attribute_actions=crypto_config.attribute_actions,
5657
),
5758
)
58-
return {Tag.BINARY.dynamodb_tag: signature}
59+
# for some reason pylint can't follow the Enum member attributes
60+
return {Tag.BINARY.dynamodb_tag: signature} # pylint: disable=no-member
5961

6062

6163
def verify_item_signature(signature_attribute, encrypted_item, verification_key, crypto_config):
@@ -67,7 +69,8 @@ def verify_item_signature(signature_attribute, encrypted_item, verification_key,
6769
:param DelegatedKey verification_key: DelegatedKey to use to calculate the signature
6870
:param CryptoConfig crypto_config: Cryptographic configuration
6971
"""
70-
signature = signature_attribute[Tag.BINARY.dynamodb_tag]
72+
# for some reason pylint can't follow the Enum member attributes
73+
signature = signature_attribute[Tag.BINARY.dynamodb_tag] # pylint: disable=no-member
7174
verification_key.verify(
7275
algorithm=verification_key.algorithm,
7376
signature=signature,
@@ -97,10 +100,11 @@ def _string_to_sign(item, table_name, attribute_actions):
97100

98101
data_to_sign.extend(_hash_data(hasher=hasher, data=key.encode(TEXT_ENCODING)))
99102

103+
# for some reason pylint can't follow the Enum member attributes
100104
if action is CryptoAction.SIGN_ONLY:
101-
data_to_sign.extend(SignatureValues.PLAINTEXT.sha256)
105+
data_to_sign.extend(SignatureValues.PLAINTEXT.sha256) # pylint: disable=no-member
102106
else:
103-
data_to_sign.extend(SignatureValues.ENCRYPTED.sha256)
107+
data_to_sign.extend(SignatureValues.ENCRYPTED.sha256) # pylint: disable=no-member
104108

105109
data_to_sign.extend(_hash_data(hasher=hasher, data=serialize_attribute(item[key])))
106110
return bytes(data_to_sign)

src/dynamodb_encryption_sdk/internal/crypto/encryption.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""
1919
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
2020
from typing import Text # noqa pylint: disable=unused-import
21+
2122
from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import
2223
except ImportError: # pragma: no cover
2324
# We only actually need these imports when running the mypy checks
@@ -46,7 +47,8 @@ def encrypt_attribute(attribute_name, attribute, encryption_key, algorithm):
4647
encrypted_attribute = encryption_key.encrypt(
4748
algorithm=algorithm, name=attribute_name, plaintext=serialized_attribute
4849
)
49-
return {Tag.BINARY.dynamodb_tag: encrypted_attribute}
50+
# for some reason pylint can't follow the Enum member attributes
51+
return {Tag.BINARY.dynamodb_tag: encrypted_attribute} # pylint: disable=no-member
5052

5153

5254
def decrypt_attribute(attribute_name, attribute, decryption_key, algorithm):
@@ -60,7 +62,8 @@ def decrypt_attribute(attribute_name, attribute, decryption_key, algorithm):
6062
:returns: Plaintext DynamoDB attribute
6163
:rtype: dict
6264
"""
63-
encrypted_attribute = attribute[Tag.BINARY.dynamodb_tag]
65+
# for some reason pylint can't follow the Enum member attributes
66+
encrypted_attribute = attribute[Tag.BINARY.dynamodb_tag] # pylint: disable=no-member
6467
decrypted_attribute = decryption_key.decrypt(
6568
algorithm=algorithm, name=attribute_name, ciphertext=encrypted_attribute
6669
)

0 commit comments

Comments
 (0)