Thank you for your interest in contributing to the Tangle Network Gadget project! This document provides guidelines and instructions for contributing.
-
Install required dependencies:
# Ubuntu/Debian apt install build-essential cmake libssl-dev pkg-config # macOS brew install openssl cmake
-
Set up Rust:
# Install Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # Install specific toolchain rustup install nightly-2024-10-13 rustup default nightly-2024-10-13 # Install required components rustup component add rustfmt clippy rust-src
-
Clone the repository:
git clone https://github.com/tangle-network/gadget.git cd gadget
Please familiarize yourself with the project structure before contributing:
cli/
: Command-line interface implementationcrates/
: Core functionality modules.github/
: GitHub-specific files (workflows, templates)
-
Fork the repository and create your feature branch:
git checkout -b feature/your-feature-name
-
Make your changes, following our development guidelines
-
Run the test suite:
cargo test
-
Update documentation as needed
-
Submit a pull request with a clear description of the changes and any relevant issue numbers
Follow the Conventional Commits specification:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types:
feat
: New featurefix
: Bug fixdocs
: Documentation changesstyle
: Code style changes (formatting, missing semi-colons, etc)refactor
: Code refactoringtest
: Adding missing testschore
: Maintenance tasks
Example:
feat(cli): add new blueprint deployment option
Added --dry-run flag to deployment command for testing deployments
without actually submitting transactions.
Closes #123
Use the following naming convention for branches:
feature/
: New featuresfix/
: Bug fixesdocs/
: Documentation updatesrefactor/
: Code refactoringtest/
: Test-related changes
Example: feature/blueprint-deployment
- Follow Rust style guidelines
- Use
rustfmt
for code formatting:cargo fmt
- Run clippy for linting:
cargo clippy -- -D warnings
- Write unit tests for new functionality
- Ensure existing tests pass
- Add integration tests for new features
- Include documentation tests for public APIs
- Use async/tokio for asynchronous tests
Example test structure:
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_async_feature() {
// Async test implementation
let result = some_async_function().await;
assert!(result.is_ok());
}
#[tokio::test]
async fn test_error_handling() {
// Async error handling test
match failing_async_function().await {
Err(e) => assert_matches!(e, Error::Expected),
_ => panic!("Expected error"),
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_concurrent_operations() {
// Test concurrent operations
let (result1, result2) = tokio::join!(
async_operation1(),
async_operation2()
);
assert!(result1.is_ok() && result2.is_ok());
}
}
For mocking time-dependent tests:
use tokio::time::{self, Duration};
#[tokio::test]
async fn test_with_time() {
let mut interval = time::interval(Duration::from_secs(1));
// First tick completes immediately
interval.tick().await;
// Use time::sleep for testing timeouts
tokio::time::sleep(Duration::from_secs(2)).await;
// Test after delay
assert!(some_condition);
}
- Document all public APIs
- Include examples in documentation
- Update README.md if needed
- Add inline comments for complex logic
Example documentation:
/// Deploys a blueprint to the network
///
/// # Arguments
///
/// * `name` - Name of the blueprint
/// * `config` - Blueprint configuration
///
/// # Returns
///
/// * `Result<DeploymentId>` - Deployment identifier on success
///
/// # Examples
///
/// ```
/// let result = deploy_blueprint("my_blueprint", config)?;
/// ```
pub fn deploy_blueprint(name: &str, config: Config) -> Result<DeploymentId> {
// Implementation
}
- All PRs require at least one review from a maintainer
- CI checks must pass
- Documentation must be updated
- Changes should be tested on a development network
- Large changes may require multiple reviews
For questions or clarifications, please open an issue or join our Discord server.