use anyhow::Result;
use anodizer_core::config::Config;
use anodizer_core::context::Context;
use anodizer_core::log::StageLogger;
use crate::pipeline;
pub(super) fn run(
ctx: &mut Context,
config: &Config,
log: &StageLogger,
dry_run: bool,
) -> Result<()> {
log.status("running in announce-only mode (load prior report + re-fire announcers)...");
let run_id = anodizer_stage_publish::derive_run_id(ctx);
let report = anodizer_stage_publish::load_prior_report(ctx, &run_id)?;
log.status(&format!(
"announce-only: loaded prior report (run_id={}, {} publisher result(s))",
run_id,
report.results.len()
));
ctx.set_publish_report(report);
let p = pipeline::build_announce_pipeline();
p.run(ctx, log)?;
super::run_post_pipeline_after_hooks_only(ctx, config, dry_run, log)
}
#[cfg(test)]
mod tests {
use super::*;
use anodizer_core::config::Config;
use anodizer_core::context::{Context, ContextOptions};
fn ctx_with_dist(dist: std::path::PathBuf) -> Context {
let config = Config {
project_name: "test".to_string(),
dist,
..Default::default()
};
Context::new(config, ContextOptions::default())
}
#[test]
fn missing_report_returns_clear_error() {
let tmp = tempfile::tempdir().unwrap();
let mut ctx = ctx_with_dist(tmp.path().to_path_buf());
let config = ctx.config.clone();
let log = StageLogger::new("test", anodizer_core::log::Verbosity::Quiet);
let err = run(&mut ctx, &config, &log, true).unwrap_err().to_string();
assert!(
err.contains("no prior report found"),
"error must name the missing report: {err}"
);
}
}