Thank you for your interest in contributing to bmcweb-ng! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Submitting Changes
- Code Style
- Documentation
This project follows the OpenBMC Code of Conduct. Please be respectful and professional in all interactions.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/bmcweb-ng cd bmcweb-ng - Add upstream remote:
git remote add upstream https://github.com/gtmills/bmcweb-ng
- Rust 1.96.1 or later
- Linux development environment (native, WSL2, or Docker)
- OpenSSL development libraries
- DBus development libraries
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install -y \
build-essential \
libssl-dev \
libdbus-1-dev \
pkg-configFedora/RHEL:
sudo dnf install -y \
gcc \
openssl-devel \
dbus-devel \
pkg-config# Debug build
cargo build
# Release build
cargo build --release
# Run tests
cargo test
# Run with logging
RUST_LOG=debug cargo runUse descriptive branch names:
feature/add-xyz- New featuresfix/issue-123- Bug fixesdocs/update-readme- Documentation updatesrefactor/cleanup-auth- Code refactoring
Follow conventional commit format:
<type>(<scope>): <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Example:
feat(auth): Add mTLS authentication support
Implement mutual TLS authentication for enhanced security.
This allows clients to authenticate using X.509 certificates.
Closes #42
# Run all tests
cargo test
# Run specific test
cargo test test_service_root
# Run with output
cargo test -- --nocapture
# Run integration tests
cargo test --test '*'- Write unit tests in the same file as the code
- Write integration tests in
tests/directory - Use descriptive test names
- Test both success and failure cases
- Mock external dependencies (DBus, etc.)
Example:
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_service_root_returns_valid_json() {
let state = make_test_state();
let result = get_service_root(State(state)).await;
assert_eq!(result.status(), StatusCode::OK);
}
#[tokio::test]
async fn test_async_operation() {
let result = async_function().await;
assert!(result.is_ok());
}
}-
Update your fork:
git fetch upstream git rebase upstream/main
-
Create a feature branch:
git checkout -b feature/my-feature
-
Make your changes and commit them
-
Run tests and linting:
cargo test cargo clippy -- -D warnings cargo fmt --check -
Push to your fork:
git push origin feature/my-feature
-
Create a Pull Request on GitHub
- Provide a clear description of the changes
- Reference related issues (e.g., "Fixes #123")
- Ensure all tests pass
- Update documentation if needed
- Keep PRs focused on a single feature/fix
- Respond to review feedback promptly
We follow the official Rust style guide with these additions:
-
Formatting: Use
rustfmtwith default settingscargo fmt
-
Linting: Address all
clippywarningscargo clippy -- -D warnings
-
Naming Conventions:
snake_casefor functions, variables, modulesPascalCasefor types, traits, enumsSCREAMING_SNAKE_CASEfor constants- Descriptive names over abbreviations
-
Error Handling:
- Use
Result<T, E>for fallible operations - Use
anyhow::Resultfor application errors - Use
thiserrorfor library errors - Avoid
unwrap()in production code
- Use
-
Documentation:
- Document all public APIs
- Use
///for doc comments - Include examples in doc comments
- Document panics, errors, and safety
Example:
/// Retrieves the Redfish service root resource.
///
/// # Returns
///
/// Returns a JSON object containing the service root information
/// including API version, UUID, and links to major resource collections.
///
/// # Errors
///
/// Returns an error if the service root cannot be generated or
/// if required system information is unavailable.
///
/// # Example
///
/// ```
/// use bmcweb_ng::api::redfish::service_root;
///
/// // Handler is async and takes axum State — call via the router in tests.
/// ```
pub async fn get_service_root(State(state): State<AppState>) -> impl IntoResponse {
// Implementation
}- Code Documentation: Inline comments and doc comments
- API Documentation: Generated from doc comments (
cargo doc) - User Documentation: README, guides, tutorials
- Architecture Documentation: Design decisions, diagrams
When making changes, update:
- Inline code comments for complex logic
- Doc comments for public APIs
- README.md for user-facing changes
- Architecture docs for design changes
- CHANGELOG.md for notable changes
# Generate and open documentation
cargo doc --open
# Generate documentation for all dependencies
cargo doc --no-deps --openIf you have questions or need help:
- Open an issue on GitHub
- Contact the maintainers
- Check existing documentation and issues
Thank you for contributing to bmcweb-ng!