@@ -78,6 +78,10 @@ def group(label, command, instances, platforms, **kwargs):
7878 """
7979 # Use the 1st character of the group name (should be an emoji)
8080 label1 = label [0 ]
81+ # if the emoji is in the form ":emoji:", pick the entire slug
82+ if label .startswith (":" ) and ":" in label [1 :]:
83+ label1 = label [: label .index (":" , 1 ) + 1 ]
84+
8185 steps = []
8286 commands = command
8387 if isinstance (command , str ):
@@ -275,7 +279,7 @@ def __init__(self, with_build_step=True, **kwargs):
275279 if with_build_step :
276280 build_cmds , self .shared_build = shared_build ()
277281 self .build_group_per_arch (
278- "🏗️ Build" , build_cmds , depends_on_build = False , set_key = True
282+ "🏗️ Build" , build_cmds , depends_on_build = False , set_key = self . shared_build
279283 )
280284 else :
281285 self .shared_build = None
@@ -313,9 +317,25 @@ def _adapt_group(self, group):
313317 for step in group ["steps" ]:
314318 step ["command" ] = prepend + step ["command" ]
315319 if self .shared_build is not None :
316- step ["depends_on" ] = self .build_key (
317- get_arch_for_instance (step ["agents" ]["instance" ])
318- )
320+ if "depends_on" not in step :
321+ step ["depends_on" ] = []
322+ elif isinstance (step ["depends_on" ], str ):
323+ step ["depends_on" ] = [step ["depends_on" ]]
324+ elif isinstance (step ["depends_on" ], list ):
325+ pass
326+ else :
327+ raise ValueError (
328+ f"depends_on should be a string or a list but is { type (step ['depends_on' ])} "
329+ )
330+
331+ step ["depends_on" ].append (self .shared_build )
332+ step ["depends_on" ] = [
333+ self .build_key (
334+ dep , get_arch_for_instance (step ["agents" ]["instance" ])
335+ )
336+ for dep in step ["depends_on" ]
337+ ]
338+
319339 return group
320340
321341 def build_group (self , * args , ** kwargs ):
@@ -331,17 +351,17 @@ def build_group(self, *args, **kwargs):
331351 group (* args , ** combined ), depends_on_build = depends_on_build
332352 )
333353
334- def build_key (self , arch ):
354+ def build_key (self , key , arch ):
335355 """Return the Buildkite key for the build step, for the specified arch"""
336- return self . shared_build .replace ("$(uname -m)" , arch ).replace (".tar.gz" , "" )
356+ return key .replace ("$(uname -m)" , arch ).replace (".tar.gz" , "" )
337357
338358 def build_group_per_arch (self , label , * args , ** kwargs ):
339359 """
340360 Build a group, parametrizing over the architectures only.
341361
342362 kwargs consumed by this method and not passed down to `group`:
343363 - `depends_on_build` (default: `True`): Whether the steps in this group depend on the artifacts from the shared compilation steps
344- - `set_key`: If True , causes the generated steps to have a "key" field
364+ - `set_key`: If a string , causes the generated steps to have a "key" field replacing "$(uname -m)" with arch and removing trailing tar.gz
345365 """
346366 depends_on_build = kwargs .pop ("depends_on_build" , True )
347367 set_key = kwargs .pop ("set_key" , None )
@@ -350,7 +370,7 @@ def build_group_per_arch(self, label, *args, **kwargs):
350370 if set_key :
351371 for step in grp ["steps" ]:
352372 step ["key" ] = self .build_key (
353- get_arch_for_instance (step ["agents" ]["instance" ])
373+ set_key , get_arch_for_instance (step ["agents" ]["instance" ])
354374 )
355375 return self .add_step (grp , depends_on_build = depends_on_build )
356376
0 commit comments