hive-forge: add ci-runs listing verb, fix ci-log's ambiguous no-log message
This commit is contained in:
parent
55eaebc9cf
commit
56c0602c2f
6 changed files with 204 additions and 59 deletions
|
|
@ -26,6 +26,7 @@ use anyhow::{Result, bail};
|
|||
use clap::Args as ClapArgs;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::ci_common::find_run_by_number;
|
||||
use crate::client::Client;
|
||||
|
||||
#[derive(ClapArgs)]
|
||||
|
|
@ -235,12 +236,38 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
|||
match streamer_logs(client, &stream_path, &args) {
|
||||
Ok(()) => Ok(()),
|
||||
Err(StreamerMiss::StepOutOfRange(msg)) => bail!(msg),
|
||||
Err(StreamerMiss::Unavailable) => bail!(
|
||||
"run #{} job {} returned no log from either the persisted download \
|
||||
or the live streamer — the run may not exist or its logs were \
|
||||
fully purged.",
|
||||
Err(StreamerMiss::Unavailable) => bail!(no_log_message(client, &args)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Both log sources came back empty — tell the caller whether that's
|
||||
/// because the run doesn't exist at all, or because it does but genuinely
|
||||
/// has no log yet (queued, mid-run with nothing buffered, or purged).
|
||||
/// A single cheap lookup ([`find_run_by_number`]) resolves the ambiguity
|
||||
/// that used to leave both cases reading identically.
|
||||
fn no_log_message(client: &Client, args: &Args) -> String {
|
||||
match find_run_by_number(client, args.run) {
|
||||
Ok(Some(found)) => format!(
|
||||
"run #{} exists (status: {}) but produced no log from either the \
|
||||
persisted download or the live streamer — it may still be \
|
||||
queued, or its logs were purged after finishing.",
|
||||
args.run,
|
||||
args.job
|
||||
found.status.as_deref().unwrap_or("unknown"),
|
||||
),
|
||||
Ok(None) => format!(
|
||||
"no such run #{} in {} — check the number (`ci-runs` lists real \
|
||||
ones) or that the dispatch that was meant to create it actually \
|
||||
landed.",
|
||||
args.run,
|
||||
client.repo(),
|
||||
),
|
||||
// The existence lookup itself failed (network, auth) — don't let a
|
||||
// secondary failure mask the original "no log" finding.
|
||||
Err(_) => format!(
|
||||
"run #{} job {} returned no log from either the persisted download \
|
||||
or the live streamer, and a follow-up lookup to tell \"no such \
|
||||
run\" from \"no log yet\" also failed.",
|
||||
args.run, args.job
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue