Skip to content

chore: fix all CI and start migration to GitHub Actions #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cef1a0c
chore: force tox to update pip
mattsb42-aws Jun 12, 2020
308dbe3
chore: update isort configuration to 5.0.0
mattsb42-aws Aug 21, 2020
3b74a11
chore: autoformat
mattsb42-aws Aug 21, 2020
2fabdc7
chore: hypothesis.HealthCheck.hung_test is deprecated
mattsb42-aws Aug 21, 2020
9338567
chore: flake8 linting
mattsb42-aws Aug 21, 2020
e2733e2
chore: update pylint and flake8 configs
mattsb42-aws Aug 21, 2020
a21d2f5
chore: linting fixes
mattsb42-aws Aug 21, 2020
fdda119
chore: update default Python envlist
mattsb42-aws Aug 21, 2020
f6b2a4e
chore: Python 2 lists do not have copy()
mattsb42-aws Aug 24, 2020
cf92374
chore: address all pylint issues aside from TODO references
mattsb42-aws Aug 24, 2020
2f1bdab
chore: unlock mypy version
mattsb42-aws Aug 24, 2020
0fa073e
chore: fix type annotation syntax errors
mattsb42-aws Aug 24, 2020
c9015f3
chore: move TODOs into GitHub issues
mattsb42-aws Aug 24, 2020
25e2502
chore: move test TODOs to GitHub issues
mattsb42-aws Aug 24, 2020
f122f59
chore: autoformat
mattsb42-aws Aug 25, 2020
aa24b33
chore: rework moto use
mattsb42-aws Aug 25, 2020
d4b128a
chore: force nocmk environment to black all environment variables
mattsb42-aws Aug 25, 2020
3f10f43
chore: add GitHub Actions workflows
mattsb42-aws Aug 25, 2020
72a38a7
chore: move sourcebuildcheck and nocmk into upstream-py3 job
mattsb42-aws Aug 25, 2020
824d38d
chore: add ci-requirements.txt
mattsb42-aws Aug 25, 2020
c00699e
chore: work around bug in Python 2 Hypothesis behavior by only runnin…
mattsb42-aws Aug 25, 2020
3c404b3
chore: fix sourcebuildcheck script
mattsb42-aws Aug 25, 2020
ceb0b5f
chore: pruning known runs from Travis that fail due to known infrastr…
mattsb42-aws Aug 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/ci_static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow runs static analysis checks on pull requests.
name: static analysis

on:
pull_request:
push:
# Run once a day
schedule:
- cron: '0 0 * * *'

jobs:
analysis:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
category:
# Disabled pending completion of integration
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
# - mypy-py2
# - mypy-py3
- bandit
- doc8
- readme
- docs
- flake8
- pylint
- flake8-tests
- flake8-examples
- pylint-tests
- pylint-examples
- black-check
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.x
- run: |
python -m pip install --upgrade pip
pip install --upgrade -r ci-requirements.txt
- name: check
env:
TOXENV: ${{ matrix.category }}
run: tox -- -vv
131 changes: 131 additions & 0 deletions .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# This workflow runs tests on pull requests.
name: tests

on:
pull_request:
push:
# Run once a day
schedule:
- cron: '0 0 * * *'

