@@ -79,6 +79,10 @@ def group(label, command, instances, platforms, **kwargs):
7979 """
8080 # Use the 1st character of the group name (should be an emoji)
8181 label1 = label [0 ]
82+ # if the emoji is in the form ":emoji:", pick the entire slug
83+ if label .startswith (':' ) and ':' in label [1 :]:
84+ label1 = label [:label .index (':' , 1 )+ 1 ]
85+
8286 steps = []
8387 commands = command
8488 if isinstance (command , str ):
@@ -276,7 +280,7 @@ def __init__(self, with_build_step=True, **kwargs):
276280 if with_build_step :
277281 build_cmds , self .shared_build = shared_build ()
278282 self .build_group_per_arch (
279- "🏗️ Build" , build_cmds , depends_on_build = False , set_key = True
283+ "🏗️ Build" , build_cmds , depends_on_build = False , set_key = self . shared_build
280284 )
281285 else :
282286 self .shared_build = None
@@ -314,9 +318,25 @@ def _adapt_group(self, group):
314318 for step in group ["steps" ]:
315319 step ["command" ] = prepend + step ["command" ]
316320 if self .shared_build is not None :
317- step ["depends_on" ] = self .build_key (
318- get_arch_for_instance (step ["agents" ]["instance" ])
319- )
321+ if "depends_on" not in step :
322+ step ["depends_on" ] = []
323+ elif isinstance (step ["depends_on" ], str ):
324+ step ["depends_on" ] = [step ["depends_on" ]]
325+ elif isinstance (step ["depends_on" ], list ):
326+ pass
327+ else :
328+ raise ValueError (
329+ f"depends_on should be a string or a list but is { type (step ['depends_on' ])} "
330+ )
331+
332+ step ["depends_on" ].append (self .shared_build )
333+ step ["depends_on" ] = [
334+ self .build_key (
335+ dep , get_arch_for_instance (step ["agents" ]["instance" ])
336+ )
337+ for dep in step ["depends_on" ]
338+ ]
339+
320340 return group
321341
322342 def build_group (self , * args , ** kwargs ):
@@ -332,17 +352,17 @@ def build_group(self, *args, **kwargs):
332352 group (* args , ** combined ), depends_on_build = depends_on_build
333353 )
334354
335- def build_key (self , arch ):
355+ def build_key (self , key , arch ):
336356 """Return the Buildkite key for the build step, for the specified arch"""
337- return self . shared_build .replace ("$(uname -m)" , arch ).replace (".tar.gz" , "" )
357+ return key .replace ("$(uname -m)" , arch ).replace (".tar.gz" , "" )
338358
339359 def build_group_per_arch (self , label , * args , ** kwargs ):
340360 """
341361 Build a group, parametrizing over the architectures only.
342362
343363 kwargs consumed by this method and not passed down to `group`:
344364 - `depends_on_build` (default: `True`): Whether the steps in this group depend on the artifacts from the shared compilation steps
345- - `set_key`: If True , causes the generated steps to have a "key" field
365+ - `set_key`: If a string , causes the generated steps to have a "key" field replacing "$(uname -m)" with arch and removing trailing tar.gz
346366 """
347367 depends_on_build = kwargs .pop ("depends_on_build" , True )
348368 set_key = kwargs .pop ("set_key" , None )
@@ -351,7 +371,7 @@ def build_group_per_arch(self, label, *args, **kwargs):
351371 if set_key :
352372 for step in grp ["steps" ]:
353373 step ["key" ] = self .build_key (
354- get_arch_for_instance (step ["agents" ]["instance" ])
374+ set_key , get_arch_for_instance (step ["agents" ]["instance" ])
355375 )
356376 return self .add_step (grp , depends_on_build = depends_on_build )
357377
0 commit comments