Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
fix: undo rename of run info field id
Lars Wirzenius committed 2 years ago
commit 6627cd29e0e3fd789743e0bfa713e2fbf175bdc9
parent 87f91e2
4 files changed +18 -3
modified Cargo.toml
@@ -2,6 +2,7 @@
name = "radicle-native-ci"
version = "0.1.0"
edition = "2021"
+
default-run = "radicle-native-ci"

[dependencies]
html-page = "0.1.0"
added src/bin/run_info.rs
@@ -0,0 +1,14 @@
+
use std::path::Path;
+

+
use radicle_native_ci::{report::ReportError, runinfo::RunInfo};
+

+
/// The main program.
+
fn main() {
+
    let x = read_file_info(Path::new("run.yaml")).expect("parse yaml");
+
    println!("{:#?}", x);
+
}
+

+
fn read_file_info(filename: &Path) -> Result<RunInfo, ReportError> {
+
    let yaml = std::fs::read(filename).map_err(|e| ReportError::ReadRunInfo(filename.into(), e))?;
+
    serde_yaml::from_slice(&yaml).map_err(|e| ReportError::DeserializeRunInfo(filename.into(), e))
+
}
modified src/report.rs
@@ -76,7 +76,7 @@ fn list_runs(repos: &[&str], run_infos: &[RunInfo]) -> Document {

            let run_id = Element::new(Tag::Code)
                .with_class("run_id")
-
                .with_text(&ri.run_id);
+
                .with_text(&ri.id);

            let timestamp = Element::new(Tag::Span)
                .with_class("timestamp")
modified src/runinfo.rs
@@ -18,7 +18,7 @@ pub struct RunInfo {
    pub commit: String,

    /// Identifier for the CI run.
-
    pub run_id: String,
+
    pub id: String,

    /// Result of the CI run.
    pub result: RunResult,
@@ -96,7 +96,7 @@ impl RunInfoBuilder {
        Ok(RunInfo {
            repo: self.repo.map(|x| x.to_string()).unwrap_or("".into()),
            commit: self.commit.map(|x| x.to_string()).unwrap_or("".into()),
-
            run_id: self.run_id.unwrap_or("<unknown>".into()),
+
            id: self.run_id.unwrap_or("<unknown>".into()),
            result: self
                .result
                .ok_or(RunInfoError::MissingInfo("result".into()))?,