Contributing
We welcome contributions to cuenv! This guide will help you get started with contributing code, documentation, and ideas.
Getting Started
Section titled “Getting Started”Prerequisites
Section titled “Prerequisites”- Rust 1.70+ (install via rustup)
- Git for version control
- Nix (optional, for reproducible development environment)
- Go 1.21+ (for CUE engine development)
Development Setup
Section titled “Development Setup”# Clone the repositorygit clone https://github.com/cuenv/cuenv.gitcd cuenv
# Set up development environmentnix develop # or direnv allow
# Build the projectcargo build
# Run testscargo test --workspaceCode Contributions
Section titled “Code Contributions”Finding Issues to Work On
Section titled “Finding Issues to Work On”- Check the issue tracker
- Look for issues labeled
good first issueorhelp wanted - Join discussions to propose new features
Development Workflow
Section titled “Development Workflow”- Fork and Clone
# Fork on GitHub, then clone your forkgit clone https://github.com/YOUR_USERNAME/cuenv.gitcd cuenvgit remote add upstream https://github.com/cuenv/cuenv.git- Create a Branch
git checkout -b feature/my-new-feature- Make Changes
- Follow the coding standards below
- Write tests for new functionality
- Update documentation as needed
- Test Your Changes
# Run all testscargo test --workspace
# Run specific crate testscargo test -p cuenginecargo test -p cuenv-corecargo test -p cuenv-cli
# Run lintingcargo clippy -- -D warnings
# Format codecargo fmt- Commit and Push
git add .git commit -m "feat: add new feature description"git push origin feature/my-new-feature- Create Pull Request
- Open a PR on GitHub
- Fill out the PR template
- Link any related issues
Coding Standards
Section titled “Coding Standards”Rust Code Style
Section titled “Rust Code Style”- Follow standard Rust formatting (
cargo fmt) - Use
cargo clippyfor linting - Document public APIs with rustdoc comments
- Write unit tests for all public functions
use cuengine::CueEvaluator;use cuenv_core::manifest::Cuenv;use std::path::Path;
/// Evaluates the `cuenv` package inside `dir` and returns the typed manifest.////// # Arguments////// * `dir` - Directory containing your `env.cue`////// # Errors////// Returns any evaluation or deserialization error emitted by the Go bridge.////// # Examples////// ```rust/// # use cuengine::CueEvaluator;/// # use std::path::Path;/// let evaluator = CueEvaluator::builder().build()?;/// let json = evaluator.evaluate(Path::new("./config"), "cuenv")?;/// assert!(json.contains("env"));/// # Ok::<_, cuenv_core::Error>(())/// ```pub fn load_manifest(dir: &Path) -> cuenv_core::Result<Cuenv> { let evaluator = CueEvaluator::builder().build()?; evaluator.evaluate_typed(dir, "cuenv")}Error Handling
Section titled “Error Handling”Use structured error types with thiserror:
#[derive(Debug, thiserror::Error)]pub enum MyError { #[error("Configuration error: {message}")] Config { message: String },
#[error("IO error")] Io(#[from] std::io::Error),}Testing
Section titled “Testing”Write comprehensive tests using Rust’s built-in test framework:
#[cfg(test)]mod tests { use super::*; use cuengine::CueEvaluator; use std::path::Path;
#[test] fn evaluator_runs() { let evaluator = CueEvaluator::builder().no_retry().build().unwrap(); let result = evaluator.evaluate(Path::new("."), "cuenv"); assert!(result.is_ok()); }}Project Structure
Section titled “Project Structure”cuenv/├── crates/│ ├── cuengine/ # CUE evaluation engine│ ├── cuenv-core/ # Core library│ └── cuenv-cli/ # CLI application├── docs/ # Documentation source├── examples/ # Example configurations├── schema/ # CUE schemas└── tests/ # Integration testsAdding New Features
Section titled “Adding New Features”When adding new features:
- Design First: Discuss the design in an issue or discussion
- Start Small: Implement the minimal viable version
- Test Thoroughly: Add unit and integration tests
- Document: Update relevant documentation
- Performance: Consider performance implications
Working with FFI
Section titled “Working with FFI”For changes to the CUE engine FFI:
- Go Side: Update
crates/cuengine/bridge.go - Rust Side: Update
crates/cuengine/src/lib.rs - Test Both: Ensure both Go and Rust tests pass
- Memory Safety: Verify proper memory management
Documentation Contributions
Section titled “Documentation Contributions”Documentation Structure
Section titled “Documentation Structure”Documentation uses Astro with Starlight:
- Source files in
docs/src/content/docs/ - Configuration in
docs/astro.config.mjs - Build with
bun run build
Writing Guidelines
Section titled “Writing Guidelines”- Use clear, concise language
- Include code examples for APIs
- Add cross-references between related topics
- Test all code examples
Building Documentation
Section titled “Building Documentation”cd docs
# Install dependenciesbun install
# Development server with hot reloadbun run dev
# Build for productionbun run build
# Preview production buildbun run previewBug Reports
Section titled “Bug Reports”Before Reporting
Section titled “Before Reporting”- Check if the issue already exists
- Try to reproduce with the latest version
- Create a minimal reproduction case
Bug Report Template
Section titled “Bug Report Template”When reporting bugs, include:
- Environment: OS, Rust version, cuenv version
- Steps to Reproduce: Clear, numbered steps
- Expected Behavior: What should happen
- Actual Behavior: What actually happens
- Reproduction Case: Minimal code/config to reproduce
Example Bug Report
Section titled “Example Bug Report”## Bug Description
CUE evaluation fails with circular reference error
## Environment
- OS: Ubuntu 20.04- Rust: 1.75.0- cuenv: 0.1.1
## Steps to Reproduce
1. Create file `config.cue` with content: ```cue a: b b: a ```- Run
cuenv env print
Expected Behavior
Section titled “Expected Behavior”Should report circular reference error clearly
Actual Behavior
Section titled “Actual Behavior”Crashes with panic: “stack overflow”
Reproduction Case
Section titled “Reproduction Case”[Link to minimal repo or paste configuration]
## Feature Requests
### Before Requesting
* Check if a similar feature exists or is planned* Consider if it fits with cuenv's goals* Think about implementation complexity
### Feature Request Template
Include:
* **Use Case**: Why is this needed?* **Proposal**: How should it work?* **Alternatives**: What other solutions exist?* **Implementation**: Any implementation ideas?
## Release Process
### Versioning
cuenv follows Semantic Versioning:
* **Major** (1.0.0): Breaking changes* **Minor** (0.1.x): New features, backwards compatible* **Patch** (0.1.1): Bug fixes
### Release Checklist
For maintainers preparing releases:
1. Update version numbers in `Cargo.toml` files2. Update `CHANGELOG.md`3. Run full test suite4. Build documentation5. Tag release6. Publish to crates.io
## Community Guidelines
### Code of Conduct
We follow the [Contributor Covenant](https://www.contributor-covenant.org/) code of conduct. Be respectful and inclusive.
### Communication
* **GitHub Issues**: Bug reports and feature requests* **GitHub Discussions**: General questions and design discussions* **Pull Requests**: Code contributions and reviews
### Getting Help
* Read the documentation first* Search existing issues and discussions* Ask specific questions with context* Provide minimal reproduction cases
## Recognition
Contributors will be:
* Listed in `CONTRIBUTORS.md`* Mentioned in release notes for significant contributions* Invited to join the cuenv organization (for regular contributors)
Thank you for contributing to cuenv!