Crate lmrc_pipeline

Crate lmrc_pipeline 

Source
Expand description

§lmrc-pipeline

Pipeline orchestration library for LMRC Stack projects.

This library provides reusable pipeline steps for common tasks in Rust projects:

  • Building with cargo
  • Running tests
  • Code formatting and linting
  • Building Docker images
  • Provisioning infrastructure
  • Deploying to Kubernetes

§Dynamic Pipeline Steps

The library includes a dynamic pipeline step registry that automatically builds pipeline steps based on the services configured in lmrc.toml. When users add or remove services from their infrastructure configuration, the pipeline automatically includes or excludes the corresponding setup steps.

§Example

use lmrc_pipeline::{Pipeline, PipelineContext, StepRegistry};
use lmrc_pipeline::steps::{BuildStep, TestStep, DeployStep};
use lmrc_config_validator::{LmrcConfig, ProjectConfig, ProviderConfig, AppsConfig, InfrastructureConfig};

// Create full LMRC configuration
let config = LmrcConfig {
    project: ProjectConfig {
        name: "my-project".to_string(),
        description: "My awesome project".to_string(),
    },
    providers: ProviderConfig {
        server: "hetzner".to_string(),
        kubernetes: "k3s".to_string(),
        database: "postgres".to_string(),
        queue: "rabbitmq".to_string(),
        dns: "cloudflare".to_string(),
        git: "gitlab".to_string(),
    },
    apps: AppsConfig { applications: vec![] },
    infrastructure: InfrastructureConfig {
        provider: "hetzner".to_string(),
        network: None,
        servers: vec![],
        k3s: None,
        postgres: None,
        rabbitmq: None,
        vault: None,
        dns: None,
        gitlab: None,
        load_balancer: None,
    },
};

// Create pipeline context
let context = PipelineContext::new(config.clone())?;

// Build and run pipeline with static steps
let report = Pipeline::new(context)
    .add_step(BuildStep::new().release())
    .add_step(TestStep::new())
    .add_step(DeployStep::new())
    .run()
    .await?;

println!("Pipeline completed in {:?}", report.total_duration);

// Or use dynamic registry for config-driven steps
let registry = StepRegistry::default();
let setup_steps = registry.build_setup_steps(&config);
// Add setup_steps to pipeline as needed

Re-exports§

pub use context::PipelineContext;
pub use error::PipelineError;
pub use error::Result;
pub use factory::ProviderFactory;
pub use factory::Providers;
pub use pipeline::Pipeline;
pub use pipeline::PipelineReport;
pub use registry::StepBuilder;
pub use registry::StepRegistry;
pub use registry_builder::RegistryBuilder;
pub use registry_builder::StepCategory;
pub use step::PipelineStep;
pub use step::StepOutput;

Modules§

context
error
factory
Provider factory for creating port implementations based on configuration
pipeline
registry
registry_builder
secret_store
Secret storage module
server_mapping
step
steps