hive-c0re: widen nix stderr predicate to cover error:/evaluation warning:, add tests
This commit is contained in:
parent
25893d0f95
commit
70644cb004
3 changed files with 78 additions and 14 deletions
|
|
@ -806,7 +806,7 @@ pub async fn prebuild_toplevel(name: &str, flake_ref: &str, node_id: Option<u64>
|
|||
let pump_stderr = tokio::spawn(async move {
|
||||
let mut lines = BufReader::new(stderr).lines();
|
||||
while let Ok(Some(line)) = lines.next_line().await {
|
||||
if is_real_nix_warning(&line) {
|
||||
if is_actionable_nix_line(&line) {
|
||||
tracing::warn!(target: "nix-prebuild", cmdline = %stderr_cmdline, "{line}");
|
||||
} else {
|
||||
tracing::info!(target: "nix-prebuild", cmdline = %stderr_cmdline, "{line}");
|
||||
|
|
@ -893,19 +893,26 @@ pub fn ensure_agent_runtime_dir(name: &str) -> Result<()> {
|
|||
.with_context(|| format!("create agent runtime dir {}", dir.display()))
|
||||
}
|
||||
|
||||
/// Whether a `nix`/`nixos-container` stderr line is an actual warning
|
||||
/// (nix's own convention: a genuine warning starts with `warning:`) rather
|
||||
/// than routine progress chatter (`copying N paths…`, `fetching git
|
||||
/// input…`, `structuredAttrs is enabled`, …) — nix writes the latter to
|
||||
/// stderr too, and it dwarfs the former in volume.
|
||||
fn is_real_nix_warning(line: &str) -> bool {
|
||||
line.trim_start().starts_with("warning:")
|
||||
/// Whether a `nix`/`nixos-container` stderr line is worth WARN (nix's own
|
||||
/// warnings and errors) rather than routine progress chatter (`copying N
|
||||
/// paths…`, `fetching git input…`, `structuredAttrs is enabled`, …) — nix
|
||||
/// writes the latter to stderr too, and it dwarfs the former in volume.
|
||||
/// Matches nix's own prefixes (`warning:`, `evaluation warning:`,
|
||||
/// `error:`) rather than only `warning:`, so a real build failure
|
||||
/// (`error: builder for '...' failed`, `error: 1 dependencies ... failed
|
||||
/// to build`) never gets buried at INFO alongside the chatter.
|
||||
fn is_actionable_nix_line(line: &str) -> bool {
|
||||
let trimmed = line.trim_start();
|
||||
trimmed.starts_with("warning:")
|
||||
|| trimmed.starts_with("evaluation warning:")
|
||||
|| trimmed.starts_with("error:")
|
||||
}
|
||||
|
||||
/// Build the per-line callback for `create_container_streaming` /
|
||||
/// `update_container_streaming`. Both ops share identical dispatch logic
|
||||
/// (stdout → info + `append_stdout`, stderr → warn + `append_stderr`); this
|
||||
/// helper avoids duplicating that match body across the two call sites.
|
||||
/// (stdout → info + `append_stdout`, stderr → warn for a nix warning/error
|
||||
/// and info otherwise + `append_stderr`); this helper avoids duplicating
|
||||
/// that match body across the two call sites.
|
||||
fn make_log_callback(
|
||||
logs: Option<std::sync::Arc<crate::build_logs::BuildLogs>>,
|
||||
log_id: Option<i64>,
|
||||
|
|
@ -920,7 +927,7 @@ fn make_log_callback(
|
|||
}
|
||||
}
|
||||
PrivStream::Stderr => {
|
||||
if is_real_nix_warning(line) {
|
||||
if is_actionable_nix_line(line) {
|
||||
tracing::warn!(target: "nixos-container", cmdline = %cmdline, "{line}");
|
||||
} else {
|
||||
tracing::info!(target: "nixos-container", cmdline = %cmdline, "{line}");
|
||||
|
|
|
|||
Loading…
Reference in a new issue