jobs:
# Hypothesis no longer supports Python 2 and
# there is a bug that appears with our slow tests
# only on Python 2.
# Until we also drop Python 2 support,
# the workaround is just that we don't run the slow tests
# on Python 2.
py2-tests:
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: true
matrix:
platform:
- os: ubuntu-latest
architecture: x64
- os: windows-latest
architecture: x64
# x86 builds are only meaningful for Windows
- os: windows-latest
architecture: x86
- os: macos-latest
architecture: x64
category:
- local-fast
# These require credentials.
# Enable them once we sort how to provide them.
# - integ-fast
# - examples
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 2.7
architecture: ${{ matrix.platform.architecture }}
- run: |
python -m pip install --upgrade pip
pip install --upgrade -r ci-requirements.txt
- name: run test
env:
TOXENV: ${{ matrix.category }}
run: tox -- -vv
tests:
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: true
matrix:
platform:
- os: ubuntu-latest
architecture: x64
- os: windows-latest
architecture: x64
# x86 builds are only meaningful for Windows
- os: windows-latest
architecture: x86
- os: macos-latest
architecture: x64
python:
- 3.5
- 3.6
- 3.7
- 3.8
- 3.x
category:
- local-slow
# These require credentials.
# Enable them once we sort how to provide them.
# - integ-slow
# - examples
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.platform.architecture }}
- run: |
python -m pip install --upgrade pip
pip install --upgrade -r ci-requirements.txt
- name: run test
env:
TOXENV: ${{ matrix.category }}
run: tox -- -vv
upstream-py3:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
category:
- nocmk
- sourcebuildcheck
- test-upstream-requirements-py37
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
- run: |
python -m pip install --upgrade pip
pip install --upgrade -r ci-requirements.txt
- name: run test
env:
TOXENV: ${{ matrix.category }}
run: tox -- -vv
upstream-py2:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
category:
- test-upstream-requirements-py27
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 2.7
- run: |
python -m pip install --upgrade pip
pip install --upgrade -r ci-requirements.txt
- name: run test
env:
TOXENV: ${{ matrix.category }}
run: tox -- -vv
17 changes: 7 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ sudo: false
language: python
matrix:
include:
# Hypothesis no longer supports Python 2 and
# there is a bug that appears with our slow tests
# only on Python 2.
# Until we also drop Python 2 support,
# the workaround is just that we don't run the slow tests
# on Python 2.
# CPython 2.7
- python: 2.7
env: TOXENV=py27-travis-local-slow
env: TOXENV=py27-travis-local-fast
- python: 2.7
env: TOXENV=py27-travis-integ-slow
- python: 2.7
env: TOXENV=py27-travis-isolation
# CPython 3.4
- python: 3.4
env: TOXENV=py34-travis-local-slow
- python: 3.4
env: TOXENV=py34-travis-integ-slow
- python: 3.4
env: TOXENV=py34-travis-isolation
# CPython 3.5
- python: 3.5
env: TOXENV=py35-travis-local-slow
Expand Down
1 change: 1 addition & 0 deletions ci-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tox
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ log_level=DEBUG

# Flake8 Configuration
[flake8]
max_complexity = 10
max_complexity = 11
max_line_length = 120
import_order_style = google
application_import_names = dynamodb_encryption_sdk
Expand Down Expand Up @@ -61,6 +61,5 @@ multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
combine_as_imports = True
not_skip = __init__.py
known_first_party = dynamodb_encryption_sdk
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_version():
def get_requirements():
"""Reads the requirements file."""
requirements = read("requirements.txt")
return [r for r in requirements.strip().splitlines()]
return requirements.strip().splitlines()


