Skip to content

Commit 4a48e14

Browse files
committed
Revert "Merge pull request #223 from shanejbrown/XENG-9264"
This reverts commit baee0d0, reversing changes made to cc251e5.
1 parent baee0d0 commit 4a48e14

12 files changed

Lines changed: 908 additions & 1110 deletions

File tree

.github/workflows/build.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ jobs:
3333
run: uv sync --locked
3434
- name: Pre-commit checks
3535
run: uv run pre-commit run --all-files
36-
37-
- name: Set up QEMU
38-
uses: docker/setup-qemu-action@v1
39-
with:
40-
platforms: linux/amd64,linux/arm64
41-
42-
- name: Set up Docker Buildx
43-
uses: docker/setup-buildx-action@v1
44-
4536
- name: Test with pytest
4637
# Create the ssh key file once for all testing
4738
run: |

README.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -990,19 +990,6 @@ The default generated tag may be omitted by setting the 'add_build_tag' flag to
990990
false. In this case, the 'tags' property must be specified or else an error
991991
will occur.
992992

993-
When multiple build steps push to the same Docker repository, each step receives
994-
a unique default tag that includes the step name (format: ``{default_tag}-{step_name}``).
995-
This prevents tag collisions between steps. For example, if two steps named
996-
``build-java17`` and ``build-java11`` both push to ``myimages/app``, they will
997-
receive default tags like ``main-1791.Ia09cc5.M0-1661374484-build-java17`` and
998-
``main-1791.Ia09cc5.M0-1661374484-build-java11`` respectively.
999-
1000-
Docker images pushed to registries are recorded in the ``artifacts.json`` file.
1001-
When multiple steps push to the same repository, each step creates a separate
1002-
artifact entry keyed by ``{step_name}/{repository}`` (e.g., ``build-java17/myimages/app``).
1003-
This prevents artifact entries from overwriting each other and allows downstream
1004-
systems to distinguish between images from different build steps.
1005-
1006993
To push the image to a registry, you must add the --push argument to buildrunner.
1007994

1008995
The following is an example of simple configuration where only the repository

buildrunner/config/loader.py

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -87,53 +87,6 @@ def _add_default_tag_to_tags(config: Union[str, dict], default_tag: str) -> dict
8787
return config
8888

8989

