Thank you for your interest in contributing to wash! This document provides guidelines and information for contributors.
If you have feature suggestions, find bugs, or have questions, please submit an issue here. Pull requests are welcome! The good first issue label is a great way to find a starting point for new contributors.
- Rust (latest stable version)
- Git
- WebAssembly targets:
wasm32-wasip2(installed viarustup target add wasm32-wasip2)
git clone https://github.com/wasmcloud/wasmCloud.git
cd wasmCloud
cargo build# Run all tests
cargo test
# Run specific test suites
cargo test --lib
cargo test --bin washThe wash crate is organized as a single crate with both binary and library targets:
src/ # The wash binary
└── main.rs
crates/wash/src/
├── cli/ # CLI structs and command handling
│ ├── mod.rs
│ └── <subcommand>.rs
├── <subcommand>.rs # Reusable types and libraries for commands
├── lib.rs # Module exports
├── config.rs # Configuration management
└── new.rs # Project creation functionality
All Rust code in this project must follow these conventions:
- Never use
unwrap(),expect(), orpanic!()- Use proper error handling withResultandOption - Use
anyhow::Resultfor functions that can return errors - Add context to errors using
.context()method:operation().context("failed to perform operation")? - Error messages and log contexts should start with lowercase and not end with periods
- Use string interpolation:
format!("{value}")instead offormat!("{}", value)
- Never use
println!oreprintln!for output - Use theCommandOutputstruct for all command results - Use
tracingcrate macros for all logging:info!(),debug!(),warn!(),error!(),trace!() - Use the
#[instrument]macro for any operations that take longer than 100ms - Instrumented functions should have descriptive names with verbs (e.g., "Building component", "Fetching template")
- Prefix all environment variables with
WASH_to avoid conflicts and ensure clarity
- Use the
CommandOutputstruct for all command return values - Commands should return structured data that can be formatted as text or JSON
- Follow clap derive patterns for argument parsing
This CLI is instrumented with the tracing crate:
- Use
#[instrument(level = "debug", skip_all, name = "operation_name")]for long-running functions - Log levels should be appropriate:
error!()- Unrecoverable errorswarn!()- Recoverable issues or deprecated usageinfo!()- User-facing progress informationdebug!()- Developer debugging informationtrace!()- Detailed execution flow
Example:
use tracing::{info, instrument};
#[instrument(level = "debug", skip_all, name = "building_component")]
pub async fn build_component(&self, ctx: &CliContext) -> anyhow::Result<CommandOutput> {
info!("Building WebAssembly component");
// ...
Ok(CommandOutput::ok("Component built successfully", None))
}- Fork the repository and create your feature branch from
main - Write tests for any new functionality
- Ensure all tests pass with
cargo test - Follow the code style guidelines outlined above
- Update documentation if you're changing behavior or adding features
- Write clear commit messages that explain what and why, not just what
<type>: <description>
[optional body]
[optional footer]
Types:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changes (formatting, etc.)refactor:- Code refactoringtest:- Adding or updating testschore:- Maintenance tasks
All submissions require review. We use GitHub pull requests for this process.
- Write unit tests for new functionality
- Include integration tests for CLI commands when appropriate
- Test error cases and edge conditions
- Ensure tests are deterministic and don't depend on external services
- Update README.md if you're changing user-facing functionality
- Add inline documentation for public APIs
- Update command help text if you're modifying CLI behavior
- Rust Style Guide - Official Rust coding standards
- WebAssembly Component Model - Learn about the component model
- WASI Preview 2 - WebAssembly System Interface