From 4a59779e51c8c9da7a02bf8c70a67df0d1654996 Mon Sep 17 00:00:00 2001 From: Allison Piper Date: Mon, 22 Apr 2024 23:10:25 +0000 Subject: [PATCH] Use more sensible job ordering --- ci/compute-matrix.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ci/compute-matrix.py b/ci/compute-matrix.py index 8e9d2d26a3b..9f2d19e70de 100755 --- a/ci/compute-matrix.py +++ b/ci/compute-matrix.py @@ -60,6 +60,7 @@ import copy import json import os +import re import sys import yaml @@ -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