fdc00f0635
Add DebugFeature bitflags for controlling notify.dummy, events, scheduler, and script debug behaviors. Add prefetch module to fetch plugins and templates before pipeline runs. Add cleanup and artifact handling to finalize stage. Add build_id to ExecutionContext.
80 lines
2.2 KiB
Rust
80 lines
2.2 KiB
Rust
pub mod config;
|
|
pub mod constant;
|
|
pub mod error;
|
|
pub mod event;
|
|
pub mod cleanup;
|
|
pub mod artifact;
|
|
pub mod plugin;
|
|
pub mod stage;
|
|
pub mod template;
|
|
pub mod types;
|
|
|
|
use crate::cli::Cli;
|
|
use crate::types::resource::ResourceRegistry;
|
|
pub use config::*;
|
|
pub use error::FinalizeError;
|
|
use std::path::Path;
|
|
use workshop_engine::EventSender;
|
|
|
|
pub fn parse(path: &Path) -> Result<FinalizeConfig, FinalizeError> {
|
|
let content = std::fs::read_to_string(path).map_err(FinalizeError::IoError)?;
|
|
let config: FinalizeConfig = serde_yaml::from_str(&content)?;
|
|
Ok(config)
|
|
}
|
|
|
|
pub async fn finalize(
|
|
finalize_path: &Path,
|
|
_cli: &Cli,
|
|
ctx: &mut workshop_engine::ExecutionContext,
|
|
event_tx: EventSender,
|
|
registry: &ResourceRegistry,
|
|
) -> Result<(), FinalizeError> {
|
|
let mut finalize = parse(finalize_path)?;
|
|
let validate_result = finalize.validate();
|
|
if let Err(errors) = validate_result {
|
|
for error in &errors {
|
|
log::error!("Error: {}", error);
|
|
}
|
|
return Err(FinalizeError::ValidateError(errors));
|
|
};
|
|
|
|
// Register Plugins (paths resolved from registry)
|
|
log::info!("Registering {} plugins", finalize.plugin.len());
|
|
let registered_plugins = plugin::register(finalize.plugin, None, &mut finalize.notification, registry)?;
|
|
|
|
// Early hook
|
|
let earlyhook_result = stage::hook::hook(
|
|
finalize.hooks.as_ref().and_then(|h| h.early.as_ref()),
|
|
ctx,
|
|
event_tx.clone(),
|
|
®istered_plugins,
|
|
)
|
|
.await;
|
|
|
|
// Determine if we should continue with artifacts/latehook
|
|
// If prior stages failed, we still send notification but skip artifacts
|
|
let _prior_failed = earlyhook_result.is_err();
|
|
// Artifact collection and publishing
|
|
if !_prior_failed {
|
|
log::info!("Processing {} artifacts", finalize.artifact.len());
|
|
artifact::collect_and_publish(
|
|
&finalize.artifact,
|
|
®istered_plugins,
|
|
ctx,
|
|
event_tx.clone(),
|
|
)
|
|
.await?;
|
|
}
|
|
|
|
// Late hook
|
|
stage::hook::hook(
|
|
finalize.hooks.as_ref().and_then(|h| h.late.as_ref()),
|
|
ctx,
|
|
event_tx.clone(),
|
|
®istered_plugins,
|
|
)
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|