Adds comprehensive contributing guidelines covering: - Development workflow setup - Code submission guidelines - Local testing instructions (unit, integration, chaos, SDK) - CI/CD pipeline overview - Documentation standards Closes: bf-5u89
7.1 KiB
Contributing to Miroir
Thank you for your interest in contributing to Miroir! This document covers the development workflow, code submission guidelines, and local testing instructions.
Development Workflow
Prerequisites
- Rust 1.87 or later (see
rust-toolchain.toml) - Docker and Docker Compose for local integration testing
- make for convenience targets
- clang and musl-tools for static binary builds
Getting Started
- Clone the repository:
git clone https://github.com/jedarden/miroir.git
cd miroir
- Install Rust toolchain:
rustup show
# If Rust is not installed, follow https://rustup.rs/
- Build the project:
cargo build --all
- Run tests:
cargo test --all
- Start the development stack:
docker compose -f examples/docker-compose-dev.yml up -d
Project Structure
miroir/
├── crates/
│ ├── miroir-core/ # Core library (routing, merging, topology)
│ ├── miroir-proxy/ # HTTP proxy binary
│ └── miroir-ctl/ # Management CLI binary
├── tests/ # Integration and chaos tests
├── benches/ # Performance benchmarks
├── examples/ # Docker Compose configs and SDK tests
├── charts/miroir/ # Helm chart
├── docs/ # Documentation
└── k8s/ # ArgoCD and Argo Workflow templates
Development Commands
# Format code
cargo fmt
# Run linter
cargo clippy --all-targets --all-features -- -D warnings
# Run all tests
cargo test --all
# Run integration tests (requires dev stack running)
cargo test -p miroir-proxy --test docker_compose_integration -- --test-threads=1
# Run benchmarks
cargo bench
# Build static binaries
make build-static
Code Submission Guidelines
Pull Request Process
- Fork the repository and create a branch for your work:
git checkout -b feature/your-feature-name
-
Make your changes following the coding standards below.
-
Ensure all checks pass:
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all
- Commit your changes with a clear message:
feat(scope): brief description
Detailed explanation of the change and why it was made.
Closes: #gh-issue-number
- Push to your fork and create a pull request:
git push origin feature/your-feature-name
Coding Standards
- Follow Rust style guidelines enforced by
cargo fmt - No
unwrap()orexpect()in production code — all fallible operations must returnResult<T> - Add unit tests for new functionality in
#[cfg(test)]modules - Document public APIs with rustdoc comments
- Keep functions focused — single responsibility, clear names
- Error messages should be actionable and include context
Commit Message Conventions
Use conventional commit prefixes:
feat:— new featurefix:— bug fixdocs:— documentation changestest:— adding or updating testsrefactor:— code refactoring (no behavior change)perf:— performance improvementci:— CI/CD changeschore:— maintenance tasks
Local Testing
Unit Tests
Run unit tests for all crates:
cargo test --all
Run tests for a specific crate:
cargo test -p miroir-core
cargo test -p miroir-proxy
Integration Tests
Start the development stack first:
docker compose -f examples/docker-compose-dev.yml up -d
Run integration tests:
cargo test -p miroir-proxy --test docker_compose_integration -- --test-threads=1
Clean up after testing:
docker compose -f examples/docker-compose-dev.yml down -v
Chaos Tests
Chaos tests simulate node failures and network partitions:
# Ensure dev stack is running
docker compose -f examples/docker-compose-dev.yml up -d
# Run chaos tests
./tests/chaos/p4_topology_chaos.sh
# Clean up
docker compose -f examples/docker-compose-dev.yml down -v
SDK Compatibility Tests
Test SDK compatibility with Python, TypeScript, and Go:
cd examples/sdk-tests
./run_all_sdk_tests.sh
CI/CD Pipeline
Miroir uses Argo Workflows for CI/CD (GitHub Actions are disabled). See k8s/argo-workflows/miroir-ci.yaml for the full pipeline.
Pipeline Stages
- Checkout — Clone repository
- Lint —
cargo fmtandcargo clippy - Test —
cargo test --all --all-features - Build — Static musl binaries for
miroir-proxyandmiroir-ctl - Docker build — Push to
ghcr.io/jedarden/miroir(tag-gated) - GitHub Release — Create release with binaries (tag-gated)
Manual CI Trigger
Trigger a CI run manually:
kubectl --kubeconfig=/home/coding/.kube/iad-ci.kubeconfig create -f - <<EOF
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: miroir-ci-manual-
namespace: argo-workflows
spec:
workflowTemplateRef:
name: miroir-ci
arguments:
parameters:
- name: revision
value: main
EOF
Release Process
See the Release Checklist in the runbooks for the complete release process.
Documentation
Plan Documentation
The authoritative design document is docs/plan/plan.md. All architectural decisions should reference specific sections of this document.
Code Documentation
Public APIs must be documented with rustdoc:
/// Assigns a shard to `rf` nodes within a single replica group.
///
/// # Arguments
///
/// * `shard_id` - The shard identifier to assign
/// * `group_nodes` - Nodes belonging to the target replica group
/// * `rf` - Replication factor (number of nodes to select)
///
/// # Returns
///
/// A vector of node IDs selected for this shard, sorted by score descending.
///
/// # Example
///
/// ```no_run
/// use miroir_core::router::assign_shard_in_group;
/// let nodes = vec!["node-0".to_string(), "node-1".to_string()];
/// let assigned = assign_shard_in_group(0, &nodes, 1);
/// assert_eq!(assigned, vec!["node-0".to_string()]);
/// ```
pub fn assign_shard_in_group(shard_id: u32, group_nodes: &[NodeId], rf: usize) -> Vec<NodeId> {
// ...
}
User Documentation
User-facing documentation lives in:
docs/onboarding/— Production deployment guidesdocs/troubleshooting/— Common issues and diagnosticsdocs/runbooks/— Operational proceduresdocs/ctl/—miroir-ctlcommand documentationexamples/README.md— Quick start and local development
Getting Help
- Documentation: Start with
README.mdanddocs/plan/plan.md - Issues: Search GitHub Issues before creating a new one
- Discussions: Use GitHub Discussions for questions and design conversations
- Troubleshooting: See
docs/troubleshooting.mdfor common issues
License
By contributing to Miroir, you agree that your contributions will be licensed under the MIT License.