From 7b8cc37fdc2dc5d2dd666c508ad8867597610254 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 19 May 2026 17:15:03 +0200 Subject: [PATCH] refactor(config): standardize the workspace on serde_yaml_ng for YAML parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The workspace had two YAML parsers — both forks of the archived `dtolnay/serde-yaml`. `mergify-config` used `serde_norway` for `.mergify.yml`; `mergify-ci` used `serde_yaml_ng` for merge-queue metadata in PR bodies and git notes. Same job, two crates, two transitive `unsafe-libyaml*` trees in Cargo.lock. Standardize on `serde_yaml_ng` for both. The decision is grounded in concrete signal, not vibe: Metric serde_norway serde_yaml_ng ───────────────────────── ───────────── ───────────── Reverse-deps on lib.rs 229 (78 dir.) 618 (349 dir.) GitHub stars 53 109 Last commit 2025-08-04 2025-09-14 Bus factor (recent prs) 1 (solo) merges externals Maintainer statement v0.9.40 title README: explicit "I'm gonna upstream-compat maintain this" intent unsafe-libyaml backend forked ("…- canonical norway") Open since 2024-06-10 2024-05-03 License Apache-2.0 MIT (= upstream) `serde_yaml_ng` wins on every axis that matters for the "will this still be alive in two years" question: three-times the ecosystem adoption, more recent activity, accepts third-party PRs, declares the maintenance commitment in writing, and uses the canonical `unsafe-libyaml` rather than a parallel-fork backend. Functional surface is identical for both of our use shapes — `from_str` to a typed struct for ci, `from_str` to `Value` then convert to `serde_json::Value` for config validation. Migration is purely a rename at the one call site. Cargo.lock drops `serde_norway` and `unsafe-libyaml-norway`. Co-Authored-By: Claude Opus 4.7 Change-Id: If5d28d2c4259127181bace5bafb0ac02c78d8f7b --- Cargo.lock | 21 +-------------------- crates/mergify-config/Cargo.toml | 2 +- crates/mergify-config/src/validate.rs | 4 ++-- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d59f674f..7da1bf26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1100,7 +1100,7 @@ dependencies = [ "mergify-test-support", "serde", "serde_json", - "serde_norway", + "serde_yaml_ng", "temp-env", "tempfile", "tokio", @@ -1823,19 +1823,6 @@ dependencies = [ "zmij", ] -[[package]] -name = "serde_norway" -version = "0.9.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e408f29489b5fd500fab51ff1484fc859bb655f32c671f307dcd733b72e8168c" -dependencies = [ - "indexmap", - "itoa", - "ryu", - "serde", - "unsafe-libyaml-norway", -] - [[package]] name = "serde_yaml_ng" version = "0.10.0" @@ -2153,12 +2140,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" -[[package]] -name = "unsafe-libyaml-norway" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39abd59bf32521c7f2301b52d05a6a2c975b6003521cbd0c6dc1582f0a22104" - [[package]] name = "untrusted" version = "0.9.0" diff --git a/crates/mergify-config/Cargo.toml b/crates/mergify-config/Cargo.toml index e543dd5a..d7da3e78 100644 --- a/crates/mergify-config/Cargo.toml +++ b/crates/mergify-config/Cargo.toml @@ -14,7 +14,7 @@ mergify-core = { path = "../mergify-core" } jsonschema = { version = "0.46", default-features = false } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -serde_norway = "0.9" +serde_yaml_ng = "0.10" url = "2" [dev-dependencies] diff --git a/crates/mergify-config/src/validate.rs b/crates/mergify-config/src/validate.rs index e669ac32..1bdee53c 100644 --- a/crates/mergify-config/src/validate.rs +++ b/crates/mergify-config/src/validate.rs @@ -57,10 +57,10 @@ pub async fn run(explicit_path: Option<&Path>, output: &mut dyn Output) -> Resul fn load_yaml(path: &Path) -> Result { let text = std::fs::read_to_string(path) .map_err(|e| CliError::Configuration(format!("cannot read {}: {e}", path.display())))?; - // Parse as YAML into serde_norway::Value, then convert to JSON + // Parse as YAML into serde_yaml_ng::Value, then convert to JSON // so jsonschema can validate. The conversion is always lossless // for valid Mergify configs (mappings, sequences, scalars). - let yaml_value: serde_norway::Value = serde_norway::from_str(&text) + let yaml_value: serde_yaml_ng::Value = serde_yaml_ng::from_str(&text) .map_err(|e| CliError::Configuration(format!("Invalid YAML in {}: {e}", path.display())))?; // Mergify configs are YAML mappings at the top level; an empty // file deserializes to Null, which we treat as an empty mapping.