90-
def _get_step_tag(default_tag: str, step_name: str, max_length: int = 128) -> str:
91-
"""
92-
Get a step-specific tag from a default tag and step name.
93-
94-
This function creates unique tags per build step by appending the step name to
95-
the default tag. This is necessary when multiple build steps push to the same
96-
Docker repository, as it prevents tag collisions (multiple build steps using the same default tag).
97-
98-
Args:
99-
default_tag: The base default tag (typically a build ID or timestamp)
100-
step_name: The name of the build step (e.g., "build-java17")
101-
max_length: Maximum allowed tag length (default: 128, Docker image tag name character limit)
102-
103-
Returns:
104-
A step-specific tag in the format "{default_tag}-{step_name}".
105-
If the resulting tag exceeds max_length, the default_tag is truncated
106-
to fit while preserving the step_name suffix.
107-
"""
108-
# Create step-specific tag by appending step name to default tag
109-
step_tag = f"{default_tag}-{step_name}"
110-
111-
# If tag is within length limit, return as-is
112-
if len(step_tag) <= max_length:
113-
return step_tag
114-
115-
# Tag exceeds Docker's maximum length limit (typically 128 characters)
116-
# Truncate the default_tag portion while preserving the step_name suffix
117-
# This ensures the step name is always included for uniqueness
118-
LOGGER.info(
119-
f"Step tag {step_tag} is too long, truncating default tag by length of step name"
120-
)
121-
122-
step_suffix = f"-{step_name}"
123-
124-
# If the step suffix is too long, truncate it
125-
if len(step_suffix) > max_length:
126-
step_suffix = step_suffix[:max_length]
127-
128-
# Calculate how much space we have for the default_tag portion
129-
available_space = max_length - len(step_suffix)
130-
step_tag = f"{default_tag[:available_space]}{step_suffix}"
131-
132-
LOGGER.info(f"Truncated step tag: {step_tag}")
133-
134-
return step_tag
135-
136-
13790
def _set_default_tag(config: dict, default_tag: str) -> dict:
13891
"""
13992
Set default tag if not set for each image
@@ -149,20 +102,18 @@ def _set_default_tag(config: dict, default_tag: str) -> dict:
149102
if not isinstance(steps, dict):
150103
return config
151104
for step_name, step in steps.items():
152-
step_tag = _get_step_tag(default_tag, step_name)
153-
154105
for substep_name, substep in step.items():
155106
if substep_name in ["push", "commit"]:
156107
# Add default tag to tags list if not in the list
157108
if isinstance(substep, list):
158109
curr_image_infos = []
159110
for push_config in substep:
160111
curr_image_infos.append(
161-
_add_default_tag_to_tags(push_config, step_tag)
112+
_add_default_tag_to_tags(push_config, default_tag)
162113
)
163114
config["steps"][step_name][substep_name] = curr_image_infos
164115
else:
165-
curr_image_info = _add_default_tag_to_tags(substep, step_tag)
116+
curr_image_info = _add_default_tag_to_tags(substep, default_tag)
166117
config["steps"][step_name][substep_name] = curr_image_info
167118
return config
168119

buildrunner/steprunner/tasks/push.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,8 @@ def run(self, context): # pylint: disable=too-many-branches
348348

349349
# Add tagged image as artifact if this is a push and not just a commit
350350
if not self._commit_only:
351-
# Include step name in artifact key to prevent overwrites when multiple
352-
# steps push to the same repository with different tags
353-
artifact_key = f"{self.step_runner.name}/{repo.repository}"
354351
self.step_runner.build_runner.add_artifact(
355-
artifact_key,
352+
repo.repository,
356353
{
357354
"type": "docker-image",
358355
"docker:image": built_image_ids_str,

buildrunner/steprunner/tasks/run.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,34 +1152,19 @@ def _run_post_build(self, context):
11521152
self.step_runner.log.info("Running post-build processing")
11531153
post_build = self.step.post_build
11541154
temp_tag = f"buildrunner-post-build-tag-{str(uuid.uuid4())}"
1155-
committed_image = self.runner.commit(self.step_runner.log)
1156-
python_on_whales.docker.image.tag(committed_image, temp_tag)
1155+
python_on_whales.docker.image.tag(
1156+
self.runner.commit(self.step_runner.log),
1157+
temp_tag,
1158+
)
11571159
self.images_to_remove.append(temp_tag)
11581160

1159-
# Force use of legacy builder for post-build since we're using a locally committed image
1160-
# Buildx with certain builders (like docker-container) cannot access local images
1161-
buildrunner_config = BuildRunnerConfig.get_instance()
1162-
original_use_legacy_builder = buildrunner_config.run_config.use_legacy_builder
1163-
if not original_use_legacy_builder:
1164-
self.step_runner.log.info(
1165-
"Forcing use of legacy builder for post-build step (committed image is local)"
1166-
)
1167-
buildrunner_config.run_config.use_legacy_builder = True
1168-
11691161
post_build.pull = False
1170-
try:
1171-
build_image_task = BuildBuildStepRunnerTask(
1172-
self.step_runner, post_build, image_to_prepend_to_dockerfile=temp_tag
1173-
)
1174-
_build_context = {}
1175-
build_image_task.run(_build_context)
1176-
context["run-image"] = _build_context.get("image", None)
1177-
finally:
1178-
# Restore the original builder setting
1179-
if not original_use_legacy_builder:
1180-
buildrunner_config.run_config.use_legacy_builder = (
1181-
original_use_legacy_builder
1182-
)
1162+
build_image_task = BuildBuildStepRunnerTask(
1163+
self.step_runner, post_build, image_to_prepend_to_dockerfile=temp_tag
1164+
)
1165+
_build_context = {}
1166+
build_image_task.run(_build_context)
1167+
context["run-image"] = _build_context.get("image", None)
11831168

11841169
def cleanup(self, context): # pylint: disable=unused-argument
11851170
if self.runner:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "uv_build"
44

55
[project]
66
name = "buildrunner"
7-
version = "3.20"
7+
version = "3.19"
88
description = "Docker-based build tool"
99
readme = "README.rst"
1010
requires-python = ">=3.9"

tests/test-files/test-multiplatform-image-tags.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/test-files/test-push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ steps:
6363
build:
6464
# pull defaults to false
6565
dockerfile: |
66-
FROM adobe/buildrunner-test3:{{ BUILDRUNNER_BUILD_DOCKER_TAG }}-test-commit-list
66+
FROM adobe/buildrunner-test3:{{ BUILDRUNNER_BUILD_DOCKER_TAG }}
6767
run:
6868
cmds:
6969
# File should exist since the locally committed version is used

tests/test_buildrunner_files.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"test-general-buildx.yaml",
2121
"test-general.yaml",
2222
"test-push-artifact-buildx.yaml",
23-
"test-multiplatform-image-tags.yaml",
2423
]
2524

2625

tests/test_config_validation/test_retagging.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def test_valid_config_with_buildrunner_build_tag(
336336
buildrunner_config = BuildRunnerConfig.get_instance()
337337
push_info = buildrunner_config.run_config.steps["build-container"].push
338338
assert isinstance(push_info, list)
339-
assert f"{id_string}-{build_number}-build-container" in push_info[0].tags
339+
assert f"{id_string}-{build_number}" in push_info[0].tags
340340

341341

342342
@pytest.mark.parametrize(
@@ -362,9 +362,28 @@ def test_valid_config_with_buildrunner_build_tag(
362362
push:
363363
repository: user1/buildrunner-test-multi-platform2
364364
tags: [ 'latest' ]
365-
"""
365+
""",
366+
"""
367+
steps:
368+
build-container-multi-platform:
369+
build:
370+
dockerfile: |
371+
FROM {{ DOCKER_REGISTRY }}/busybox
372+
platforms:
373+
- linux/amd64
374+
- linux/arm64/v8
375+
push:
376+
- repository: user1/buildrunner-test-multi-platform
377+
tags: [ 'latest', '0.0.1' ]
378+
379+
use-built-image1:
380+
run:
381+
image: user1/buildrunner-test-multi-platform:{{ BUILDRUNNER_BUILD_DOCKER_TAG }}
382+
cmd: echo "Hello World"
383+
push: user1/buildrunner-test-multi-platform2
384+
""",
366385
],
367-
ids=["buildrunner_build_tag_explict"],
386+
ids=["buildrunner_build_tag_explict", "buildrunner_build_tag_implied"],
368387
)
369388
@mock.patch("buildrunner.config.DEFAULT_GLOBAL_CONFIG_FILES", [])
370389
@mock.patch("buildrunner.detect_vcs")

0 commit comments

Comments
 (0)