diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-18 10:13:39 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-18 10:13:39 +0800 |
| commit | 8ea8e13f1a6b2a2942b78127e23d6783c5188ca5 (patch) | |
| tree | 01cc8dde8cb8c90529c8d5f66dc57a08ed7cdc26 /mingling_ci/src/res | |
| parent | 570b2bc1710c0ab8a68ad69a6121144e4f5e3aca (diff) | |
refactor(ci-new): generalize report entries from packages to items
Rename package-based terminology and structures to item-based, allowing
arbitrary items with associated locations instead of only crate
packages.
Locations are now carried through report files and included in generated
reports, with the fallback to `—` removed.
Diffstat (limited to 'mingling_ci/src/res')
| -rw-r--r-- | mingling_ci/src/res/collect_logs.rs | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/mingling_ci/src/res/collect_logs.rs b/mingling_ci/src/res/collect_logs.rs index 7c5b375..6017168 100644 --- a/mingling_ci/src/res/collect_logs.rs +++ b/mingling_ci/src/res/collect_logs.rs @@ -18,17 +18,20 @@ pub struct GitInfo { /// Parsed contents of the collect directory. #[derive(Default, Clone)] pub struct ResCollectLogs { - /// `(task, package) -> os -> ok` + /// `(task, item) -> os -> ok` pub statuses: BTreeMap<(String, String), BTreeMap<String, bool>>, - /// `(task, os, package) -> stripped error output` + /// `(task, item) -> location` + pub locations: BTreeMap<(String, String), String>, + /// `(task, os, item) -> stripped error output (location line removed)` pub err_outputs: BTreeMap<(String, String, String), String>, pub git: GitInfo, } impl ResCollectLogs { /// Reads the flat `collect/` directory — aggregate `{task}.{os}.ok` files - /// (one package per line) and per-package `{task}.{os}.{package}.err` - /// files — plus the git info. + /// (`item` or `item = location` per line) and per-item + /// `{task}.{os}.{item}.err` files (first line is the location) — plus the + /// git info. #[must_use] pub fn read() -> Self { let mut logs = Self::default(); @@ -37,23 +40,33 @@ impl ResCollectLogs { for entry in entries.flatten() { let file_name = entry.file_name().to_string_lossy().into_owned(); if let Some((task, os)) = parse_ok_name(&file_name) { - // Aggregate success file: one package name per line. + // Aggregate success file: `item` or `item = location` per line. if let Ok(content) = std::fs::read_to_string(entry.path()) { - for package in content.lines().filter(|l| !l.is_empty()) { + for line in content.lines().filter(|l| !l.is_empty()) { + let (item, location) = line + .split_once('=') + .map_or((line, ""), |(name, loc)| (name.trim(), loc.trim())); logs.statuses - .entry((task.clone(), package.to_string())) + .entry((task.clone(), item.to_string())) .or_default() .insert(os.clone(), true); + logs.locations + .insert((task.clone(), item.to_string()), location.to_string()); } } - } else if let Some((task, os, package)) = parse_err_name(&file_name) { + } else if let Some((task, os, item)) = parse_err_name(&file_name) { + let content = std::fs::read_to_string(entry.path()).unwrap_or_default(); + let mut lines = content.splitn(2, '\n'); + let location = lines.next().unwrap_or_default().to_string(); + let output = lines.next().unwrap_or_default().to_string(); logs.statuses - .entry((task.clone(), package.clone())) + .entry((task.clone(), item.clone())) .or_default() .insert(os.clone(), false); - let err = std::fs::read_to_string(entry.path()).unwrap_or_default(); + logs.locations + .insert((task.clone(), item.clone()), location); logs.err_outputs - .insert((task, os, package), strip_ansi(&err)); + .insert((task, os, item), strip_ansi(&output)); } } } |
