484
484
_SHARD_RE = re .compile (r"(.+) \(shard (\d+)\)" )
485
485
_SLOWEST_N_TARGETS = 20
486
486
487
+ # Pipelines with elevated priority. Values are project slugs,
488
+ # i.e. "org_slug/pipeline_slug".
489
+ _PRIORITY_PIPELINES = frozenset (["bazel/google-bazel-presubmit" ])
490
+
487
491
488
492
class BuildkiteException (Exception ):
489
493
"""
@@ -580,11 +584,13 @@ def _open_url(self, url, params=[], retries=5):
580
584
if retry_after :
581
585
wait_time = int (retry_after )
582
586
else :
583
- wait_time = ( 2 ** attempt ) # Exponential backoff if no RateLimit-Reset header
587
+ wait_time = 2 ** attempt # Exponential backoff if no RateLimit-Reset header
584
588
585
589
time .sleep (wait_time )
586
590
else :
587
- raise BuildkiteException ("Failed to open {}: {} - {}" .format (url , ex .code , ex .reason ))
591
+ raise BuildkiteException (
592
+ "Failed to open {}: {} - {}" .format (url , ex .code , ex .reason )
593
+ )
588
594
589
595
raise BuildkiteException (f"Failed to open { url } after { retries } retries." )
590
596
@@ -968,7 +974,9 @@ def load_imported_tasks(import_name, http_url, file_config, bazel_version):
968
974
else :
969
975
file_config = new_path
970
976
971
- imported_config = load_config (http_url = http_url , file_config = file_config , allow_imports = False , bazel_version = bazel_version )
977
+ imported_config = load_config (
978
+ http_url = http_url , file_config = file_config , allow_imports = False , bazel_version = bazel_version
979
+ )
972
980
973
981
namespace = import_name .partition ("." )[0 ]
974
982
tasks = {}
@@ -2669,7 +2677,9 @@ def terminate_background_process(process):
2669
2677
process .kill ()
2670
2678
2671
2679
2672
- def create_step (label , commands , platform , shards = 1 , soft_fail = None , concurrency = None , concurrency_group = None ):
2680
+ def create_step (
2681
+ label , commands , platform , shards = 1 , soft_fail = None , concurrency = None , concurrency_group = None
2682
+ ):
2673
2683
if "docker-image" in PLATFORMS [platform ]:
2674
2684
step = create_docker_step (
2675
2685
label ,
@@ -2685,6 +2695,12 @@ def create_step(label, commands, platform, shards=1, soft_fail=None, concurrency
2685
2695
"agents" : {"queue" : PLATFORMS [platform ]["queue" ]},
2686
2696
}
2687
2697
2698
+ project_slug = "{}/{}" .format (
2699
+ os .getenv ("BUILDKITE_ORGANIZATION_SLUG" ), os .getenv ("BUILDKITE_PIPELINE_SLUG" )
2700
+ )
2701
+ if project_slug in _PRIORITY_PIPELINES :
2702
+ step ["priority" ] = 1
2703
+
2688
2704
if shards > 1 :
2689
2705
# %N means shard counting starts at 1, not 0
2690
2706
step ["label" ] += " (shard %N)"
@@ -4351,7 +4367,11 @@ def main(argv=None):
4351
4367
runner .add_argument ("--task" , action = "store" , type = str , default = "" )
4352
4368
runner .add_argument ("--file_config" , type = str )
4353
4369
runner .add_argument ("--http_config" , type = str )
4354
- runner .add_argument ("--overwrite_bazel_version" , type = str , help = "Overwrite the bazel version in the config file." )
4370
+ runner .add_argument (
4371
+ "--overwrite_bazel_version" ,
4372
+ type = str ,
4373
+ help = "Overwrite the bazel version in the config file." ,
4374
+ )
4355
4375
runner .add_argument ("--git_repository" , type = str )
4356
4376
runner .add_argument (
4357
4377
"--git_commit" , type = str , help = "Reset the git repository to this commit after cloning it"
@@ -4456,7 +4476,9 @@ def main(argv=None):
4456
4476
old_bazel = task_config .get ("old_bazel" )
4457
4477
if old_bazel :
4458
4478
new_bazel = task_config .get ("bazel" )
4459
- print_collapsed_group (f":bazel: Bazel version overridden from { old_bazel } to { new_bazel } " )
4479
+ print_collapsed_group (
4480
+ f":bazel: Bazel version overridden from { old_bazel } to { new_bazel } "
4481
+ )
4460
4482
4461
4483
execute_commands (
4462
4484
task_config = task_config ,
0 commit comments