feat: produce RSS feed of unfinished CI runs

That's CI runs that have been triggered, are running, but have not
finished.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2025-02-19 17:26:39 +02:00
parent e69262d186
commit 00ca0e8fcc
+22
View File
@@ -40,6 +40,7 @@ use crate::{
const BROKER_RSS: &str = "index.rss";
const FAILURE_RSS: &str = "failed.rss";
const UNFINISHED_RSS: &str = "unfinished.rss";
const CSS: &str = include_str!("radicle-ci.css");
const REFERESH_INTERVAL: &str = "300";
const UPDATE_INTERVAL: Duration = Duration::from_secs(60);
@@ -627,6 +628,22 @@ impl PageData {
Ok(channel.build())
}
fn unfinished_as_rss(&self) -> Result<Channel, PageError> {
let mut channel = ChannelBuilder::default();
channel
.title("Radicle CI broker run information")
.description("All CI runs known to this instance of the Radicle CI broker.")
.link("FIXME:link");
for (_alias, repo_id) in self.repos() {
for run in self.runs(repo_id) {
if run.state() == RunState::Triggered || run.state() == RunState::Running {
channel.item(Self::rss_item_from_run(run)?);
}
}
}
Ok(channel.build())
}
fn rss_item_from_run(run: &Run) -> Result<Item, PageError> {
let mut guid = Guid::default();
guid.set_value(run.broker_run_id().to_string());
@@ -857,6 +874,11 @@ impl StatusPage {
let channel = data.failed_as_rss()?;
let rss = channel.to_string();
Self::write_file(&filename, &rss)?;
let filename = dirname.join(UNFINISHED_RSS);
let channel = data.unfinished_as_rss()?;
let rss = channel.to_string();
Self::write_file(&filename, &rss)?;
}
Ok(())
}