Skip to content

Commit

Permalink
Chore | Migrate to GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
geototti21 committed Dec 8, 2023
1 parent 6ec3e61 commit d36ca74
Show file tree
Hide file tree
Showing 7 changed files with 603 additions and 323 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true

[*.{yml,yaml}]
indent_style = space
indent_size = 2

[*.{markdown,md}]
trim_trailing_whitespace = false
27 changes: 27 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: python
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: python -m pip install --upgrade pip poetry

- name: Install poetry
run: poetry install

- name: Run linter
run: make lint

- name: Run tests
run: make tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ setup: ## Create a virtual environment for the project and installs all dependen

.PHONY: format
format: ## Automatically format the .py files with Black and Isort
poetry run isort --recursive .
poetry run isort .
poetry run black .

.PHONY: lint
Expand Down
818 changes: 537 additions & 281 deletions poetry.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ include = [
"LICENSE",
]
[tool.poetry.dependencies]
python = "^3.7"
python = "^3.9"
boto3 = "^1.9"

[tool.poetry.dev-dependencies]
pytest = "^3.0"
mypy = "^0.720.0"
isort = "^4.3"
black = "==19.3b0"
flake8 = "^3.7"
pytest-cov = "^2.7"
pytest = "^7.4"
mypy = "^1.7"
isort = "^5.12"
black = "^23.11.0"
flake8 = "^6.1"
pytest-cov = "^4.0"
codecov = "^2.0"

[build-system]
Expand Down
31 changes: 17 additions & 14 deletions tests/test_python_aws_ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
)


def test_version():
def test_version() -> None:
assert __version__ == "1.0.0"


class TestGetParameters(TestCase):
def setUp(self):
def setUp(self) -> None:
self.parameter_store = ParameterStore(client=MagicMock())

def tearDown(self):
def tearDown(self) -> None:
pass

def test_get_parameters_keys_are_mapped(self):
def test_get_parameters_keys_are_mapped(self) -> None:
self.parameter_store.client.get_parameters.return_value = {
"Parameters": [
{"Name": "foo_ssm_key_1", "Value": "foo_ssm_value_1"},
Expand All @@ -47,7 +47,7 @@ def test_get_parameters_keys_are_mapped(self):
WithDecryption=True,
)

def test_get_parameters_unknown_keys_are_ignored(self):
def test_get_parameters_unknown_keys_are_ignored(self) -> None:
self.parameter_store.client.get_parameters.return_value = {
"Parameters": [
{"Name": "foo_ssm_key_1", "Value": "foo_ssm_value_1"},
Expand All @@ -59,14 +59,15 @@ def test_get_parameters_unknown_keys_are_ignored(self):

self.assertEqual({"foo_ssm_key_1": "foo_ssm_value_1"}, secrets)

def test_get_parameters_aws_errors_are_not_caught(self):
def test_get_parameters_aws_errors_are_not_caught(self) -> None:
expected_error = Exception("Unexpected AWS error!")
self.parameter_store.client.get_parameters.side_effect = expected_error

with self.assertRaises(Exception, msg="Unexpected AWS error!"):
self.parameter_store.get_parameters(["/key"])
return None

def test_get_parameters_by_path_keys_are_mapped(self):
def test_get_parameters_by_path_keys_are_mapped(self) -> None:
self.parameter_store.client.get_parameters_by_path.return_value = {
"Parameters": [
{"Name": "/bar/env/foo_ssm_key_1", "Value": "foo_ssm_value_1"},
Expand All @@ -84,7 +85,7 @@ def test_get_parameters_by_path_keys_are_mapped(self):
Path="/bar/env/", Recursive=False, WithDecryption=True
)

def test_get_parameters_by_path_are_stripped_of_leading_slashes(self):
def test_get_parameters_by_path_are_stripped_of_leading_slashes(self) -> None:
"""
Leading slashes of parameters are stripped consistently.
Expand Down Expand Up @@ -113,7 +114,7 @@ def test_get_parameters_by_path_are_stripped_of_leading_slashes(self):
Path=parameters_path, Recursive=False, WithDecryption=True
)

def test_get_parameters_by_path_recursive_not_nested(self):
def test_get_parameters_by_path_recursive_not_nested(self) -> None:
self.parameter_store.client.get_parameters_by_path.return_value = {
"Parameters": [
{"Name": "/bar/env/foo_ssm_key_1", "Value": "foo_ssm_value_1"},
Expand All @@ -136,7 +137,7 @@ def test_get_parameters_by_path_recursive_not_nested(self):
Path="/bar/", Recursive=True, WithDecryption=True
)

def test_get_parameters_by_path_recursive_nested(self):
def test_get_parameters_by_path_recursive_nested(self) -> None:
self.parameter_store.client.get_parameters_by_path.return_value = {
"Parameters": [
{"Name": "/bar/env/foo_ssm_key_1", "Value": "foo_ssm_value_1"},
Expand All @@ -161,12 +162,12 @@ def test_get_parameters_by_path_recursive_nested(self):
Path="/bar/", Recursive=True, WithDecryption=True
)

def test_get_parameter_by_path_aws_errors_are_not_caught(self):
def test_get_parameter_by_path_aws_errors_are_not_caught(self) -> None:
expected_error = Exception("Unexpected AWS error!")
self.parameter_store.client.get_parameters_by_path.side_effect = expected_error

with self.assertRaises(Exception, msg="Unexpected AWS error!"):
self.parameter_store.get_parameters_by_path(["/key"])
self.parameter_store.get_parameters_by_path("/key")

def test_get_required_parameters_by_path_can_be_asserted(self) -> None:
"""
Expand All @@ -190,7 +191,9 @@ def test_get_required_parameters_by_path_can_be_asserted(self) -> None:
assert len(exc_info.exception.parameter_names) == 2
assert sorted(exc_info.exception.parameter_names) == sorted(["baz", "foo/bar"])

def test_required_parameters_by_path_are_checked_before_recursive_nested(self):
def test_required_parameters_by_path_are_checked_before_recursive_nested(
self,
) -> None:
self.parameter_store.client.get_parameters_by_path.return_value = {
"Parameters": [
{"Name": "/bar/env/foo_ssm_key_1", "Value": "foo_ssm_value_1"},
Expand Down Expand Up @@ -218,7 +221,7 @@ def test_required_parameters_by_path_are_checked_before_recursive_nested(self):
Path="/bar/", Recursive=True, WithDecryption=True
)

def test_requesting_invalid_parameters(self):
def test_requesting_invalid_parameters(self) -> None:
"""Assert requesting invalid parameters results in an exception."""
self.parameter_store.client.get_parameters.return_value = {
"Parameters": [{"Name": "/test/foo", "Value": "foo_ssm_value_1"}],
Expand Down

0 comments on commit d36ca74

Please sign in to comment.