feat: add metadata about CI run to RSS feed entries

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2025-02-19 17:26:39 +02:00
parent 0c5eaeb8fa
commit e69262d186
2 changed files with 55 additions and 0 deletions
+1
View File
@@ -2176,6 +2176,7 @@ then file reports/status.json exists
when I run jq .event_queue_length reports/status.json
then stdout is exactly "0\n"
~~~
# Acceptance criteria for upgrades
_What:_ The node operator can safely upgrade the CI broker. At the
+54
View File
@@ -646,10 +646,22 @@ impl PageData {
parse_timestamp(&ts).map_err(|err| PageError::RssTimestamp(ts.clone(), err))?;
let ts = rfc822_timestamp(parsed).map_err(|err| PageError::RssTimestamp(ts, err))?;
let entry = RssEntry {
repoid: run.repo_id(),
commit: match run.whence() {
Whence::Branch { commit, .. } => *commit,
Whence::Patch { commit, .. } => *commit,
},
info_url: run.adapter_info_url().map(String::from),
status: run.state(),
result: run.result().cloned(),
};
let mut item = ItemBuilder::default()
.title(Some(title))
.guid(Some(guid))
.pub_date(Some(ts))
.content(entry.to_html().serialize())
.build();
if let Some(url) = run.adapter_info_url() {
@@ -660,6 +672,48 @@ impl PageData {
}
}
struct RssEntry {
repoid: RepoId,
commit: Oid,
info_url: Option<String>,
status: RunState,
result: Option<RunResult>,
}
impl RssEntry {
fn to_html(&self) -> Element {
Element::new(Tag::Div)
.with_class("ci_run")
.with_child(
Element::new(Tag::Span)
.with_class("repoid")
.with_text(&self.repoid.to_string()),
)
.with_child(
Element::new(Tag::Span)
.with_class("commit")
.with_text(&self.commit.to_string()),
)
.with_child(
Element::new(Tag::Span)
.with_class("info_url")
.with_text(self.info_url.as_deref().unwrap_or("")),
)
.with_child(
Element::new(Tag::Span)
.with_class("status")
.with_text(&self.status.to_string()),
)
.with_child(Element::new(Tag::Span).with_class("result").with_text(
match &self.result {
None => "undetermined",
Some(RunResult::Success) => "success",
Some(RunResult::Failure) => "failure",
},
))
}
}
/// Data for status pages for CI broker.
///
/// There is a "front page" with status about the broker, and a list