Skip to content

Commit

Permalink
Added pipeline aws_infra python typing check
Browse files Browse the repository at this point in the history
  • Loading branch information
mluypaert committed Apr 9, 2024
1 parent 157d602 commit 2b4beba
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 13 deletions.
3 changes: 3 additions & 0 deletions pipeline/aws_infra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ run-unit-tests: python-dependencies python-test-dependencies

run-unit-tests-dev: check-venv-active python-dependencies python-test-dependencies
python -m pytest

run-python-type-check: python-dependencies python-test-dependencies
mypy --install-types --non-interactive --warn-unused-config .
10 changes: 5 additions & 5 deletions pipeline/aws_infra/cdk_app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python3
import os

import aws_cdk as cdk
from aws_cdk import (
App, Environment
)

from cdk_classes.cdk_infra_stack import CdkInfraStack


app = cdk.App()
app = App()
CdkInfraStack(app, "PaviPipelineCdkStack",
env=cdk.Environment(account='100225593120', region='us-east-1'))
env=Environment(account='100225593120', region='us-east-1'))

app.synth()
Empty file.
4 changes: 3 additions & 1 deletion pipeline/aws_infra/cdk_classes/cdk_infra_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

from constructs import Construct

from typing import Any

from cdk_classes.pipeline_stack import PaviEcrRepository

class CdkInfraStack(Stack):

def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
def __init__(self, scope: Construct, construct_id: str, **kwargs: Any) -> None:
super().__init__(scope, construct_id, **kwargs)

PaviEcrRepository(self, id="PAVI-pipeline-seq-retrieval-repo", component_name='seq_retrieval')
Expand Down
2 changes: 1 addition & 1 deletion pipeline/aws_infra/cdk_classes/pipeline_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def __init__(self, scope: Stack, id: str, component_name: str) -> None:
self.repository = repo

def get_repo_arn(self) -> str:
return self.repository.repository_arn
return str(self.repository.repository_arn)
10 changes: 10 additions & 0 deletions pipeline/aws_infra/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[mypy]
disallow_any_generics = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
warn_unused_ignores = False
warn_return_any = True
strict_equality = True
enable_error_code = explicit-override,truthy-bool,truthy-iterable,possibly-undefined
follow_imports = skip
1 change: 1 addition & 0 deletions pipeline/aws_infra/tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mypy==1.9.*
pytest==8.0.*
13 changes: 7 additions & 6 deletions pipeline/aws_infra/tests/test_cdk_infra_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
before getting applied to the live AWS resources.
"""

import aws_cdk
from aws_cdk import App
from aws_cdk.aws_config import ResourceType
import aws_cdk.assertions as assertions

from cdk_classes.cdk_infra_stack import CdkInfraStack

app = aws_cdk.App()
app = App()
stack = CdkInfraStack(app, "pytest-stack")
template = assertions.Template.from_stack(stack)

Expand All @@ -21,15 +22,15 @@
# * Move All images from the old ECR repository to the new one
# (or delete the images if no longer relevant)
# * Delete the old ECR repository
def test_pipeline_seq_retrieval_ecr_repo():
template.has_resource(type=aws_cdk.aws_config.ResourceType.ECR_REPOSITORY.compliance_resource_type, props={
def test_pipeline_seq_retrieval_ecr_repo() -> None:
template.has_resource(type=ResourceType.ECR_REPOSITORY.compliance_resource_type, props={
"Properties": {
"RepositoryName": "agr_pavi/seq_retrieval"
}
})

def test_pipeline_alignment_ecr_repo():
template.has_resource(type=aws_cdk.aws_config.ResourceType.ECR_REPOSITORY.compliance_resource_type, props={
def test_pipeline_alignment_ecr_repo() -> None:
template.has_resource(type=ResourceType.ECR_REPOSITORY.compliance_resource_type, props={
"Properties": {
"RepositoryName": "agr_pavi/alignment"
}
Expand Down

0 comments on commit 2b4beba

Please sign in to comment.