From 376582d98b2d3843fc33858aa3a15c35e4124ab0 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 12 May 2016 13:00:52 -0400 Subject: [PATCH] Create stable order for CI results stable One of the regressions in our pipeline fix was that Jenkins no longer ends up on top of the results list. From a UX perspective pinning first party results to the top of the list was very important, because that's the first thing most people are looking for. This reintroduces that, plus creates a stable (alphabetic) ordering of all non first party reporters so that we get a stable reporting order, and not an order that is merely based on who showed up first. Change-Id: Idd38a047bc73bfe3d7ecc89291c10c0fefbfe665 --- .../openstack_project/files/gerrit/hideci.js | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/openstack_project/files/gerrit/hideci.js b/modules/openstack_project/files/gerrit/hideci.js index 03f6df0bbf..4f91d3da14 100644 --- a/modules/openstack_project/files/gerrit/hideci.js +++ b/modules/openstack_project/files/gerrit/hideci.js @@ -23,6 +23,8 @@ var psRegex = /^(Uploaded patch set|Patch Set) (\d+)(:|\.)/; var mergeFailedRegex = /Merge Failed\./; // this regex matches the name of CI systems we trust to report merge failures var trustedCIRegex = /^(OpenStack CI|Jenkins)$/; +// this regex matches the name+pipeline that we want at the top of the CI list +var firstPartyCI = /^Jenkins/; // this regex matches the pipeline markup var pipelineNameRegex = /Build \w+ \((\w+) pipeline\)/; // The url to full status information on running jobs @@ -156,9 +158,32 @@ var ci_group_by_ci_pipeline = function(current, comments) { } } + function sort_by_name(a,b) { + if (a[0] < b[0]) + return -1; + else if (a[0] > b[0]) + return 1; + else + return 0; + } + var results = []; + var notfirstparty = []; + // we want to separate out first party CI results to always be the + // top of the list, and third party CI to come after, so that + // hunting for first party CI isn't tough. for (i = 0; i < ci_pipelines.length; i++) { - results.push([ci_pipelines[i], ci_pipeline_comments[i]]); + if (firstPartyCI.test(ci_pipelines[i])) { + results.push([ci_pipelines[i], ci_pipeline_comments[i]]); + } else { + notfirstparty.push([ci_pipelines[i], ci_pipeline_comments[i]]); + } + } + + notfirstparty.sort(sort_by_name); + + for (i = 0; i < notfirstparty.length; i++) { + results.push(notfirstparty[i]); } return results; };