Skip to content

Commit b263118

Browse files
filippomcCopilot
andcommitted
(ci-cd) Remove unnecessary test builds from codefresh pipeline
Co-authored-by: Copilot <copilot@github.com>
1 parent dd49854 commit b263118

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

tools/deployment-cli-tools/ch_cli_tools/codefresh.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,12 @@ def add_unit_test_step(app_config: ApplicationHarnessConfig):
366366
codefresh_steps_from_base_path(join(root_path, APPS_PATH), include=helm_values[KEY_TASK_IMAGES].keys())
367367
codefresh_steps_from_base_path(join(root_path, APPS_PATH), include=build_included)
368368

369-
if CD_E2E_TEST_STEP in steps:
369+
if CD_E2E_TEST_STEP in steps and steps[CD_E2E_TEST_STEP].get("scale"):
370370
name = "test-e2e"
371371
if codefresh_steps_from_base_path(join(root_path, TEST_IMAGES_PATH), include=(name,), publish=False):
372372
steps[CD_E2E_TEST_STEP]["image"] = image_tag_with_variables(f"{base_name}/{name}", helm_values.registry.name, app_specific_tag_variable(name))
373373

374-
if CD_API_TEST_STEP in steps:
374+
if CD_API_TEST_STEP in steps and steps[CD_API_TEST_STEP].get("scale"):
375375
name = "test-api"
376376
if codefresh_steps_from_base_path(join(root_path, TEST_IMAGES_PATH), include=(name,), fixed_context=relpath(root_path, os.getcwd()), publish=False):
377377
steps[CD_API_TEST_STEP]["image"] = image_tag_with_variables(f"{base_name}/{name}", helm_values.registry.name, app_specific_tag_variable(name))

tools/deployment-cli-tools/tests/test_codefresh.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ def test_create_codefresh_configuration_tests():
290290
assert CD_API_TEST_STEP not in l1_steps, "Api steps are not included in any app"
291291
assert CD_E2E_TEST_STEP not in l1_steps, "E2E steps are not included in any app"
292292

293+
all_build_steps = {k: v for k, v in l1_steps.items() if k.startswith(STEP_0[:-1])}
294+
built_images = {name for step in all_build_steps.values() for name in step.get("steps", {})}
295+
assert "test-e2e" not in built_images, "test-e2e image should not be built when no e2e tests are configured"
296+
assert "test-api" not in built_images, "test-api image should not be built when no api tests are configured"
297+
293298
finally:
294299
shutil.rmtree(BUILD_MERGE_DIR)
295300

0 commit comments

Comments
 (0)