lmrc-pipeline
Pipeline orchestration library for LMRC Stack projects with reusable build, test, and deployment steps.
Overview
lmrc-pipeline provides a programmatic way to define and execute CI/CD pipelines for Rust projects. It offers:
- Reusable Steps: Pre-built steps for common tasks (build, test, lint, deploy)
- Composable API: Build complex pipelines from simple building blocks
- Progress Tracking: Beautiful terminal output with step status and timing
- Error Handling: Comprehensive error types with context
- Flexibility: Easy to add custom steps for project-specific needs
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
= "0.1.0" # For ProjectConfig
Quick Start
use ;
use ;
use ProjectConfig;
async
Available Steps
Cargo Steps
BuildStep
Build your Rust workspace:
use BuildStep;
// Debug build
let step = new;
// Release build
let step = new.release;
// Specific packages
let step = new
.packages;
TestStep
Run tests:
use TestStep;
// All tests
let step = new;
// Specific packages
let step = new
.packages;
// Specific test
let step = new
.test_name;
FormatCheckStep / FormatStep
Check or apply code formatting:
use ;
// Check formatting (CI)
let step = new;
// Apply formatting (development)
let step = new;
ClippyStep
Run clippy linter:
use ClippyStep;
// Deny warnings (default)
let step = new;
// Allow warnings
let step = new.deny_warnings;
// Specific packages
let step = new
.packages;
Infrastructure Steps (Placeholder)
The following steps are defined but not yet fully implemented. They serve as placeholders for future functionality:
DockerBuildStep: Build Docker imagesProvisionStep: Provision infrastructure (Hetzner Cloud)SetupK8sStep: Setup Kubernetes/K3s clusterSetupDatabaseStep: Setup PostgreSQL databaseSetupDnsStep: Configure DNS records (Cloudflare)DeployStep: Deploy applications to Kubernetes
Creating Custom Steps
Implement the PipelineStep trait:
use ;
use async_trait;
use Instant;
Pipeline Context
The PipelineContext provides shared state between steps:
use PipelineContext;
use ProjectConfig;
use PathBuf;
let config = from_file?;
let context = new
.with_working_dir
.with_dry_run; // Preview without executing
// Steps can access and modify shared state
context.set_state;
let value = context.get_state;
Example: Complete CI Pipeline
use ;
use *;
use ProjectConfig;
async
CLI Integration
The library is designed to be used in generated pipeline binaries:
use ;
use ;
use *;
use ProjectConfig;
async
Error Handling
The library uses a comprehensive error type:
use PipelineError;
match pipeline.run.await
Output Example
When you run a pipeline, you'll see beautiful terminal output:
════════════════════════════════════════════════════════════════════════════════
Pipeline Execution - 4 steps
════════════════════════════════════════════════════════════════════════════════
▶ 1/4 Running cargo-fmt-check
Check code formatting
✓ 1/4 DONE cargo-fmt-check (0.43s)
Code is properly formatted
▶ 2/4 Running cargo-clippy
Run clippy linter
✓ 2/4 DONE cargo-clippy (2.15s)
No clippy issues found
▶ 3/4 Running cargo-test
Run workspace tests
✓ 3/4 DONE cargo-test (5.82s)
All tests passed
▶ 4/4 Running cargo-build
Build workspace in release mode
✓ 4/4 DONE cargo-build (18.34s)
Built successfully in release mode
════════════════════════════════════════════════════════════════════════════════
✓ Pipeline completed successfully (26.74s)
════════════════════════════════════════════════════════════════════════════════
Development Status
✅ Implemented
- Core pipeline orchestration
- Cargo build/test/format/clippy steps
- Error handling and reporting
- Progress tracking and terminal output
- Context sharing between steps
🚧 Planned
- Complete Docker image building
- Infrastructure provisioning integration
- Kubernetes deployment integration
- Database setup integration
- DNS configuration integration
- Parallel step execution
- Step caching and incremental builds
- Pipeline state persistence
- Rollback on failure
Contributing
Contributions are welcome! Areas that need work:
- Infrastructure Steps: Complete the placeholder implementations
- Testing: Add comprehensive unit and integration tests
- Documentation: Improve examples and API docs
- Performance: Optimize step execution and add caching
- Features: Add parallel execution, retries, timeouts
License
Dual licensed under MIT OR Apache-2.0 (user's choice).
Author
Lemarc lemarc.dev@gmail.com
Related Projects
- lmrc-cli: CLI tool that uses this library
- lmrc-config-validator: Configuration validation
- lmrc-hetzner: Hetzner Cloud client
- lmrc-kubernetes: Kubernetes management
- lmrc-docker: Docker operations