ci: improve citool job db errors

This commit is contained in:
MarcoIeni 2025-05-21 18:50:01 +02:00
parent c43786c9b7
commit f57a64ae5a
No known key found for this signature in database

View file

@ -85,14 +85,20 @@ impl JobDatabase {
}
pub fn load_job_db(db: &str) -> anyhow::Result<JobDatabase> {
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)
}