provisioning/docs/book/development/build-system.html

609 lines
25 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML>
2026-01-17 03:58:28 +00:00
<html lang="en" class="rust sidebar-visible" dir="ltr">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Build System - Provisioning Platform Documentation</title>
<!-- Custom HTML head -->
2026-01-17 03:58:28 +00:00
<meta name="description" content="Enterprise-grade Infrastructure as Code platform - Complete documentation">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
<link rel="icon" href="../favicon.svg">
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="../fonts/fonts.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" id="highlight-css" href="../highlight.css">
<link rel="stylesheet" id="tomorrow-night-css" href="../tomorrow-night.css">
<link rel="stylesheet" id="ayu-highlight-css" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
<!-- Provide site root and default themes to javascript -->
<script>
const path_to_root = "../";
2026-01-17 03:58:28 +00:00
const default_light_theme = "rust";
const default_dark_theme = "navy";
</script>
<!-- Start loading toc.js asap -->
<script src="../toc.js"></script>
</head>
<body>
<div id="mdbook-help-container">
<div id="mdbook-help-popup">
<h2 class="mdbook-help-title">Keyboard shortcuts</h2>
<div>
<p>Press <kbd></kbd> or <kbd></kbd> to navigate between chapters</p>
<p>Press <kbd>S</kbd> or <kbd>/</kbd> to search in the book</p>
<p>Press <kbd>?</kbd> to show this help</p>
<p>Press <kbd>Esc</kbd> to hide this help</p>
</div>
</div>
</div>
<div id="body-container">
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
try {
let theme = localStorage.getItem('mdbook-theme');
let sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
const default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? default_dark_theme : default_light_theme;
let theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
const html = document.documentElement;
2026-01-17 03:58:28 +00:00
html.classList.remove('rust')
html.classList.add(theme);
html.classList.add("js");
</script>
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
<!-- Hide / unhide sidebar before it is displayed -->
<script>
let sidebar = null;
const sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
sidebar_toggle.checked = sidebar === 'visible';
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<!-- populated by js -->
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
<noscript>
<iframe class="sidebar-iframe-outer" src="../toc.html"></iframe>
</noscript>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
</div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</label>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="default_theme">Auto</button></li>
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search (`/`)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="/ s" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">Provisioning Platform Documentation</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
2026-01-17 03:58:28 +00:00
<a href="https://github.com/your-org/provisioning" title="Git repository" aria-label="Git repository">
<i id="git-repository-button" class="fa fa-github"></i>
</a>
2026-01-17 03:58:28 +00:00
<a href="https://github.com/your-org/provisioning/edit/main/provisioning/docs/src/development/build-system.md" title="Suggest an edit" aria-label="Suggest an edit">
<i id="git-edit-button" class="fa fa-edit"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
2026-01-17 03:58:28 +00:00
<h1 id="build-system"><a class="header" href="#build-system">Build System</a></h1>
<p>Building, testing, and packaging the Provisioning platform and extensions with Cargo, Just, and Nickel.</p>
<h2 id="build-tools"><a class="header" href="#build-tools">Build Tools</a></h2>
2026-01-17 03:58:28 +00:00
<div class="table-wrapper"><table><thead><tr><th>Tool</th><th>Purpose</th><th>Version Required</th></tr></thead><tbody>
<tr><td><strong>Cargo</strong></td><td>Rust compilation and testing</td><td>Latest stable</td></tr>
<tr><td><strong>Just</strong></td><td>Task runner for common operations</td><td>Latest</td></tr>
<tr><td><strong>Nickel</strong></td><td>Schema validation and type checking</td><td>1.15.1+</td></tr>
<tr><td><strong>Nushell</strong></td><td>Script execution and testing</td><td>0.109.0+</td></tr>
</tbody></table>
</div>
<h2 id="building-platform-services"><a class="header" href="#building-platform-services">Building Platform Services</a></h2>
<h3 id="build-all-services"><a class="header" href="#build-all-services">Build All Services</a></h3>
<pre><code class="language-bash"># Build all Rust services in release mode
cd provisioning/platform
cargo build --release --workspace
# Or using just task runner
just build-platform
</code></pre>
<p>Binary outputs in <code>target/release/</code>:</p>
<ul>
<li><code>provisioning-orchestrator</code></li>
<li><code>provisioning-control-center</code></li>
<li><code>provisioning-vault-service</code></li>
<li><code>provisioning-installer</code></li>
</ul>
<h3 id="build-individual-service"><a class="header" href="#build-individual-service">Build Individual Service</a></h3>
<pre><code class="language-bash"># Orchestrator service
cd provisioning/platform/crates/orchestrator
cargo build --release
# Control Center service
cd provisioning/platform/crates/control-center
cargo build --release
# Development build (faster compilation)
cargo build
</code></pre>
<h2 id="testing"><a class="header" href="#testing">Testing</a></h2>
<h3 id="run-all-tests"><a class="header" href="#run-all-tests">Run All Tests</a></h3>
<pre><code class="language-bash"># Rust unit and integration tests
cargo test --workspace
# Nushell script tests
just test-nushell
# Complete test suite
just test-all
</code></pre>
<h3 id="test-specific-component"><a class="header" href="#test-specific-component">Test Specific Component</a></h3>
<pre><code class="language-bash"># Test orchestrator crate
cargo test -p provisioning-orchestrator
# Test with output visible
cargo test -p provisioning-orchestrator -- --nocapture
# Test specific function
cargo test -p provisioning-orchestrator test_workflow_creation
# Run tests matching pattern
cargo test workflow
</code></pre>
<h3 id="security-tests"><a class="header" href="#security-tests">Security Tests</a></h3>
<pre><code class="language-bash"># Run 350+ security test cases
cargo test -p security --test '*'
# Specific security component
cargo test -p security authentication
cargo test -p security authorization
cargo test -p security kms
</code></pre>
<h2 id="code-quality"><a class="header" href="#code-quality">Code Quality</a></h2>
<h3 id="formatting"><a class="header" href="#formatting">Formatting</a></h3>
<pre><code class="language-bash"># Format all Rust code
cargo fmt --all
# Check formatting without modifying
cargo fmt --all -- --check
# Format Nickel schemas
nickel fmt provisioning/schemas/**/*.ncl
</code></pre>
<h3 id="linting"><a class="header" href="#linting">Linting</a></h3>
<pre><code class="language-bash"># Run Clippy linter
cargo clippy --all -- -D warnings
# Auto-fix Clippy warnings
cargo clippy --all --fix
# Clippy with all features enabled
cargo clippy --all --all-features -- -D warnings
</code></pre>
<h3 id="nickel-validation"><a class="header" href="#nickel-validation">Nickel Validation</a></h3>
<pre><code class="language-bash"># Type check Nickel schemas
nickel typecheck provisioning/schemas/main.ncl
# Evaluate schema
nickel eval provisioning/schemas/main.ncl
# Format Nickel files
nickel fmt provisioning/schemas/**/*.ncl
</code></pre>
<h2 id="continuous-integration"><a class="header" href="#continuous-integration">Continuous Integration</a></h2>
<p>The platform uses automated CI workflows for quality assurance.</p>
<h3 id="github-actions-pipeline"><a class="header" href="#github-actions-pipeline">GitHub Actions Pipeline</a></h3>
<p>Key CI jobs:</p>
<pre><code class="language-text">1. Rust Build and Test
- cargo build --release --workspace
- cargo test --workspace
- cargo clippy --all -- -D warnings
2. Nushell Validation
- nu --check core/cli/provisioning
- Run Nushell test suite
3. Nickel Schema Validation
- nickel typecheck schemas/main.ncl
- Validate all schema files
4. Security Tests
- Run 350+ security test cases
- Vulnerability scanning
5. Documentation Build
- mdbook build docs
- Markdown linting
</code></pre>
<h2 id="packaging-and-distribution"><a class="header" href="#packaging-and-distribution">Packaging and Distribution</a></h2>
<h3 id="create-release-package"><a class="header" href="#create-release-package">Create Release Package</a></h3>
<pre><code class="language-bash"># Build optimized binaries
cargo build --release --workspace
# Strip debug symbols (reduce binary size)
strip target/release/provisioning-orchestrator
strip target/release/provisioning-control-center
# Create distribution archive
just package
</code></pre>
<h3 id="package-structure"><a class="header" href="#package-structure">Package Structure</a></h3>
<pre><code class="language-text">provisioning-5.0.0-linux-x86_64.tar.gz
├── bin/
│ ├── provisioning # Main CLI
│ ├── provisioning-orchestrator # Orchestrator service
│ ├── provisioning-control-center # Control Center
│ ├── provisioning-vault-service # Vault service
│ └── provisioning-installer # Platform installer
├── lib/
│ └── nulib/ # Nushell libraries
├── schemas/ # Nickel schemas
├── config/
│ └── config.defaults.toml # Default configuration
├── systemd/
│ └── *.service # Systemd unit files
└── README.md
</code></pre>
<h2 id="cross-platform-builds"><a class="header" href="#cross-platform-builds">Cross-Platform Builds</a></h2>
<h3 id="supported-targets"><a class="header" href="#supported-targets">Supported Targets</a></h3>
<pre><code class="language-bash"># Linux x86_64 (primary platform)
cargo build --release --target x86_64-unknown-linux-gnu
# Linux ARM64 (Raspberry Pi, cloud ARM instances)
cargo build --release --target aarch64-unknown-linux-gnu
# macOS x86_64
cargo build --release --target x86_64-apple-darwin
# macOS ARM64 (Apple Silicon)
cargo build --release --target aarch64-apple-darwin
</code></pre>
<h3 id="cross-compilation-setup"><a class="header" href="#cross-compilation-setup">Cross-Compilation Setup</a></h3>
2026-01-17 03:58:28 +00:00
<pre><code class="language-bash"># Add target architectures
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
2026-01-17 03:58:28 +00:00
# Install cross-compilation tool
cargo install cross
2026-01-17 03:58:28 +00:00
# Cross-compile with Docker
cross build --release --target aarch64-unknown-linux-gnu
</code></pre>
<h2 id="just-task-runner"><a class="header" href="#just-task-runner">Just Task Runner</a></h2>
<p>Common build tasks in <code>justfile</code>:</p>
<pre><code class="language-just"># Build all components
build-all: build-platform build-plugins
# Build platform services
build-platform:
cd platform &amp;&amp; cargo build --release --workspace
# Run all tests
test: test-rust test-nushell test-integration
# Test Rust code
test-rust:
cargo test --workspace
# Test Nushell scripts
test-nushell:
nu scripts/test/test_all.nu
# Format all code
fmt:
cargo fmt --all
nickel fmt schemas/**/*.ncl
# Lint all code
lint:
cargo clippy --all -- -D warnings
nickel typecheck schemas/main.ncl
# Create release package
package:
./scripts/package.nu
# Clean build artifacts
clean:
cargo clean
rm -rf target/
</code></pre>
<p>Usage examples:</p>
<pre><code class="language-bash">just build-all # Build everything
just test # Run all tests
just fmt # Format code
just lint # Run linters
just package # Create distribution
just clean # Remove artifacts
</code></pre>
<h2 id="performance-optimization"><a class="header" href="#performance-optimization">Performance Optimization</a></h2>
<h3 id="release-builds"><a class="header" href="#release-builds">Release Builds</a></h3>
<pre><code class="language-toml"># Cargo.toml
[profile.release]
opt-level = 3 # Maximum optimization
lto = "fat" # Link-time optimization
codegen-units = 1 # Better optimization, slower compile
strip = true # Strip debug symbols
panic = "abort" # Smaller binary size
</code></pre>
<h3 id="build-time-optimization"><a class="header" href="#build-time-optimization">Build Time Optimization</a></h3>
<pre><code class="language-toml"># Cargo.toml
[profile.dev]
opt-level = 1 # Basic optimization
incremental = true # Faster recompilation
</code></pre>
<p>Speed up compilation:</p>
<pre><code class="language-bash"># Use faster linker (Linux)
sudo apt install lld
export RUSTFLAGS="-C link-arg=-fuse-ld=lld"
2026-01-17 03:58:28 +00:00
# Parallel compilation
cargo build -j 8
2026-01-17 03:58:28 +00:00
# Use cargo-watch for auto-rebuild
cargo install cargo-watch
cargo watch -x build
</code></pre>
2026-01-17 03:58:28 +00:00
<h2 id="development-workflow"><a class="header" href="#development-workflow">Development Workflow</a></h2>
<h3 id="recommended-workflow"><a class="header" href="#recommended-workflow">Recommended Workflow</a></h3>
<pre><code class="language-bash"># 1. Start development
just clean
just build-all
2026-01-17 03:58:28 +00:00
# 2. Make changes to code
2026-01-17 03:58:28 +00:00
# 3. Test changes quickly
cargo check # Fast syntax check
cargo test &lt;specific-test&gt; # Test specific functionality
2026-01-17 03:58:28 +00:00
# 4. Full validation before commit
just fmt
just lint
just test
2026-01-17 03:58:28 +00:00
# 5. Create package for testing
just package
</code></pre>
2026-01-17 03:58:28 +00:00
<h3 id="hot-reload-development"><a class="header" href="#hot-reload-development">Hot Reload Development</a></h3>
<pre><code class="language-bash"># Auto-rebuild on file changes
cargo watch -x build
2026-01-17 03:58:28 +00:00
# Auto-test on changes
cargo watch -x test
2026-01-17 03:58:28 +00:00
# Run service with auto-reload
cargo watch -x 'run --bin provisioning-orchestrator'
</code></pre>
2026-01-17 03:58:28 +00:00
<h2 id="debugging-builds"><a class="header" href="#debugging-builds">Debugging Builds</a></h2>
<h3 id="debug-information"><a class="header" href="#debug-information">Debug Information</a></h3>
<pre><code class="language-bash"># Build with full debug info
cargo build
2026-01-17 03:58:28 +00:00
# Build with debug info in release mode
cargo build --release --profile release-with-debug
2026-01-17 03:58:28 +00:00
# Run with backtraces
RUST_BACKTRACE=1 cargo run
RUST_BACKTRACE=full cargo run
</code></pre>
2026-01-17 03:58:28 +00:00
<h3 id="build-verbosity"><a class="header" href="#build-verbosity">Build Verbosity</a></h3>
<pre><code class="language-bash"># Verbose build output
cargo build -vv
2026-01-17 03:58:28 +00:00
# Show build commands
cargo build -vvv
2026-01-17 03:58:28 +00:00
# Show timing information
cargo build --timings
</code></pre>
2026-01-17 03:58:28 +00:00
<h3 id="dependency-tree"><a class="header" href="#dependency-tree">Dependency Tree</a></h3>
<pre><code class="language-bash"># View dependency tree
cargo tree
2026-01-17 03:58:28 +00:00
# Duplicate dependencies
cargo tree --duplicates
2026-01-17 03:58:28 +00:00
# Build graph visualization
cargo depgraph | dot -Tpng &gt; deps.png
</code></pre>
2026-01-17 03:58:28 +00:00
<h2 id="best-practices"><a class="header" href="#best-practices">Best Practices</a></h2>
<ul>
<li>Always run <code>just test</code> before committing</li>
<li>Use <code>cargo fmt</code> and <code>cargo clippy</code> for code quality</li>
<li>Test on multiple platforms before release</li>
<li>Strip binaries for production distributions</li>
<li>Version binaries with semantic versioning</li>
<li>Cache dependencies in CI/CD</li>
<li>Use release profile for production builds</li>
<li>Document build requirements in README</li>
<li>Automate common tasks with Just</li>
<li>Keep build times reasonable (&lt;5 min)</li>
</ul>
<h2 id="troubleshooting"><a class="header" href="#troubleshooting">Troubleshooting</a></h2>
<h3 id="common-build-issues"><a class="header" href="#common-build-issues">Common Build Issues</a></h3>
<p><strong>Compilation fails with linker error:</strong></p>
<pre><code class="language-bash"># Install build dependencies
sudo apt install build-essential pkg-config libssl-dev
</code></pre>
2026-01-17 03:58:28 +00:00
<p><strong>Out of memory during build:</strong></p>
<pre><code class="language-bash"># Reduce parallel jobs
cargo build -j 2
2026-01-17 03:58:28 +00:00
# Use more swap space
sudo fallocate -l 8G /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
</code></pre>
<p><strong>Clippy warnings:</strong></p>
<pre><code class="language-bash"># Fix automatically where possible
cargo clippy --all --fix
2026-01-17 03:58:28 +00:00
# Allow specific lints temporarily
#[allow(clippy::too_many_arguments)]
</code></pre>
2026-01-17 03:58:28 +00:00
<h2 id="related-documentation"><a class="header" href="#related-documentation">Related Documentation</a></h2>
<ul>
<li><a href="testing.html">Testing</a> - Testing strategies and procedures</li>
<li><a href="contributing.html">Contributing</a> - Contribution guidelines including build requirements</li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
2026-01-17 03:58:28 +00:00
<a rel="prev" href="../development/api-guide.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
2026-01-17 03:58:28 +00:00
<a rel="next prefetch" href="../development/testing.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
2026-01-17 03:58:28 +00:00
<a rel="prev" href="../development/api-guide.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
2026-01-17 03:58:28 +00:00
<a rel="next prefetch" href="../development/testing.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
2026-01-17 03:58:28 +00:00
<!-- Livereload script (if served using the cli tool) -->
<script>
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsAddress = wsProtocol + "//" + location.host + "/" + "__livereload";
const socket = new WebSocket(wsAddress);
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
2026-01-17 03:58:28 +00:00
<script>
window.playground_line_numbers = true;
</script>
<script>
window.playground_copyable = true;
</script>
2026-01-17 03:58:28 +00:00
<script src="../ace.js"></script>
<script src="../mode-rust.js"></script>
<script src="../editor.js"></script>
<script src="../theme-dawn.js"></script>
<script src="../theme-tomorrow_night.js"></script>
<script src="../elasticlunr.min.js"></script>
<script src="../mark.min.js"></script>
<script src="../searcher.js"></script>
<script src="../clipboard.min.js"></script>
<script src="../highlight.js"></script>
<script src="../book.js"></script>
<!-- Custom JS scripts -->
</div>
</body>
</html>