request the review classifier's review when a PR's head moves
The router gets a request_reviewer node and a pull_request_sync source; the built-in head-classifier flow asks swarm-controller, over $SWARM.router.sink.request-reviewer, to request review-classifier on every push, unless its review of the head already stands. The controller subscribes to pull_request_sync on its pull-request hook and answers the router; nats-auth grants the router the publish and the controller the subscribe.
This commit is contained in:
parent
463c5cbfcc
commit
0b1669a364
20 changed files with 1231 additions and 64 deletions
|
|
@ -188,19 +188,28 @@ mod tests {
|
|||
#[test]
|
||||
fn with_no_document_the_router_runs_the_builtins() {
|
||||
let mut f = Flows::builtins();
|
||||
assert_eq!(ids(&f), ["assigned", "unassigned", "closed"]);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
f.apply(Read::Absent);
|
||||
assert_eq!(ids(&f), ["assigned", "unassigned", "closed"]);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
// An empty document is the same.
|
||||
f.apply(at(1, doc(&[], &[])));
|
||||
assert_eq!(ids(&f), ["assigned", "unassigned", "closed"]);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_document_switches_builtins_off_and_adds_custom_flows() {
|
||||
let mut f = Flows::builtins();
|
||||
f.apply(at(1, doc(&["unassigned"], &["triage"])));
|
||||
assert_eq!(ids(&f), ["assigned", "closed", "triage"]);
|
||||
assert_eq!(ids(&f), ["assigned", "closed", "head-classifier", "triage"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -208,7 +217,7 @@ mod tests {
|
|||
let mut f = Flows::builtins();
|
||||
f.apply(at(1, doc(&["closed"], &["triage"])));
|
||||
let before = ids(&f).join(",");
|
||||
assert_eq!(before, "assigned,unassigned,triage");
|
||||
assert_eq!(before, "assigned,unassigned,head-classifier,triage");
|
||||
for bad in [
|
||||
junk(2, b"not json"),
|
||||
junk(3, br#"{"version":2,"flows":[]}"#),
|
||||
|
|
@ -221,14 +230,20 @@ mod tests {
|
|||
// The next good revision replaces them: the control that the bad
|
||||
// ones were kept out by being bad, not by the loader being stuck.
|
||||
f.apply(at(5, doc(&[], &[])));
|
||||
assert_eq!(ids(&f), ["assigned", "unassigned", "closed"]);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bad_first_document_is_the_builtins_not_nothing() {
|
||||
let mut f = Flows::builtins();
|
||||
f.apply(junk(1, br#"{"version":9}"#));
|
||||
assert_eq!(ids(&f), ["assigned", "unassigned", "closed"]);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -236,7 +251,10 @@ mod tests {
|
|||
let mut f = Flows::builtins();
|
||||
f.apply(at(1, doc(&["closed"], &["triage"])));
|
||||
f.apply(Read::Absent);
|
||||
assert_eq!(ids(&f), ["assigned", "unassigned", "closed"]);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -254,6 +272,9 @@ mod tests {
|
|||
revision: 1,
|
||||
bytes: serde_json::to_vec(&d).unwrap(),
|
||||
});
|
||||
assert_eq!(ids(&f), ["assigned", "unassigned", "closed"]);
|
||||
assert_eq!(
|
||||
ids(&f),
|
||||
["assigned", "unassigned", "closed", "head-classifier"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue