Skip to content

Commit f70a87f

Browse files
committed
buildkite: make build steps unique
If we have more than one build step in a pipeline, Buildkite complains that they are not unique. fatal: Failed to upload and process pipeline: Pipeline upload rejected: The key "build_x86_64" has already been used by another step in this build We had a similar issue with shared build tarballs, so just reuse the tarball name as key. Fixes: 19e9051 Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent 474392d commit f70a87f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

.buildkite/common.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def __init__(self, with_build_step=True, **kwargs):
259259
if with_build_step:
260260
build_cmds, self.shared_build = shared_build()
261261
self.build_group_per_arch(
262-
"🏗️ Build", build_cmds, depends_on_build=False, key_prefix="build"
262+
"🏗️ Build", build_cmds, depends_on_build=False, set_key=True
263263
)
264264
else:
265265
self.shared_build = None
@@ -297,8 +297,8 @@ def _adapt_group(self, group):
297297
for step in group["steps"]:
298298
step["command"] = prepend + step["command"]
299299
if self.shared_build is not None:
300-
step["depends_on"] = (
301-
"build_" + DEFAULT_INSTANCES[step["agents"]["instance"]]
300+
step["depends_on"] = self.build_key(
301+
DEFAULT_INSTANCES[step["agents"]["instance"]]
302302
)
303303
return group
304304

@@ -314,22 +314,26 @@ def build_group(self, *args, **kwargs):
314314
group(*args, **combined), depends_on_build=depends_on_build
315315
)
316316

317+
def build_key(self, arch):
318+
"""Return the Buildkite key for the build step, for the specified arch"""
319+
return self.shared_build.replace("$(uname -m)", arch).replace(".tar.gz", "")
320+
317321
def build_group_per_arch(self, label, *args, **kwargs):
318322
"""
319323
Build a group, parametrizing over the architectures only.
320324
321325
kwargs consumed by this method and not passed down to `group`:
322326
- `depends_on_build` (default: `True`): Whether the steps in this group depend on the artifacts from the shared compilation steps
323-
- `key_prefix`: If set, causes the generated steps to have a "key" field set to f"{key_prefix}_{$ARCH}".
327+
- `set_key`: If True, causes the generated steps to have a "key" field
324328
"""
325329
depends_on_build = kwargs.pop("depends_on_build", True)
326-
key_prefix = kwargs.pop("key_prefix", None)
330+
set_key = kwargs.pop("set_key", None)
327331
combined = overlay_dict(self.per_arch, kwargs)
328332
grp = group(label, *args, **combined)
329-
if key_prefix:
333+
if set_key:
330334
for step in grp["steps"]:
331-
step["key"] = (
332-
key_prefix + "_" + DEFAULT_INSTANCES[step["agents"]["instance"]]
335+
step["key"] = self.build_key(
336+
DEFAULT_INSTANCES[step["agents"]["instance"]]
333337
)
334338
return self.add_step(grp, depends_on_build=depends_on_build)
335339

0 commit comments

Comments
 (0)