Skip to content
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
4 changes: 3 additions & 1 deletion src/taskgraph/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def build_image(
raise

# Parent id doesn't exist, needs to be re-built as well.
parent = task.dependencies["parent"][len("docker-image-") :]
parent = next(
t for t in image_tasks if image_tasks[t].task_id == parent_id
).removeprefix("docker-image-")
parent_tar = temp_dir / "parent.tar"
build_image(graph_config, parent, save_image=str(parent_tar))
volumes.append((str(parent_tar), "/workspace/parent.tar"))
Expand Down
16 changes: 13 additions & 3 deletions test/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,13 @@ def test_load_task_with_develop(mocker, run_load_task, task):

@pytest.fixture
def run_build_image(mocker):
def inner(image_name, save_image=None, context_file=None, image_task=None):
def inner(
image_name,
save_image=None,
context_file=None,
image_task=None,
parent_task_id=None,
):
graph_config = GraphConfig(
{
"trust-domain": "test-domain",
Expand Down Expand Up @@ -614,6 +620,8 @@ def mock_path_constructor(path_arg):

parent_image = mocker.MagicMock()
parent_image.task = {"payload": {"env": {}}}
if parent_task_id:
parent_image.task_id = parent_task_id

mocks["image_task"] = image_task
mocks["load_tasks_for_kind"].return_value = {
Expand Down Expand Up @@ -717,8 +725,10 @@ def test_build_image_with_parent_not_found(
# Test building image that uses DOCKER_IMAGE_PARENT
image_task = mocker.MagicMock()
image_task.task = {"payload": {"env": {"PARENT_TASK_ID": parent_task_id}}}
image_task.dependencies = {"parent": "docker-image-parent"}
result, mocks = run_build_image("hello-world", image_task=image_task)
image_task.dependencies = {"parent": parent_task_id}
result, mocks = run_build_image(
"hello-world", image_task=image_task, parent_task_id=parent_task_id
)
assert result == "hello-world:latest"

# Verify the graph generation call
Expand Down
Loading