Thank you for your interest in contributing to Fire! This document provides guidelines and setup instructions for contributors.
- Python 3.11 or later
- Bazel 7.0 or later
- Git
-
Clone the repository
git clone <repository-url> cd fire.git
-
Install Python dependencies
pip install -r requirements.txt
-
Install pre-commit hooks
pre-commit install
This will automatically run code quality checks before each commit.
Fire follows strict TDD practices:
-
Write tests first - Before implementing any feature, write tests
-
Make tests pass - Implement the minimum code needed
-
Refactor - Improve the code while keeping tests green
-
Colocate tests - Keep test files next to implementation files:
fire/parameters/ ├── validator.py # Implementation └── validator_test.py # Tests (same directory)
# Run all tests
bazel test //...
# Run specific test suite
bazel test //fire/parameters:validator_test
# Run with verbose output
bazel test //fire/parameters:validator_test --test_output=allPre-commit hooks will automatically run when you commit. To manually run all checks:
# Run all pre-commit hooks on all files
pre-commit run --all-files
# Run specific hook
pre-commit run black --all-files
pre-commit run flake8 --all-files- Formatter: Black (line length: 88)
- Import sorting: isort (Black-compatible profile)
- Linting: flake8
- Type hints: Use type hints; checked with mypy
- Docstrings: Google style
Example:
"""Module docstring describing the module."""
from typing import Dict, List
def validate_parameter(param: Dict[str, Any]) -> None:
"""Validate a single parameter.
Args:
param: The parameter dictionary to validate
Raises:
ValidationError: If validation fails
"""
pass- Formatter: Buildifier
- Keep dependencies sorted
- Use descriptive target names
Example:
load("@rules_python//python:defs.bzl", "py_library", "py_test")
py_library(
name = "validator",
srcs = ["validator.py"],
visibility = ["//visibility:public"],
)
py_test(
name = "validator_test",
srcs = ["validator_test.py"],
deps = [":validator"],
)The following hooks are configured:
- trailing-whitespace: Remove trailing whitespace
- end-of-file-fixer: Ensure files end with newline
- check-yaml: Validate YAML syntax
- check-added-large-files: Prevent large files (>1MB)
- check-merge-conflict: Detect merge conflict markers
- check-case-conflict: Detect case conflicts in filenames
- mixed-line-ending: Ensure consistent line endings
- black: Auto-format Python code
- isort: Sort and organize imports
- flake8: Lint Python code
- mypy: Type checking
- pydocstyle: Check docstring style
- buildifier: Format Bazel files
- buildifier-lint: Lint Bazel files
If you absolutely need to skip pre-commit hooks:
git commit --no-verify -m "Your message"Note: Only do this in exceptional circumstances. CI will still run these checks.
-
Create tests first
# fire/parameters/new_feature_test.py def test_new_feature(): # Test the new functionality pass
-
Implement the feature
# fire/parameters/new_feature.py def new_feature(): # Implementation pass
-
Run tests
bazel test //fire/parameters:new_feature_test -
Commit with descriptive message
git add fire/parameters/new_feature.py fire/parameters/new_feature_test.py git commit -m "Add new_feature for parameter validation"
-
Update
requirements.txt -
Update
requirements_lock.txtif needed -
Test that all builds still work:
bazel test //...
-
Create a feature branch
git checkout -b feature/your-feature-name
-
Make your changes following TDD
-
Ensure all tests pass
bazel test //... -
Ensure pre-commit hooks pass
pre-commit run --all-files
-
Push and create PR
git push origin feature/your-feature-name
-
PR should include:
- Clear description of changes
- Tests for new functionality
- Updated documentation if needed
- All checks passing
All pull requests must pass CI checks before merging. The CI pipeline runs:
- Black (Python formatting)
- isort (import sorting)
- flake8 (linting)
- mypy (type checking)
- pydocstyle (docstring style)
- Buildifier (Bazel formatting)
- General file checks
- Runs on both Ubuntu and macOS
- All unit tests (
//fire/parameters:*_test) - Integration tests (
//examples:vehicle_params_test) - Build verification for all targets
- Verifies parameter validation
- Checks C++ code generation
- Validates generated headers
CI workflow is defined in .github/workflows/ci.yaml.
fire/
├── fire/
│ ├── parameters/ # Core parameter logic
│ │ ├── *.py # Implementation files
│ │ └── *_test.py # Test files (colocated)
│ ├── rules/ # Bazel rule definitions
│ └── tools/ # Command-line tools
├── examples/ # Usage examples
├── docs/ # Documentation
├── .pre-commit-config.yaml # Pre-commit configuration
├── CONTRIBUTING.md # This file
└── README.md # Project overview
Pre-commit caches results. First run might be slow:
# Update hooks to latest versions
pre-commit autoupdate
# Clean cache if needed
pre-commit cleanOur configuration is set to avoid conflicts:
- Black line length: 88
- Flake8 configured to ignore E203, W503
If mypy complains about missing imports:
# Add type stubs to additional_dependencies in .pre-commit-config.yaml
- id: mypy
additional_dependencies: [types-PyYAML, types-<package>]- Open an issue on GitHub
- Check existing issues and documentation
- Ask in pull request reviews
- Be respectful and professional
- Follow TDD practices
- Write clear, tested code
- Document your changes
- Help review others' contributions
Thank you for contributing to Fire!