Skip to content

Commit dbf7fa1

Browse files
heitorlessarubenfonseca
authored andcommitted
chore: micro-optimization to not regenerate cdk app if already present
Signed-off-by: heitorlessa <[email protected]>
1 parent b6fcc01 commit dbf7fa1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/e2e/utils/infrastructure.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,14 @@ def _create_temp_cdk_app(self):
195195
196196
This allows us to keep our BaseInfrastructure while supporting context lookups.
197197
"""
198-
# tests.e2e.tracer.infrastructure
198+
# cdk.out/tracer/cdk_app_v39.py
199+
temp_file = self._cdk_out_dir / f"cdk_app_{PYTHON_RUNTIME_VERSION}.py"
200+
201+
if temp_file.exists():
202+
# no need to regenerate CDK app since it's just boilerplate
203+
return temp_file
204+
205+
# Convert from POSIX path to Python module: tests.e2e.tracer.infrastructure
199206
infra_module = str(self._feature_infra_module_path.relative_to(SOURCE_CODE_ROOT_PATH)).replace(os.sep, ".")
200207

201208
code = f"""
@@ -208,8 +215,6 @@ def _create_temp_cdk_app(self):
208215
if not self._cdk_out_dir.is_dir():
209216
self._cdk_out_dir.mkdir(parents=True, exist_ok=True)
210217

211-
# cdk.out/tracer/cdk_app_v39.py
212-
temp_file = self._cdk_out_dir / f"cdk_app_{PYTHON_RUNTIME_VERSION}.py"
213218
with temp_file.open("w") as fd:
214219
fd.write(textwrap.dedent(code))
215220

0 commit comments

Comments
 (0)