diff --git a/src/ci/citool/src/jobs.rs b/src/ci/citool/src/jobs.rs index 5600d7b4db59b..60cbf50c7a3a1 100644 --- a/src/ci/citool/src/jobs.rs +++ b/src/ci/citool/src/jobs.rs @@ -85,14 +85,20 @@ impl JobDatabase { } pub fn load_job_db(db: &str) -> anyhow::Result { - let mut db: Value = serde_yaml::from_str(db)?; + let mut db: Value = serde_yaml::from_str(db).context("failed to parse YAML content")?; // We need to expand merge keys (<<), because serde_yaml can't deal with them // `apply_merge` only applies the merge once, so do it a few times to unwrap nested merges. - db.apply_merge()?; - db.apply_merge()?; - let db: JobDatabase = serde_yaml::from_value(db)?; + let apply_merge = |db: &mut Value| -> anyhow::Result<()> { + db.apply_merge().context("failed to apply merge keys") + }; + + // Apply merge twice to handle nested merges + apply_merge(&mut db)?; + apply_merge(&mut db)?; + + let db: JobDatabase = serde_yaml::from_value(db).context("failed to parse job database")?; Ok(db) }