Development Guide
This guide helps developers contribute to Morphir Rust.
Setting Up Development Environment
Prerequisites
- Rust toolchain (1.98+)
wasm32-unknown-unknowntarget for extension development- Git
Clone and Build
git clone https://github.com/finos/morphir-rust.git
cd morphir-rust
cargo build
Run Tests
# All tests
cargo test
# Specific crate
cargo test -p morphir-common
# BDD acceptance tests
cd crates/morphir-gleam-binding
cargo test --test acceptance
Project Structure
morphir-rust/
├── crates/
│ ├── morphir-devkit/ # Devkit: workspace, config, and extension discovery
│ ├── morphir-common/ # Shared infrastructure
│ ├── morphir-daemon/ # Runtime services
│ ├── morphir-gleam-binding/ # Gleam extension
│ └── ...
├── docs/ # Documentation site
└── ...
Code Organization
CLI
The canonical morphir CLI lives in the finos/morphir repository (crates/morphir there) and consumes this workspace’s crates through a git submodule.
Devkit
Devkit functionality in crates/morphir-devkit/:
config/- Configuration discovery and layered loadingdiscovery.rs- Locating configuration files (project, global user, system, user override)sources.rs- Source kinds, precedence, and the per-source reportloader.rs- Merging sources into the effective configuration and workspace/project contextpaths.rs- Output-path resolution inside.morphir/
extensions.rs- Extension discovery
Common Utilities
Shared code in crates/morphir-common/:
config/model.rs- Configuration modelspipeline/- Pipeline frameworkvfs/- Virtual file system
Adding a New Command
CLI commands live in finos/morphir. Create the command module under crates/morphir/src/commands/ in that repository, wire it into the Commands enum and MorphirSession::execute(), and add tests there.
Adding a New Extension
- Create extension crate
- Implement
Extension,Frontend, and/orBackendtraits - Build as WASM:
cargo build --target wasm32-unknown-unknown - Add to builtin extensions (if applicable)
- Update extension discovery
Testing
Unit Tests
#[cfg(test)]
mod tests {
#[test]
fn test_feature() {
// Test implementation
}
}
Integration Tests
Integration tests in tests/ directory:
#[tokio::test]
async fn test_command() {
// Test command execution
}
BDD Tests
BDD tests use Cucumber/Gherkin:
Feature: My Feature
Scenario: Test case
Given setup
When action
Then assertion
Code Style
- Follow Rust standard formatting (
cargo fmt) - Use
clippyfor linting (cargo clippy) - Document public APIs
- Write tests for new features
Contributing
- Create a feature branch
- Make changes
- Add tests
- Update documentation
- Submit pull request
Next Steps
- Read Architecture Overview
- See Extension System Design
- Check CLI Architecture