Thank you for your interest in contributing to FlatCityBuf!
We welcome contributions from the community and are excited to work with you.
There are many ways to contribute to FlatCityBuf:
- π Report bugs and issues
- π‘ Suggest new features or improvements
- π Improve documentation and examples
- π§ Submit code changes and fixes
- π§ͺ Add tests and benchmarks
- π Help with translations and internationalization
- π¬ Answer questions in discussions and issues
Before contributing, ensure you have:
- Rust toolchain (1.83.0 or later)
- Git for version control
- wasm-pack (for WebAssembly development)
- cargo-watch (for development workflow)
- cargo-audit (for security checks)
-
Fork and Clone
# Fork the repository on GitHub, then clone your fork git clone https://github.com/YOUR_USERNAME/flatcitybuf.git cd flatcitybuf # Add upstream remote git remote add upstream https://github.com/HideBa/flatcitybuf.git
-
Install Development Tools
# Install development dependencies cargo install cargo-watch cargo-audit cargo-nextest # Install pre-commit hooks (optional but recommended) pip install pre-commit pre-commit install
-
Build and Test
# Build all crates cargo build --workspace --all-features --exclude fcb_wasm --release # Run tests cargo test --workspace # Run with file watching for development cargo watch -x test
-
Verify Everything Works
# Run benchmarks cargo bench -p fcb_core --bench read -- --release # Check for security vulnerabilities cargo audit # Run clippy for linting cargo clippy --workspace --all-features
main- Production-ready codedevelop- Integration branch for new featuresfeature/xyz- Feature development branchesbugfix/xyz- Bug fix branchesdocs/xyz- Documentation updates
-
Create a Branch
# Always branch from the latest main git checkout main git pull upstream main git checkout -b feature/your-feature-name -
Make Your Changes
- Follow our coding standards
- Write tests for new functionality
- Update documentation as needed
- Ensure code compiles and tests pass
-
Test Your Changes
# Run the full test suite cargo test --workspace # Run specific crate tests cargo test -p fcb_core # Run integration tests cargo test --test integration_tests # Format code cargo fmt --all # Check with clippy cargo clippy --workspace --all-features -- -D warnings
-
Commit Your Changes
# Use conventional commit messages git add . git commit -m "feat: add spatial query optimization"
-
Push and Create PR
git push origin feature/your-feature-name # Then create a Pull Request on GitHub
We follow the Rust API Guidelines and these additional standards:
- Use
rustfmtwith default settings - Follow Rust naming conventions:
snake_casefor variables, functions, modulesPascalCasefor structs, enums, traitsSCREAMING_SNAKE_CASEfor constants
- Prefer explicit, descriptive names over short abbreviations
- Use
thiserrorfor custom errors in libraries - Avoid
unwrap()except in tests and examples - Return
Result<T, E>for fallible operations - Use
anyhowfor binary crates when appropriate
- Use iterators instead of loops where possible
- Minimize memory allocations
- Prefer borrowed references (
&str,&[u8]) over owned data - Use
criterionfor benchmarking
- Write rustdoc comments for all public APIs
- Include examples in documentation
- Update docs when changing public interfaces
- Write unit tests with
#[cfg(test)] - Use integration tests for public APIs
- Add benchmarks for performance-critical code
- Mock external dependencies
use anyhow::{Context, Result};
use thiserror::Error;
/// Custom error type for the module
#[derive(Error, Debug)]
pub enum MyError {
#[error("invalid input: {0}")]
InvalidInput(String),
#[error("io error")]
Io(#[from] std::io::Error),
}
/// Process city data with proper error handling
///
/// # Example
///
/// ```rust
/// use fcb_core::process_data;
///
/// let result = process_data("input.fcb")?;
/// println!("processed {} features", result.len());
/// ```
pub fn process_data(path: &str) -> Result<Vec<Feature>, MyError> {
let data = std::fs::read(path)
.context("failed to read input file")?;
parse_features(&data)
.context("failed to parse features")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_process_data() {
let result = process_data("test_data.fcb").unwrap();
assert_eq!(result.len(), 10);
}
}-
Unit Tests
- Test individual functions and methods
- Use
#[cfg(test)]modules - Mock external dependencies
-
Integration Tests
- Test public APIs and crate interactions
- Place in
tests/directory - Use real data files when possible
-
Benchmarks
- Use
criterionfor performance tests - Place in
benches/directory - Compare against baseline performance
- Use
#[cfg(test)]
mod tests {
use super::*;
use tempfile::tempdir;
#[test]
fn test_serialize_deserialize_roundtrip() {
// Arrange
let temp_dir = tempdir().unwrap();
let file_path = temp_dir.path().join("test.fcb");
let original_data = create_test_features();
// Act
serialize_to_file(&original_data, &file_path).unwrap();
let deserialized_data = deserialize_from_file(&file_path).unwrap();
// Assert
assert_eq!(original_data, deserialized_data);
}
#[test]
fn test_error_handling_invalid_input() {
let result = process_data("nonexistent.fcb");
assert!(result.is_err());
assert!(result.unwrap_err().to_string().contains("failed to read"));
}
}# Run all tests
cargo test --workspace
# Run tests with output
cargo test --workspace -- --nocapture
# Run specific test
cargo test test_serialize_deserialize_roundtrip
# Run tests in release mode (for performance testing)
cargo test --release
# Run benchmarks
cargo bench -p fcb_core- Public APIs: Must have rustdoc comments with examples
- Modules: Include module-level documentation
- Examples: Provide working code examples
- Error Cases: Document when functions can fail
- Keep README.md up to date
- Update CHANGELOG.md for releases
- Add examples for new features
- Update API documentation links
- Use clear, concise language
- Include code examples
- Explain the "why" not just the "what"
- Use lowercase for UI/logging text (per project style)
- Search existing issues to avoid duplicates
- Check the documentation and examples
- Try the latest version from main branch
When reporting bugs, please include:
## Bug Description
Brief description of the issue
## Steps to Reproduce
1. Step one
2. Step two
3. Step three
## Expected Behavior
What should have happened
## Actual Behavior
What actually happened
## Environment
- OS: [e.g., macOS 14.0, Ubuntu 22.04]
- Rust version: [e.g., 1.83.0]
- FlatCityBuf version: [e.g., 0.1.0]
- Other relevant info
## Additional Context
Any other relevant information, logs, or screenshotsWe welcome feature requests! Please:
- Check existing issues for similar requests
- Describe the use case and motivation
- Propose a solution if you have ideas
- Consider the scope - start small and iterate
## Feature Description
Clear description of the proposed feature
## Use Case
Why is this feature needed? What problem does it solve?
## Proposed Solution
How should this feature work?
## Alternatives Considered
What other approaches did you consider?
## Additional Context
Any other relevant information- Keep PRs focused - one feature or fix per PR
- Write clear descriptions explaining what and why
- Include tests for new functionality
- Update documentation as needed
- Respond to feedback promptly and constructively
We review for:
- β Correctness - Does the code work as intended?
- β Quality - Is the code well-written and maintainable?
- β Performance - Are there any performance regressions?
- β Security - Are there any security concerns?
- β Documentation - Is the code properly documented?
- β Tests - Are there adequate tests?
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Benchmarks run successfully
- [ ] Manual testing performed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] Tests added/updatedWe follow Semantic Versioning:
- MAJOR version for incompatible API changes
- MINOR version for backwards-compatible functionality
- PATCH version for backwards-compatible bug fixes
- Update version numbers in
Cargo.tomlfiles - Update
CHANGELOG.mdwith release notes - Run full test suite and benchmarks
- Create release branch and PR
- Tag release after merge
- Publish to crates.io
We are committed to providing a welcoming and inclusive environment. Please:
- Be respectful and considerate
- Be constructive in discussions and feedback
- Help others learn and grow
- Follow the golden rule - treat others as you'd like to be treated
- GitHub Issues - Bug reports and feature requests
- GitHub Discussions - General questions and community chat
- Pull Requests - Code contributions and reviews
If you need help:
- Check the documentation
- Search existing issues
- Ask in GitHub Discussions
- Create a new issue if needed
We're particularly interested in contributions for:
- π Performance optimizations for reading
- π Query performance improvements
- π§ͺ Test coverage expansion
- π Documentation and examples
- π WebAssembly functionality and bindings
- π§ CLI tool enhancements
- πΊοΈ Spatial indexing optimizations
- π Benchmarking infrastructure
- π Python bindings development
- π± Mobile platform support
- βοΈ Cloud integration features
- π Plugin system architecture
Contributors will be:
- β¨ Listed in CONTRIBUTORS.md
- π Mentioned in release notes
- π Featured in project updates
- π Eligible for special recognition
By contributing to FlatCityBuf, you agree that your contributions will be licensed under the same MIT License that covers the project.
Thank you for contributing to FlatCityBuf! π
Together, we're building the future of 3D city model processing.
π Back to README β’ π Documentation β’ π¬ Discussions