Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
refactor: use serde-yml instead of serde-yaml
Lars Wirzenius committed 1 year ago
commit 0eecd7b6e4c2ace7760f32119449a7916f67f752
parent dff40e2
6 files changed +11 -30
modified Cargo.lock
@@ -2120,7 +2120,7 @@ dependencies = [
 "radicle-git-ext 0.9.0",
 "serde",
 "serde_json",
-
 "serde_yaml",
+
 "serde_yml",
 "tempfile",
 "thiserror 2.0.12",
 "time",
@@ -2441,19 +2441,6 @@ dependencies = [
]

[[package]]
-
name = "serde_yaml"
-
version = "0.9.34+deprecated"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
-
dependencies = [
-
 "indexmap",
-
 "itoa",
-
 "ryu",
-
 "serde",
-
 "unsafe-libyaml",
-
]
-

-
[[package]]
name = "serde_yml"
version = "0.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3144,12 +3131,6 @@ dependencies = [
]

[[package]]
-
name = "unsafe-libyaml"
-
version = "0.2.11"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
-

-
[[package]]
name = "url"
version = "2.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
modified Cargo.toml
@@ -19,7 +19,7 @@ radicle-ci-broker = "0.15.1"
radicle-git-ext = "0.9.0"
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
-
serde_yaml = "0.9.27"
+
serde_yml = "0.0.12"
tempfile = "3.19.1"
thiserror = "2.0.12"
time = { version = "0.3.41", features = ["formatting", "macros"] }
modified src/config.rs
@@ -38,7 +38,7 @@ impl Config {
    pub fn read(filename: &Path) -> Result<Self, ConfigError> {
        let file = std::fs::File::open(filename)
            .map_err(|e| ConfigError::ReadConfig(filename.into(), e))?;
-
        serde_yaml::from_reader(&file).map_err(|e| ConfigError::ParseConfig(filename.into(), e))
+
        serde_yml::from_reader(&file).map_err(|e| ConfigError::ParseConfig(filename.into(), e))
    }

    /// Return configuration serialized to JSON.
@@ -55,7 +55,7 @@ pub enum ConfigError {
    ReadConfig(PathBuf, #[source] std::io::Error),

    #[error("failed to parse configuration file as YAML: {0}")]
-
    ParseConfig(PathBuf, #[source] serde_yaml::Error),
+
    ParseConfig(PathBuf, #[source] serde_yml::Error),

    #[error("failed to get environment variable {0}")]
    GetEnv(&'static str, #[source] std::env::VarError),
modified src/runlog.rs
@@ -212,7 +212,7 @@ impl RunLog {
        }

        if let Some(runspec) = &self.runspec {
-
            let text = serde_yaml::to_string(&runspec).map_err(RunLogError::RunSpec)?;
+
            let text = serde_yml::to_string(&runspec).map_err(RunLogError::RunSpec)?;
            body.push_child(toc.push(Element::new(Tag::Span).with_child(
                Element::new(Tag::Code).with_child(Element::new(Tag::Code).with_text(RUNSPEC_PATH)),
            )));
@@ -363,5 +363,5 @@ pub enum RunLogError {
    Write(PathBuf, #[source] std::io::Error),

    #[error("failed to serialize run spec to YAML")]
-
    RunSpec(#[source] serde_yaml::Error),
+
    RunSpec(#[source] serde_yml::Error),
}
modified src/runspec.rs
@@ -19,7 +19,7 @@ impl RunSpec {
    pub fn from_file(filename: &Path) -> Result<Self, RunSpecError> {
        let file = std::fs::File::open(filename)
            .map_err(|e| RunSpecError::ReadRunSpec(filename.into(), e))?;
-
        let runspec: RunSpec = serde_yaml::from_reader(&file)
+
        let runspec: RunSpec = serde_yml::from_reader(&file)
            .map_err(|e| RunSpecError::ParseRunSpec(filename.into(), e))?;
        Ok(runspec)
    }
@@ -31,7 +31,7 @@ pub enum RunSpecError {
    ReadRunSpec(PathBuf, #[source] std::io::Error),

    #[error("failed to parse run spec as YAML: {0}")]
-
    ParseRunSpec(PathBuf, #[source] serde_yaml::Error),
+
    ParseRunSpec(PathBuf, #[source] serde_yml::Error),

    #[error(transparent)]
    Log(#[from] LogError),
modified tests/integration.rs
@@ -350,7 +350,7 @@ impl TestCaseBuilder {
        std::fs::create_dir(git.path().join(".radicle"))?;
        git.write(
            ".radicle/native.yaml",
-
            &serde_yaml::to_string(&runspec).unwrap(),
+
            &serde_yml::to_string(&runspec).unwrap(),
        )?;

        // Commit everything.
@@ -365,7 +365,7 @@ impl TestCaseBuilder {
                log: tmp.join("log.html"),
                base_url: None,
            };
-
            let config = serde_yaml::to_string(&config).unwrap();
+
            let config = serde_yml::to_string(&config).unwrap();
            std::fs::write(filename, config)?;
        } else if let ConfigKind::ValidWithUrl(filename, url) = &config {
            let config = Config {
@@ -373,7 +373,7 @@ impl TestCaseBuilder {
                log: tmp.join("log.html"),
                base_url: Some(url.into()),
            };
-
            let config = serde_yaml::to_string(&config).unwrap();
+
            let config = serde_yml::to_string(&config).unwrap();
            std::fs::write(filename, config)?;
        }