Skip to content

Commit 081b7d9

Browse files
author
Michal Ploski
committed
Enable deploying stack with concrete python version
1 parent 25c7723 commit 081b7d9

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

.github/workflows/run-e2e-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@ jobs:
1616
permissions:
1717
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
1818
contents: read
19+
strategy:
20+
matrix:
21+
version: ["3.8", "3.9", "3.10"]
1922
steps:
2023
- name: "Checkout"
2124
uses: actions/checkout@v3
2225
#########################
2326
# Release new version
2427
#########################
25-
- name: "Use Python 3"
28+
- name: "Use Python"
2629
uses: actions/setup-python@v3
2730
with:
28-
python-version: "3.x" # Version range or exact version of a Python version to use, using SemVer's version range syntax
29-
architecture: "x64" # optional x64 or x86. Defaults to x64 if not specified
31+
python-version: ${{ matrix.version }}
32+
architecture: "x64"
3033
- name: Install dependencies
3134
run: make dev
3235
- name: Configure AWS credentials

tests/e2e/utils/infrastructure.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
import io
22
import os
3+
import sys
34
import zipfile
5+
from enum import Enum
46
from pathlib import Path
57

68
import boto3
79
import yaml
810
from aws_cdk import App, CfnOutput, RemovalPolicy, Stack, aws_lambda_python_alpha, aws_logs
911
from aws_cdk.aws_lambda import Code, Function, Runtime, Tracing
1012

13+
PYTHON_RUNTIME_VERSION = f"V{''.join(map(str, sys.version_info[:2]))}"
14+
15+
16+
class PythonVersion(Enum):
17+
V37 = Runtime.PYTHON_3_7
18+
V38 = Runtime.PYTHON_3_8
19+
V39 = Runtime.PYTHON_3_9
20+
1121

1222
class Infrastructure:
1323
def __init__(self, stack_name: str, handlers_dir: str, config: dict, environment_variables: dict) -> None:
@@ -63,7 +73,7 @@ def _prepare_stack(self, handlers, handlers_dir, stack_name, environment_variabl
6373
"aws-lambda-powertools",
6474
layer_version_name="aws-lambda-powertools",
6575
entry=".",
66-
compatible_runtimes=[Runtime.PYTHON_3_9],
76+
compatible_runtimes=[PythonVersion[PYTHON_RUNTIME_VERSION].value],
6777
)
6878
code = Code.from_asset(handlers_dir)
6979

@@ -72,7 +82,7 @@ def _prepare_stack(self, handlers, handlers_dir, stack_name, environment_variabl
7282
function_python = Function(
7383
stack,
7484
f"{filename}-lambda",
75-
runtime=Runtime.PYTHON_3_9,
85+
runtime=PythonVersion[PYTHON_RUNTIME_VERSION].value,
7686
code=code,
7787
handler=f"{filename}.lambda_handler",
7888
layers=[powertools_layer],

0 commit comments

Comments
 (0)