Skip to content

Commit d7d87e8

Browse files
committed
CH-198 fix codefresh pipelines generation with no dependencies
1 parent 7541f30 commit d7d87e8

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def add_unit_test_step(app_config: ApplicationHarnessConfig):
386386
codefresh_steps_from_base_path(join(root_path, STATIC_IMAGES_PATH),
387387
include=helm_values[KEY_TASK_IMAGES].keys())
388388
codefresh_steps_from_base_path(join(root_path, APPS_PATH), include=helm_values[KEY_TASK_IMAGES].keys())
389-
codefresh_steps_from_base_path(join(root_path, APPS_PATH), include=build_included)
389+
codefresh_steps_from_base_path(join(root_path, APPS_PATH), include=build_included)
390390

391391
if CD_E2E_TEST_STEP in steps and steps[CD_E2E_TEST_STEP].get("scale"):
392392
name = "test-e2e"

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,51 @@ def test_create_codefresh_configuration_tests():
299299
shutil.rmtree(BUILD_MERGE_DIR)
300300

301301

302+
def test_create_codefresh_configuration_app_without_base_build_dependency():
303+
"""An app that has a Dockerfile but no build dependencies on task images must still
304+
be included in the build steps. Previously the apps directory was iterated only if
305+
task-images was non-empty, so apps with no base build dependency were silently skipped."""
306+
values = create_helm_chart(
307+
[CLOUDHARNESS_ROOT, RESOURCES],
308+
output_path=OUT,
309+
include=['accounts'],
310+
exclude=['events'],
311+
domain="my.local",
312+
namespace='test',
313+
env='dev',
314+
local=False,
315+
tag=1,
316+
registry='reg'
317+
)
318+
try:
319+
root_paths = preprocess_build_overrides(
320+
root_paths=[CLOUDHARNESS_ROOT, RESOURCES],
321+
helm_values=values,
322+
merge_build_path=BUILD_MERGE_DIR
323+
)
324+
325+
build_included = [app['harness']['name']
326+
for app in values['apps'].values() if 'harness' in app]
327+
328+
assert values.get('task-images') == {} or 'task-images' not in values, \
329+
"Precondition: accounts must not pull in any task images for this test to be meaningful"
330+
331+
cf = create_codefresh_deployment_scripts(root_paths, include=build_included,
332+
envs=['dev'],
333+
base_image_name=values['name'],
334+
helm_values=values, save=False)
335+
336+
all_build_steps = {}
337+
for step_name in [STEP_0, STEP_1, STEP_2, STEP_3]:
338+
if step_name in cf['steps']:
339+
all_build_steps.update(cf['steps'][step_name].get('steps', {}))
340+
341+
assert 'accounts' in all_build_steps, \
342+
f"accounts must be included in the build steps even when no base build dependency is specified. Got: {list(all_build_steps.keys())}"
343+
finally:
344+
shutil.rmtree(BUILD_MERGE_DIR, ignore_errors=True)
345+
346+
302347
def test_create_codefresh_configuration_nobuild():
303348
values = create_helm_chart(
304349
[RESOURCES],

0 commit comments

Comments
 (0)