Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat: store job ID in run value, if known
Lars Wirzenius committed 8 months ago
commit 8ed719a53fe9362c8f12e1513b68df889b048110
parent 5bb6cc1
2 files changed +16 -1
modified src/broker.rs
@@ -125,7 +125,9 @@ impl Broker {
        // it. We won't do anything about a failure, as there's
        // nothing useful we can do about it, as long as we let CI
        // run, which want to do.
-
        create_job(trigger.repo(), oid);
+
        if let Some(job_id) = create_job(trigger.repo(), oid) {
+
            run.set_job_id(job_id);
+
        }

        // We run the adapter, but if that fails, we just
        // log the error. The `Run` value records the
modified src/run.rs
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};

use radicle::git::Oid;
use radicle::prelude::RepoId;
+
use radicle_job::JobId;

use crate::msg::{Revision, RunId, RunResult};

@@ -59,6 +60,7 @@ impl RunBuilder {
            broker_run_id,
            adapter_run_id: None,
            adapter_info_url: None,
+
            job_id: None,
            repo_id,
            repo_name,
            timestamp,
@@ -74,6 +76,7 @@ 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 +87,16 @@ pub struct Run {
}

impl Run {
+
    /// Set job COB ID.
+
    pub fn set_job_id(&mut self, job_id: JobId) {
+
        self.job_id = Some(job_id);
+
    }
+

+
    /// Job COB ID, if set.
+
    pub fn job_id(&self) -> Option<JobId> {
+
        self.job_id
+
    }
+

    /// Return the repo alias.
    pub fn repo_alias(&self) -> &str {
        &self.repo_name