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

Commit

Permalink
Extend the search for images to promote
Browse files Browse the repository at this point in the history
Instead of reying on the last tag in the list, we should consider all repositories.

This solves an issue where the last tag in the list was actually another repository (due to the build.tag option in the BUILD.yml file), and we thereby lost the promotion cache.
  • Loading branch information
skovhus committed Oct 27, 2020
1 parent c01c288 commit 0a2ce9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
10 changes: 4 additions & 6 deletions brick/dockerlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,16 @@ def docker_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 = set([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

0 comments on commit 0a2ce9d

Please sign in to comment.