setup(
Expand Down
3 changes: 2 additions & 1 deletion src/dynamodb_encryption_sdk/encrypted/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def __getattr__(self, name):

def paginate(self, **kwargs):
# type: (**Any) -> Iterator[Dict]
# TODO: narrow this down
# narrow this down
# https://github.com/aws/aws-dynamodb-encryption-python/issues/66
"""Create an iterator that will paginate through responses from the underlying paginator,
transparently decrypting any returned items.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/dynamodb_encryption_sdk/encrypted/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def decrypt_dynamodb_item(item, crypto_config):
:rtype: dict
"""
unique_actions = set([crypto_config.attribute_actions.default_action.name])
unique_actions.update(set([action.name for action in crypto_config.attribute_actions.attribute_actions.values()]))
unique_actions.update({action.name for action in crypto_config.attribute_actions.attribute_actions.values()})

if crypto_config.attribute_actions.take_no_actions:
# If we explicitly have been told not to do anything to this item, just copy it.
Expand Down
4 changes: 2 additions & 2 deletions src/dynamodb_encryption_sdk/encrypted/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

@attr.s(init=False)
class EncryptedTablesCollectionManager(object):
# pylint: disable=too-few-public-methods
# pylint: disable=too-few-public-methods,too-many-instance-attributes
"""Tables collection manager that provides :class:`EncryptedTable` objects.

https://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.ServiceResource.tables
Expand Down Expand Up @@ -119,7 +119,7 @@ def _transform_table(self, method, **kwargs):

@attr.s(init=False)
class EncryptedResource(object):
# pylint: disable=too-few-public-methods
# pylint: disable=too-few-public-methods,too-many-instance-attributes
"""High-level helper class to provide a familiar interface to encrypted tables.

>>> import boto3
Expand Down
2 changes: 1 addition & 1 deletion src/dynamodb_encryption_sdk/encrypted/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

@attr.s(init=False)
class EncryptedTable(object):
# pylint: disable=too-few-public-methods
# pylint: disable=too-few-public-methods,too-many-instance-attributes
"""High-level helper class to provide a familiar interface to encrypted tables.

>>> import boto3
Expand Down
4 changes: 2 additions & 2 deletions src/dynamodb_encryption_sdk/identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def __gt__(self, other):
def __lt__(self, other):
# type: (CryptoAction) -> bool
"""Define CryptoAction equality."""
return self.value < other.value
return self.value < other.value # pylint: disable=comparison-with-callable

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


class EncryptionKeyType(Enum):
Expand Down
12 changes: 8 additions & 4 deletions src/dynamodb_encryption_sdk/internal/crypto/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
from typing import Text # noqa pylint: disable=unused-import

from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import
except ImportError: # pragma: no cover
# We only actually need these imports when running the mypy checks
Expand Down Expand Up @@ -55,7 +56,8 @@ def sign_item(encrypted_item, signing_key, crypto_config):
attribute_actions=crypto_config.attribute_actions,
),
)
return {Tag.BINARY.dynamodb_tag: signature}
# for some reason pylint can't follow the Enum member attributes
return {Tag.BINARY.dynamodb_tag: signature} # pylint: disable=no-member


def verify_item_signature(signature_attribute, encrypted_item, verification_key, crypto_config):
Expand All @@ -67,7 +69,8 @@ def verify_item_signature(signature_attribute, encrypted_item, verification_key,
:param DelegatedKey verification_key: DelegatedKey to use to calculate the signature
:param CryptoConfig crypto_config: Cryptographic configuration
"""
signature = signature_attribute[Tag.BINARY.dynamodb_tag]
# for some reason pylint can't follow the Enum member attributes
signature = signature_attribute[Tag.BINARY.dynamodb_tag] # pylint: disable=no-member
verification_key.verify(
algorithm=verification_key.algorithm,
signature=signature,
Expand Down Expand Up @@ -97,10 +100,11 @@ def _string_to_sign(item, table_name, attribute_actions):

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

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

data_to_sign.extend(_hash_data(hasher=hasher, data=serialize_attribute(item[key])))
return bytes(data_to_sign)
Expand Down
7 changes: 5 additions & 2 deletions src/dynamodb_encryption_sdk/internal/crypto/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""
try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
from typing import Text # noqa pylint: disable=unused-import

from dynamodb_encryption_sdk.internal import dynamodb_types # noqa pylint: disable=unused-import
except ImportError: # pragma: no cover
# We only actually need these imports when running the mypy checks
Expand Down Expand Up @@ -46,7 +47,8 @@ def encrypt_attribute(attribute_name, attribute, encryption_key, algorithm):
encrypted_attribute = encryption_key.encrypt(
algorithm=algorithm, name=attribute_name, plaintext=serialized_attribute
)
return {Tag.BINARY.dynamodb_tag: encrypted_attribute}
# for some reason pylint can't follow the Enum member attributes
return {Tag.BINARY.dynamodb_tag: encrypted_attribute} # pylint: disable=no-member


def decrypt_attribute(attribute_name, attribute, decryption_key, algorithm):
Expand All @@ -60,7 +62,8 @@ def decrypt_attribute(attribute_name, attribute, decryption_key, algorithm):
:returns: Plaintext DynamoDB attribute
:rtype: dict
"""
encrypted_attribute = attribute[Tag.BINARY.dynamodb_tag]
# for some reason pylint can't follow the Enum member attributes
encrypted_attribute = attribute[Tag.BINARY.dynamodb_tag] # pylint: disable=no-member
decrypted_attribute = decryption_key.decrypt(
algorithm=algorithm, name=attribute_name, ciphertext=encrypted_attribute
)
Expand Down
Loading