Merge "Hideci: handle merge failures"
This commit is contained in:
commit
c095466d82
@ -18,9 +18,14 @@ var hashRegex = /^\#\/c\/[\/\d]+$/
|
|||||||
var ciRegex = /^(.* CI|Jenkins)$/
|
var ciRegex = /^(.* CI|Jenkins)$/
|
||||||
// this regex matches "Patch set #"
|
// this regex matches "Patch set #"
|
||||||
var psRegex = /^Patch Set (\d+):/
|
var psRegex = /^Patch Set (\d+):/
|
||||||
|
// this regex matches merge failure messages
|
||||||
|
var mergeFailedRegex = /^Merge Failed\./
|
||||||
|
// this regex matches the name of CI systems we trust to report merge failures
|
||||||
|
var trustedCIRegex = /^(OpenStack CI|Jenkins)$/
|
||||||
|
|
||||||
ci_find_comments = function() {
|
ci_find_comments = function() {
|
||||||
var comments = [];
|
var comments = [];
|
||||||
|
var last_merge_failure = null;
|
||||||
$("p").each(function() {
|
$("p").each(function() {
|
||||||
var match = psRegex.exec(this.innerHTML);
|
var match = psRegex.exec(this.innerHTML);
|
||||||
if (match !== null) {
|
if (match !== null) {
|
||||||
@ -31,9 +36,45 @@ ci_find_comments = function() {
|
|||||||
top = $(this).parent().parent().parent();
|
top = $(this).parent().parent().parent();
|
||||||
name = $(this).parent().prev().children()[0].innerHTML;
|
name = $(this).parent().prev().children()[0].innerHTML;
|
||||||
}
|
}
|
||||||
comments.push({"name":name, "psnum":psnum, "top":top, "comment":$(this).parent()});
|
// Search this comment for results
|
||||||
|
var comment_object = $(this).parent();
|
||||||
|
var result_list = [];
|
||||||
|
comment_object.find("li.comment_test").each(function(i, li) {
|
||||||
|
var result = {};
|
||||||
|
result["name"] = $(li).find("span.comment_test_name").find("a")[0].innerHTML;
|
||||||
|
result["link"] = $(li).find("span.comment_test_name").find("a")[0];
|
||||||
|
result["result"] = $(li).find("span.comment_test_result")[0];
|
||||||
|
result_list.push(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
var comment = {"name":name, "psnum":psnum, "top":top,
|
||||||
|
"merge_failure":null,
|
||||||
|
"results":result_list,
|
||||||
|
"comment":comment_object};
|
||||||
|
comments.push(comment);
|
||||||
|
|
||||||
|
// Keep a pointer to the most recent merge failure message from
|
||||||
|
// the trusted CI system. If there is a message from the system
|
||||||
|
// after it, drop the reference. This way we end up with a pointer
|
||||||
|
// iff the last comment from the trusted system is a merge failure.
|
||||||
|
if (trustedCIRegex.exec(name) !== null) {
|
||||||
|
if ($(this).next().length>0 &&
|
||||||
|
mergeFailedRegex.exec($(this).next()[0].innerHTML) !== null) {
|
||||||
|
last_merge_failure = comment;
|
||||||
|
} else if (result_list.length>0) {
|
||||||
|
last_merge_failure = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// If the last comment from the trusted system is a merge failure,
|
||||||
|
// mark that comment as a merge failure so it is displayed. (We
|
||||||
|
// want to ignore it if there was a merge failure that was
|
||||||
|
// superceded.)
|
||||||
|
if (last_merge_failure !== null) {
|
||||||
|
last_merge_failure["merge_failure"] = true;
|
||||||
|
}
|
||||||
return comments;
|
return comments;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -43,20 +84,13 @@ ci_update_table = function() {
|
|||||||
var comments = ci_find_comments();
|
var comments = ci_find_comments();
|
||||||
$.each(comments, function(comment_index, comment) {
|
$.each(comments, function(comment_index, comment) {
|
||||||
while (patchsets.length < comment["psnum"]) {
|
while (patchsets.length < comment["psnum"]) {
|
||||||
patchsets.push({});
|
// Whether there is a current merge failure in this
|
||||||
|
// patchset.
|
||||||
|
patchsets.push({"_merge_failure": false});
|
||||||
}
|
}
|
||||||
// Search this comment for results
|
|
||||||
var result_list = [];
|
|
||||||
comment["comment"].find("li.comment_test").each(function(i, li) {
|
|
||||||
var result = {};
|
|
||||||
result["name"] = $(li).find("span.comment_test_name").find("a")[0].innerHTML;
|
|
||||||
result["link"] = $(li).find("span.comment_test_name").find("a")[0];
|
|
||||||
result["result"] = $(li).find("span.comment_test_result")[0];
|
|
||||||
result_list.push(result);
|
|
||||||
});
|
|
||||||
|
|
||||||
// If this comment has results
|
// If this comment has results
|
||||||
if (result_list.length > 0) {
|
if (comment["results"].length > 0) {
|
||||||
// Get the name of the system
|
// Get the name of the system
|
||||||
var name = comment["name"];
|
var name = comment["name"];
|
||||||
// an item in patchsets is a hash of systems
|
// an item in patchsets is a hash of systems
|
||||||
@ -70,10 +104,10 @@ ci_update_table = function() {
|
|||||||
// we preserve what was in the comments), and a
|
// we preserve what was in the comments), and a
|
||||||
// hash of results (so later runs of the same job
|
// hash of results (so later runs of the same job
|
||||||
// on the same patchset override previous results).
|
// on the same patchset override previous results).
|
||||||
system = {"jobs": [], "results": {}}
|
system = {"jobs": [], "results": {}};
|
||||||
systems[name] = system;
|
systems[name] = system;
|
||||||
}
|
}
|
||||||
$.each(result_list, function(i, result) {
|
$.each(comment["results"], function(i, result) {
|
||||||
// For each result, add the name of the job to the
|
// For each result, add the name of the job to the
|
||||||
// ordered list if it isn't there already
|
// ordered list if it isn't there already
|
||||||
if (system["jobs"].indexOf(result["name"]) < 0) {
|
if (system["jobs"].indexOf(result["name"]) < 0) {
|
||||||
@ -83,6 +117,11 @@ ci_update_table = function() {
|
|||||||
system["results"][result["name"]] = result;
|
system["results"][result["name"]] = result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// The merge failure flag will only be set on a comment if it
|
||||||
|
// is the most recent comment and is a merge failure.
|
||||||
|
if (comment["merge_failure"] === true) {
|
||||||
|
patchsets[comment["psnum"]-1]["_merge_failure"] = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (patchsets.length > 0) {
|
if (patchsets.length > 0) {
|
||||||
@ -117,19 +156,23 @@ ci_update_table = function() {
|
|||||||
$(table).empty();
|
$(table).empty();
|
||||||
}
|
}
|
||||||
var patchset = patchsets[patchsets.length-1];
|
var patchset = patchsets[patchsets.length-1];
|
||||||
$.each(patchset, function(name, system) {
|
if (!patchset["_merge_failure"]) {
|
||||||
// Add a header for each system
|
$.each(patchset, function(name, system) {
|
||||||
var header = $("<tr>").append($('<td class="header" colspan="2">'+name+'</td>'));
|
if (name != "_merge_failure") {
|
||||||
$(table).append(header)
|
// Add a header for each system
|
||||||
// Add the results
|
var header = $("<tr>").append($('<td class="header" colspan="2">'+name+'</td>'));
|
||||||
$.each(system["jobs"], function(i, name) {
|
$(table).append(header);
|
||||||
var result = system["results"][name]
|
// Add the results
|
||||||
var tr = $("<tr>");
|
$.each(system["jobs"], function(i, name) {
|
||||||
tr.append($("<td>").append($(result["link"]).clone()));
|
var result = system["results"][name];
|
||||||
tr.append($("<td>").append($(result["result"]).clone()));
|
var tr = $("<tr>");
|
||||||
$(table).append(tr)
|
tr.append($("<td>").append($(result["link"]).clone()));
|
||||||
|
tr.append($("<td>").append($(result["result"]).clone()));
|
||||||
|
$(table).append(tr);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -147,7 +190,8 @@ ci_toggle_visibility = function(comments) {
|
|||||||
comments = ci_find_comments();
|
comments = ci_find_comments();
|
||||||
}
|
}
|
||||||
$.each(comments, function(i, comment) {
|
$.each(comments, function(i, comment) {
|
||||||
if (ciRegex.exec(comment["name"])) {
|
if (ciRegex.exec(comment["name"]) &&
|
||||||
|
!comment["merge_failure"]) {
|
||||||
comment["top"].toggle();
|
comment["top"].toggle();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user