Skip to content

Commit

Permalink
Use more sensible job ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
alliepiper committed Apr 22, 2024
1 parent 4cf82eb commit 4a59779
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ci/compute-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import copy
import json
import os
import re
import sys
import yaml

Expand Down Expand Up @@ -347,15 +348,19 @@ def finalize_workflow_dispatch_groups(workflow_dispatch_groups_orig):
elif not group_json['two_stage']:
del group_json['two_stage']

# Natural sort impl (handles embedded numbers in strings, case insensitive)
def natural_sort_key(key):
return [int(text) if text.isdigit() else text.lower() for text in re.split('(\d+)', key)]

# Sort the dispatch groups by name:
workflow_dispatch_groups = dict(sorted(workflow_dispatch_groups.items()))
workflow_dispatch_groups = dict(sorted(workflow_dispatch_groups.items(), key=lambda x: natural_sort_key(x[0])))

# Sort the jobs within each dispatch group:
for group_name, group_json in workflow_dispatch_groups.items():
if 'standalone' in group_json:
group_json['standalone'] = sorted(group_json['standalone'], key=lambda x: x['name'])
group_json['standalone'] = sorted(group_json['standalone'], key=lambda x: natural_sort_key(x['name']))
if 'two_stage' in group_json:
group_json['two_stage'] = sorted(group_json['two_stage'], key=lambda x: x['producers'][0]['name'])
group_json['two_stage'] = sorted(group_json['two_stage'], key=lambda x: natural_sort_key(x['producers'][0]['name']))

# Count the total number of jobs:
total_jobs = 0
Expand Down

0 comments on commit 4a59779

Please sign in to comment.