Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Fix promotion not working when using a build tag #70

Merged
merged 3 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions brick/dockerlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,24 @@ def docker_build(
dockerfile_contents += f'\nLABEL brick.dependency_hash="{dependency_hash}"'
images_matching_hash = get_image_names_with_dependency_hash(dependency_hash)
logger.debug(
f"Found {len(images_matching_hash)} image(s) matching dependency hash ({images_matching_hash[0:2]}..)"
f"Found {len(images_matching_hash)} image(s) matching dependency hash {dependency_hash} ({images_matching_hash[0:5]}..)"
)

images_are_build = set(tags).issubset(set(images_matching_hash))
if images_are_build:
logger.debug(f"Skipping docker build as images are up to date with input dependencies")
return tag_to_return

# Investigate if we can promote images instead of building them again
image_name = tag_to_return.split(":")[0]
# Investigate if we can promote an image instead of building it again
image_names = {t.split(":")[0] for t in tags}
related_images_with_latest_tag = [
image
for image in images_matching_hash
if image.split(":")[0] == image_name and image.endswith(":latest")
if image.split(":")[0] in image_names and image.endswith(":latest")
]

if related_images_with_latest_tag:
# Note that we could probably allow branch images to be used for promotion.
assert (
len(related_images_with_latest_tag) == 1
), f"Expected one related image, but found {related_images_with_latest_tag}"
image_with_latest_tag = related_images_with_latest_tag[0]
logger.debug(f"Promoting image {image_with_latest_tag}")
tag_image(image_name=image_with_latest_tag, tags=tags)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_brick.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ def test_examples_node_build_2_on_master(caplog, monkeypatch) -> None:
assert get_docker_images_built_from_debug_logs(debug_logs) == set([]) # nothing was built


@pytest.mark.skip(
reason="promoting images actually doesn't work as intended when using a build tag"
)
def test_examples_node_build_3_on_feature_branch(caplog, monkeypatch) -> None:
# NOTE: test depends on test_examples_node_build_1_on_master
clean_up_output_folders()
Expand Down