only the controller's own comments carry the marker, and a cleared comment says resolved
This commit is contained in:
parent
9fc0e3bf90
commit
701efadfe4
1 changed files with 157 additions and 37 deletions
|
|
@ -67,13 +67,15 @@ pub(crate) trait MetaRepo {
|
|||
body: &str,
|
||||
) -> impl Future<Output = Result<bool>> + Send;
|
||||
/// Rewrite the comments on `pr` of `agent`'s config repo that contain
|
||||
/// `marker` so they contain `cleared`, which lets `marker` be posted again.
|
||||
/// `marker` so they contain `cleared` and end with `resolved`, which lets
|
||||
/// `marker` be posted again. Only the controller's own comments count.
|
||||
fn clear_marker(
|
||||
&self,
|
||||
agent: &str,
|
||||
pr: u64,
|
||||
marker: &str,
|
||||
cleared: &str,
|
||||
resolved: &str,
|
||||
) -> impl Future<Output = Result<usize>> + Send;
|
||||
}
|
||||
|
||||
|
|
@ -106,10 +108,19 @@ impl MetaRepo for forge::Client {
|
|||
pr: u64,
|
||||
marker: &str,
|
||||
cleared: &str,
|
||||
resolved: &str,
|
||||
) -> Result<usize> {
|
||||
crate::jobq::forge_node(
|
||||
"build_meta",
|
||||
forge::Client::clear_marker(self, forge::CONFIG_ORG, agent, pr, marker, cleared),
|
||||
forge::Client::clear_marker(
|
||||
self,
|
||||
forge::CONFIG_ORG,
|
||||
agent,
|
||||
pr,
|
||||
marker,
|
||||
cleared,
|
||||
resolved,
|
||||
),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
@ -227,9 +238,19 @@ async fn report_failure(
|
|||
/// A green build ends the red spell: clear `pr`'s failure marker for `agent`,
|
||||
/// so a later red comments again. A failure is logged and changes nothing
|
||||
/// about the node.
|
||||
async fn clear_failure(head: &impl MetaRepo, pr: u64, agent: &str) {
|
||||
async fn clear_failure(head: &impl MetaRepo, pr: u64, agent: &str, meta_rev: &str) {
|
||||
let resolved = format!(
|
||||
"Resolved: built at `{}`.",
|
||||
meta_rev.get(..12).unwrap_or(meta_rev)
|
||||
);
|
||||
match head
|
||||
.clear_marker(agent, pr, &failure_marker(agent), &cleared_marker(agent))
|
||||
.clear_marker(
|
||||
agent,
|
||||
pr,
|
||||
&failure_marker(agent),
|
||||
&cleared_marker(agent),
|
||||
&resolved,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(cleared) => {
|
||||
|
|
@ -286,6 +307,7 @@ pub(crate) async fn run(
|
|||
Outcome::Failed(error_tail)
|
||||
}
|
||||
Ok(FromMetaReply::Built { out_path, system }) => {
|
||||
let built_rev = meta_rev.clone();
|
||||
let closure = AgentClosure {
|
||||
meta_rev,
|
||||
store_path: out_path.clone(),
|
||||
|
|
@ -295,7 +317,7 @@ pub(crate) async fn run(
|
|||
match queue.record(&agent, &closure).await {
|
||||
Ok(()) => {
|
||||
if let Some(pr) = pr {
|
||||
clear_failure(head, pr, &agent).await;
|
||||
clear_failure(head, pr, &agent, &built_rev).await;
|
||||
}
|
||||
Outcome::Done
|
||||
}
|
||||
|
|
@ -364,10 +386,11 @@ mod tests {
|
|||
pr: u64,
|
||||
marker: &str,
|
||||
cleared: &str,
|
||||
resolved: &str,
|
||||
) -> Result<usize> {
|
||||
let client = self.comments.as_ref().expect("no clear expected");
|
||||
client
|
||||
.clear_marker(forge::CONFIG_ORG, agent, pr, marker, cleared)
|
||||
.clear_marker(forge::CONFIG_ORG, agent, pr, marker, cleared, resolved)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
|
@ -635,6 +658,11 @@ mod tests {
|
|||
posted[0]
|
||||
);
|
||||
assert!(posted[0].1.contains(&cleared_marker("atlas")));
|
||||
assert!(
|
||||
posted[0].1.contains("Resolved: built at `0123456789ab`"),
|
||||
"{:?}",
|
||||
posted[0]
|
||||
);
|
||||
}
|
||||
|
||||
/// A build that got no verdict says nothing about the PR's config, so it
|
||||
|
|
|
|||
Loading…
Reference in a new issue