Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat: say run timed out on report page if that happened
Lars Wirzenius committed 7 months ago
commit 845a86c04f779fea9955d2e9635570a698e33e54
parent 6959f65
3 files changed +34 -11
modified src/adapter.rs
@@ -149,6 +149,10 @@ impl Adapter {
        run.set_state(RunState::Finished);
        db.update_run(run).map_err(AdapterError::UpdateRun)?;

+
        if matches!(x, Err(AdapterError::FailedTimeout)) {
+
            run.set_timed_out();
+
        }
+

        x
    }

modified src/pages.rs
@@ -370,7 +370,20 @@ impl PageData {
        let mut runs = self.runs(rid);
        runs.sort_by_cached_key(|run| run.timestamp());
        runs.reverse();
+

        for run in runs {
+
            let result = if let Some(result) = run.result() {
+
                result.to_string()
+
            } else {
+
                "unknown".into()
+
            };
+
            let mut status = Element::new(Tag::Span)
+
                .with_class(&result)
+
                .with_text(&result);
+
            if run.timed_out() {
+
                status.push_text(" (timed out)");
+
            }
+

            let current = match run.state() {
                RunState::Triggered => Element::new(Tag::Span)
                    .with_attribute("state", "triggered")
@@ -378,16 +391,7 @@ impl PageData {
                RunState::Running => Element::new(Tag::Span)
                    .with_class("running)")
                    .with_text("running"),
-
                RunState::Finished => {
-
                    let result = if let Some(result) = run.result() {
-
                        result.to_string()
-
                    } else {
-
                        "unknown".into()
-
                    };
-
                    Element::new(Tag::Span)
-
                        .with_class(&result)
-
                        .with_text(&result)
-
                }
+
                RunState::Finished => status,
            };

            table.push_child(
modified src/run.rs
@@ -67,6 +67,7 @@ impl RunBuilder {
            whence,
            state: RunState::Triggered,
            result: None,
+
            timed_out: None,
        }
    }
}
@@ -76,7 +77,6 @@ pub struct Run {
    broker_run_id: RunId,
    adapter_run_id: Option<RunId>,
    adapter_info_url: Option<String>,
-
    job_id: Option<JobId>,
    repo_id: RepoId,
    #[serde(alias = "repo_alias")]
    repo_name: String,
@@ -84,6 +84,11 @@ pub struct Run {
    whence: Whence,
    state: RunState,
    result: Option<RunResult>,
+

+
    // These fields need to be options we can de-serialize from old
+
    // runs in the database.
+
    job_id: Option<JobId>,
+
    timed_out: Option<bool>,
}

impl Run {
@@ -167,6 +172,16 @@ impl Run {
    pub fn result(&self) -> Option<&RunResult> {
        self.result.as_ref()
    }
+

+
    /// Mark run as having timed out.
+
    pub fn set_timed_out(&mut self) {
+
        self.timed_out = Some(true);
+
    }
+

+
    /// Was run marked as having timed out?
+
    pub fn timed_out(&self) -> bool {
+
        self.timed_out == Some(true)
+
    }
}

/// State of CI run.