@@ -82,6 +82,7 @@ def main() -> int:
82
82
so it is executed.""" ,
83
83
)
84
84
85
+ parser .add_argument ("--dry-run" , action = "store_true" )
85
86
parser .add_argument ("--coverage" , action = "store_true" )
86
87
parser .add_argument (
87
88
"--sanitizer" ,
@@ -193,6 +194,7 @@ def fetch_hashes() -> None:
193
194
args .bazel_remote_cache ,
194
195
bazel_lto ,
195
196
)
197
+ truncate_skip_length (pipeline )
196
198
handle_sanitizer_skip (pipeline , args .sanitizer )
197
199
increase_agents_timeouts (pipeline , args .sanitizer , args .coverage )
198
200
prioritize_pipeline (pipeline , args .priority )
@@ -221,9 +223,10 @@ def fetch_hashes() -> None:
221
223
222
224
print ("--- Uploading new pipeline:" )
223
225
print (yaml .dump (pipeline ))
224
- spawn .runv (
225
- ["buildkite-agent" , "pipeline" , "upload" ], stdin = yaml .dump (pipeline ).encode ()
226
- )
226
+ cmd = ["buildkite-agent" , "pipeline" , "upload" ]
227
+ if args .dry_run :
228
+ cmd .append ("--dry-run" )
229
+ spawn .runv (cmd , stdin = yaml .dump (pipeline ).encode ())
227
230
228
231
return 0
229
232
@@ -264,56 +267,48 @@ def prioritize_pipeline(pipeline: Any, priority: int) -> None:
264
267
if build_author == "Dependabot" :
265
268
priority -= 40
266
269
267
- def visit (config : Any ) -> None :
270
+ for step in steps (pipeline ):
271
+ if "trigger" in step or "wait" in step or "group" in step :
272
+ # Trigger and Wait steps do not allow priorities.
273
+ continue
268
274
# Increase priority for larger Hetzner-based tests so that they get
269
275
# preferential treatment on the agents which also accept smaller jobs.
270
276
agent_priority = 0
271
- if "agents" in config :
272
- agent = config ["agents" ].get ("queue" , None )
277
+ if "agents" in step :
278
+ agent = step ["agents" ].get ("queue" , None )
273
279
if agent == "hetzner-aarch64-8cpu-16gb" :
274
280
agent_priority = 1
275
281
if agent == "hetzner-aarch64-16cpu-32gb" :
276
282
agent_priority = 2
277
- config ["priority" ] = config .get ("priority" , 0 ) + priority + agent_priority
283
+ step ["priority" ] = step .get ("priority" , 0 ) + priority + agent_priority
278
284
279
- for config in pipeline ["steps" ]:
280
- if "trigger" in config or "wait" in config :
281
- # Trigger and Wait steps do not allow priorities.
282
- continue
283
- if "group" in config :
284
- for inner_config in config .get ("steps" , []):
285
- visit (inner_config )
286
- continue
287
- visit (config )
285
+
286
+ def truncate_skip_length (pipeline : Any ) -> None :
287
+ for step in steps (pipeline ):
288
+ if len (str (step .get ("skip" , "" ))) > 70 :
289
+ step ["skip" ] = step ["skip" ][:70 ]
288
290
289
291
290
292
def handle_sanitizer_skip (pipeline : Any , sanitizer : Sanitizer ) -> None :
291
293
if sanitizer != Sanitizer .none :
292
294
pipeline .setdefault ("env" , {})["CI_SANITIZER" ] = sanitizer .value
293
295
294
- def visit ( step : dict [ str , Any ]) -> None :
296
+ for step in steps ( pipeline ) :
295
297
if step .get ("sanitizer" ) == "skip" :
296
298
step ["skip" ] = True
297
299
298
300
else :
299
301
300
- def visit ( step : dict [ str , Any ]) -> None :
302
+ for step in steps ( pipeline ) :
301
303
if step .get ("sanitizer" ) == "only" :
302
304
step ["skip" ] = True
303
305
304
- for step in pipeline ["steps" ]:
305
- visit (step )
306
- if "group" in step :
307
- for inner_step in step .get ("steps" , []):
308
- visit (inner_step )
309
-
310
306
311
307
def increase_agents_timeouts (
312
308
pipeline : Any , sanitizer : Sanitizer , coverage : bool
313
309
) -> None :
314
310
if sanitizer != Sanitizer .none or os .getenv ("CI_SYSTEM_PARAMETERS" , "" ) == "random" :
315
-
316
- def visit (step : dict [str , Any ]) -> None :
311
+ for step in steps (pipeline ):
317
312
# Most sanitizer runs, as well as random permutations of system
318
313
# parameters, are slower and need more memory. The default system
319
314
# parameters in CI are chosen to be efficient for execution, while
@@ -359,13 +354,6 @@ def visit(step: dict[str, Any]) -> None:
359
354
agent = "hetzner-x86-64-dedi-48cpu-192gb"
360
355
step ["agents" ] = {"queue" : agent }
361
356
362
- for step in pipeline ["steps" ]:
363
- visit (step )
364
- # Groups can't be nested, so handle them explicitly here instead of recursing
365
- if "group" in step :
366
- for inner_step in step .get ("steps" , []):
367
- visit (inner_step )
368
-
369
357
if coverage :
370
358
pipeline ["env" ]["CI_COVERAGE_ENABLED" ] = 1
371
359
@@ -487,92 +475,81 @@ def switch_jobs_to_aws(pipeline: Any, priority: int) -> None:
487
475
488
476
print (f"Queues stuck in Hetzner, switching to AWS or another arch: { stuck } " )
489
477
490
- def visit (config : Any ) -> None :
491
- if "agents" not in config :
492
- return
478
+ for step in steps (pipeline ):
479
+ # Trigger and Wait steps don't have agents
480
+ if "trigger" in step or "wait" in step or "group" in step :
481
+ continue
493
482
494
- agent = config ["agents" ].get ("queue" , None )
483
+ if "agents" not in step :
484
+ continue
485
+
486
+ agent = step ["agents" ].get ("queue" , None )
495
487
if not agent in stuck :
496
- return
488
+ continue
497
489
498
490
if agent == "hetzner-aarch64-2cpu-4gb" :
499
491
if "hetzner-x86-64-2cpu-4gb" not in stuck :
500
- config ["agents" ]["queue" ] = "hetzner-x86-64-2cpu-4gb"
501
- if config .get ("depends_on" ) == "build-aarch64" :
502
- config ["depends_on" ] = "build-x86_64"
492
+ step ["agents" ]["queue" ] = "hetzner-x86-64-2cpu-4gb"
493
+ if step .get ("depends_on" ) == "build-aarch64" :
494
+ step ["depends_on" ] = "build-x86_64"
503
495
else :
504
- config ["agents" ]["queue" ] = "linux-aarch64"
496
+ step ["agents" ]["queue" ] = "linux-aarch64"
505
497
elif agent == "hetzner-aarch64-4cpu-8gb" :
506
498
if "hetzner-x86-64-4cpu-8gb" not in stuck :
507
- config ["agents" ]["queue" ] = "hetzner-x86-64-4cpu-8gb"
508
- if config .get ("depends_on" ) == "build-aarch64" :
509
- config ["depends_on" ] = "build-x86_64"
499
+ step ["agents" ]["queue" ] = "hetzner-x86-64-4cpu-8gb"
500
+ if step .get ("depends_on" ) == "build-aarch64" :
501
+ step ["depends_on" ] = "build-x86_64"
510
502
else :
511
- config ["agents" ]["queue" ] = "linux-aarch64"
503
+ step ["agents" ]["queue" ] = "linux-aarch64"
512
504
elif agent == "hetzner-aarch64-8cpu-16gb" :
513
505
if "hetzner-x86-64-8cpu-16gb" not in stuck :
514
- config ["agents" ]["queue" ] = "hetzner-x86-64-8cpu-16gb"
515
- if config .get ("depends_on" ) == "build-aarch64" :
516
- config ["depends_on" ] = "build-x86_64"
506
+ step ["agents" ]["queue" ] = "hetzner-x86-64-8cpu-16gb"
507
+ if step .get ("depends_on" ) == "build-aarch64" :
508
+ step ["depends_on" ] = "build-x86_64"
517
509
else :
518
- config ["agents" ]["queue" ] = "linux-aarch64-medium"
510
+ step ["agents" ]["queue" ] = "linux-aarch64-medium"
519
511
520
512
elif agent == "hetzner-aarch64-16cpu-32gb" :
521
513
if "hetzner-x86-64-16cpu-32gb" not in stuck :
522
- config ["agents" ]["queue" ] = "hetzner-x86-64-16cpu-32gb"
523
- if config .get ("depends_on" ) == "build-aarch64" :
524
- config ["depends_on" ] = "build-x86_64"
514
+ step ["agents" ]["queue" ] = "hetzner-x86-64-16cpu-32gb"
515
+ if step .get ("depends_on" ) == "build-aarch64" :
516
+ step ["depends_on" ] = "build-x86_64"
525
517
else :
526
- config ["agents" ]["queue" ] = "linux-aarch64-medium"
518
+ step ["agents" ]["queue" ] = "linux-aarch64-medium"
527
519
528
520
elif agent in ("hetzner-x86-64-4cpu-8gb" , "hetzner-x86-64-2cpu-4gb" ):
529
- config ["agents" ]["queue" ] = "linux-x86_64"
521
+ step ["agents" ]["queue" ] = "linux-x86_64"
530
522
elif agent in ("hetzner-x86-64-8cpu-16gb" , "hetzner-x86-64-16cpu-32gb" ):
531
- config ["agents" ]["queue" ] = "linux-x86_64-medium"
523
+ step ["agents" ]["queue" ] = "linux-x86_64-medium"
532
524
elif agent == "hetzner-x86-64-dedi-2cpu-8gb" :
533
- config ["agents" ]["queue" ] = "linux-x86_64"
525
+ step ["agents" ]["queue" ] = "linux-x86_64"
534
526
elif agent == "hetzner-x86-64-dedi-4cpu-16gb" :
535
- config ["agents" ]["queue" ] = "linux-x86_64-medium"
527
+ step ["agents" ]["queue" ] = "linux-x86_64-medium"
536
528
elif agent in (
537
529
"hetzner-x86-64-dedi-8cpu-32gb" ,
538
530
"hetzner-x86-64-dedi-16cpu-64gb" ,
539
531
):
540
- config ["agents" ]["queue" ] = "linux-x86_64-large"
532
+ step ["agents" ]["queue" ] = "linux-x86_64-large"
541
533
elif agent in (
542
534
"hetzner-x86-64-dedi-32cpu-128gb" ,
543
535
"hetzner-x86-64-dedi-48cpu-192gb" ,
544
536
):
545
- config ["agents" ]["queue" ] = "builder-linux-x86_64"
546
-
547
- for config in pipeline ["steps" ]:
548
- if "trigger" in config or "wait" in config :
549
- # Trigger and Wait steps don't have agents
550
- continue
551
- if "group" in config :
552
- for inner_config in config .get ("steps" , []):
553
- visit (inner_config )
554
- continue
555
- visit (config )
537
+ step ["agents" ]["queue" ] = "builder-linux-x86_64"
556
538
557
539
558
540
def permit_rerunning_successful_steps (pipeline : Any ) -> None :
559
- def visit (step : Any ) -> None :
541
+ for step in steps (pipeline ):
542
+ if "trigger" in step or "wait" in step or "group" in step or "block" in step :
543
+ continue
560
544
step .setdefault ("retry" , {}).setdefault ("manual" , {}).setdefault (
561
545
"permit_on_passed" , True
562
546
)
563
547
564
- for config in pipeline ["steps" ]:
565
- if "trigger" in config or "wait" in config or "block" in config :
566
- continue
567
- if "group" in config :
568
- for inner_config in config .get ("steps" , []):
569
- visit (inner_config )
570
- continue
571
- visit (config )
572
-
573
548
574
549
def set_retry_on_agent_lost (pipeline : Any ) -> None :
575
- def visit (step : Any ) -> None :
550
+ for step in steps (pipeline ):
551
+ if "trigger" in step or "wait" in step or "group" in step or "block" in step :
552
+ continue
576
553
step .setdefault ("retry" , {}).setdefault ("automatic" , []).extend (
577
554
[
578
555
{
@@ -591,15 +568,6 @@ def visit(step: Any) -> None:
591
568
]
592
569
)
593
570
594
- for config in pipeline ["steps" ]:
595
- if "trigger" in config or "wait" in config or "block" in config :
596
- continue
597
- if "group" in config :
598
- for inner_config in config .get ("steps" , []):
599
- visit (inner_config )
600
- continue
601
- visit (config )
602
-
603
571
604
572
def set_default_agents_queue (pipeline : Any ) -> None :
605
573
for step in steps (pipeline ):
@@ -614,19 +582,10 @@ def set_default_agents_queue(pipeline: Any) -> None:
614
582
615
583
616
584
def set_parallelism_name (pipeline : Any ) -> None :
617
- def visit ( step : Any ) -> None :
585
+ for step in steps ( pipeline ) :
618
586
if step .get ("parallelism" , 1 ) > 1 :
619
587
step ["label" ] += " %N"
620
588
621
- for config in pipeline ["steps" ]:
622
- if "trigger" in config or "wait" in config or "block" in config :
623
- continue
624
- if "group" in config :
625
- for inner_config in config .get ("steps" , []):
626
- visit (inner_config )
627
- continue
628
- visit (config )
629
-
630
589
631
590
def check_depends_on (pipeline : Any , pipeline_name : str ) -> None :
632
591
if pipeline_name not in ("test" , "nightly" , "release-qualification" ):
@@ -639,7 +598,7 @@ def check_depends_on(pipeline: Any, pipeline_name: str) -> None:
639
598
# has completed, without waiting for block or wait steps unless those
640
599
# are also explicit dependencies.
641
600
if step .get ("id" ) in ("analyze" , "deploy" , "coverage-pr-analyze" ):
642
- return
601
+ continue
643
602
644
603
if (
645
604
"depends_on" not in step
0 commit comments