Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat: add metadata about CI run to RSS feed entries
Lars Wirzenius committed 1 year ago
commit e69262d1864f4369f105ea96fd9d3f1e683f83c2
parent 0c5eaeb
2 files changed +55 -0
modified ci-broker.md
@@ -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
modified src/pages.rs
@@ -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