Development
This guide covers the development workflow for contributing to cuenv itself.
Prerequisites
Section titled “Prerequisites”- Rust 1.70+ via rustup
- Go 1.21+ for the CUE evaluation bridge
- Nix (recommended) for reproducible development environment
- Git for version control
Development Setup
Section titled “Development Setup”Using Nix (Recommended)
Section titled “Using Nix (Recommended)”The easiest way to get a complete development environment:
# Clone the repositorygit clone https://github.com/cuenv/cuenv.gitcd cuenv
# Enter the development shellnix develop
# Or use direnv for automatic loadingdirenv allowThe Nix shell provides:
- Rust toolchain with clippy, rustfmt, and rust-analyzer
- Go for the CUE bridge
- All required system dependencies
- Development tools (treefmt, cargo-nextest, etc.)
Manual Setup
Section titled “Manual Setup”If not using Nix:
# Install Rustcurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shrustup component add clippy rustfmt
# Install Go# Download from https://go.dev/dl/
# Clone and buildgit clone https://github.com/cuenv/cuenv.gitcd cuenvcargo buildProject Structure
Section titled “Project Structure”cuenv/├── crates/│ ├── cuengine/ # CUE evaluation engine (Rust + Go FFI)│ │ ├── src/ # Rust source│ │ ├── bridge.go # Go FFI bridge│ │ └── tests/│ ├── cuenv-core/ # Core types and utilities│ ├── cuenv-cli/ # CLI application│ ├── cuenv-workspaces/ # Workspace management│ └── schema-validator/ # Schema validation├── schema/ # CUE schema definitions├── examples/ # Example configurations├── docs/ # Documentation (Astro/Starlight)├── tests/ # Integration tests└── flake.nix # Nix development environmentBuild Commands
Section titled “Build Commands”Basic Build
Section titled “Basic Build”# Debug buildcargo build
# Release buildcargo build --release
# Build specific cratecargo build -p cuengineRunning cuenv
Section titled “Running cuenv”# Run from sourcecargo run -- task
# Run with argumentscargo run -- env print --path ./examples/env-basicTesting
Section titled “Testing”Unit Tests
Section titled “Unit Tests”# Run all testscargo test --workspace
# Run tests for specific cratecargo test -p cuenginecargo test -p cuenv-core
# Run with nextest (faster, better output)cargo nextest run
# Run specific testcargo test test_basic_evaluationIntegration Tests
Section titled “Integration Tests”# Run BDD testscargo test --test bdd
# Run example validationcargo test --test examplesTest Coverage
Section titled “Test Coverage”# Generate coverage reportcargo llvm-cov
# HTML reportcargo llvm-cov --htmlCode Quality
Section titled “Code Quality”Formatting
Section titled “Formatting”# Check formattingcargo fmt --check
# Fix formattingcargo fmt
# Format all files (Rust, CUE, etc.) with treefmttreefmtLinting
Section titled “Linting”# Run clippycargo clippy
# Run with strict warnings (required for CI)cargo clippy -- -D warningsPre-Commit Checklist
Section titled “Pre-Commit Checklist”Before pushing, always run:
# 1. Format codetreefmt
# 2. Run clippy with strict warningscargo clippy -- -D warnings
# 3. Run all testscargo nextest run
# 4. Build successfullycargo buildWorking with FFI
Section titled “Working with FFI”The cuengine crate uses FFI to call Go from Rust.
Building the Go Bridge
Section titled “Building the Go Bridge”The Go bridge is built automatically during cargo build via a build script.
Manual build:
cd crates/cuenginego build -buildmode=c-archive -o libcue_bridge.a bridge.goFFI Development Tips
Section titled “FFI Development Tips”- Memory Safety: All C strings from Go must be freed with
cue_free_string - Error Handling: The bridge uses a JSON envelope for structured errors
- Thread Safety:
CStringPtris intentionally!Send + !Sync - Testing: Test both Go and Rust sides when modifying the bridge
Modifying the Bridge
Section titled “Modifying the Bridge”When changing the FFI interface:
- Update
crates/cuengine/bridge.go - Update
crates/cuengine/src/lib.rs - Ensure error codes match on both sides
- Add tests for new functionality
Documentation
Section titled “Documentation”Building Docs
Section titled “Building Docs”cd docs
# Install dependenciesbun install
# Development serverbun run dev
# Build for productionbun run buildWriting Documentation
Section titled “Writing Documentation”- Documentation uses Astro with Starlight
- Source files in
docs/src/content/docs/ - Use Markdown with MDX support
- Test code examples before documenting
Debugging
Section titled “Debugging”Verbose Logging
Section titled “Verbose Logging”# Enable debug loggingRUST_LOG=debug cargo run -- task build
# Trace level for FFI debuggingRUST_LOG=cuengine=trace cargo run -- env printGDB/LLDB
Section titled “GDB/LLDB”# Build with debug symbolscargo build
# Debug with lldblldb target/debug/cuenvCommon Issues
Section titled “Common Issues”Go bridge build fails:
# Ensure Go is in PATHgo version
# Clean and rebuildcargo cleancargo buildFFI panics:
- Check that Go code doesn’t panic without recovery
- Verify memory isn’t double-freed
- Enable trace logging to see FFI calls
Release Process
Section titled “Release Process”Releases are managed by release-plz:
- Commits follow Conventional Commits
- PRs trigger changelog generation
- Merging updates versions and publishes crates
Version Bumping
Section titled “Version Bumping”Versions are automatically determined from commit messages:
feat:- Minor version bumpfix:- Patch version bumpfeat!:orBREAKING CHANGE:- Major version bump
IDE Setup
Section titled “IDE Setup”VS Code
Section titled “VS Code”Recommended extensions:
- rust-analyzer
- Even Better TOML
- cuelang.cue
settings.json:
{ "rust-analyzer.cargo.features": "all", "rust-analyzer.check.command": "clippy"}IntelliJ/CLion
Section titled “IntelliJ/CLion”- Install Rust plugin
- Configure Rust toolchain from Nix shell if using Nix
Neovim
Section titled “Neovim”With nvim-lspconfig:
require('lspconfig').rust_analyzer.setup{ settings = { ["rust-analyzer"] = { cargo = { features = "all" }, check = { command = "clippy" } } }}See Also
Section titled “See Also”- Contributing Guide - Contribution workflow
- Architecture - System design
- API Reference - Public APIs