Thank you for your interest in contributing to Tiny8! This guide will help you get started with contributing to our educational 8-bit CPU simulator.
Whether you're fixing a bug, adding a feature, improving documentation, or creating new assembly examples, your contributions are welcome and appreciated.
- Search existing issues first
- Provide a clear description and minimal reproduction steps
- Include your Python version and operating system
- Add relevant code snippets or assembly programs
- Open an issue describing the feature and its use case
- Discuss design decisions before implementing large changes
- Consider backward compatibility and educational value
- Fix typos and improve clarity
- Add more code examples
- Enhance API documentation
- Create tutorials or guides
- Create educational assembly programs
- Document algorithms and implementation details
- Add visualizations demonstrating key concepts
- Improve test coverage
- Add edge case tests
- Test on different platforms
- Python 3.11+ (3.11, 3.12, or 3.13 recommended)
- Git for version control
- uv (optional but recommended) for fast package management
-
Fork and clone the repository:
git clone https://github.com/YOUR_USERNAME/tiny8.git cd tiny8 -
Set up development environment:
Using
uv(recommended):# Install uv if you haven't already # macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh # Windows: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # Create virtual environment and install dependencies uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate uv sync
Using standard
pip:python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -e ".[dev]"
-
Verify your setup:
# Run tests pytest # Check linting ruff check . # Try the CLI tiny8 examples/fibonacci.asm
# Run all tests
pytest
# Run with coverage
pytest --cov=src/tiny8 --cov-report=html
# Run specific test file
pytest tests/test_arithmetic.py
# Run specific test
pytest tests/test_arithmetic.py::test_add_basic
# Verbose output
pytest -v
# Show print statements
pytest -s- Tests are located in the
tests/directory - Use
pytestframework (configured inpytest.ini) - Follow existing test patterns for consistency
- Test both success and failure cases
- Keep tests fast, focused, and deterministic
Example test structure:
def test_feature_name():
"""Test description."""
# Arrange
cpu = CPU()
cpu.load_program(...)
# Act
cpu.step()
# Assert
assert cpu.read_reg(16) == expected_valueWe use ruff for both linting and formatting:
# Check for issues
ruff check .
# Auto-fix issues
ruff check . --fix
# Format code
ruff format .
# Check formatting without changing
ruff format . --check- Type hints: Use type annotations for function signatures
- Docstrings: Use Google-style docstrings for public APIs
- Line length: 88 characters (ruff default)
- Imports: Group stdlib, third-party, and local imports
- Naming:
- Functions/variables:
snake_case - Classes:
PascalCase - Constants:
UPPER_CASE - Private methods:
_leading_underscore
- Functions/variables:
Example:
def execute_instruction(self, opcode: int, operands: list[int]) -> None:
"""Execute a single instruction.
Args:
opcode: The instruction opcode.
operands: List of operand values.
Raises:
InvalidOpcodeError: If opcode is not recognized.
"""
# Implementation# Generate API documentation
sphinx-apidoc -efo docs/api/ src/
# Build HTML docs
cd docs
make html
# View docs
open _build/html/index.html # macOS
# or
xdg-open _build/html/index.html # Linux
# or
start _build/html/index.html # Windows- Keep documentation synchronized with code changes
- Add docstrings to all public functions, classes, and modules
- Update
README.mdfor user-facing changes - Update
docs/index.rstfor significant features - Include code examples in docstrings when helpful
- Place assembly files in
examples/directory - Use
.asmextension - Include comprehensive comments
- Start with a header comment explaining the algorithm
Example template:
; Algorithm Name
; Brief description of what this program does
;
; Algorithm explanation:
; - Step 1 description
; - Step 2 description
;
; Registers used:
; - R16: Purpose
; - R17: Purpose
;
; Expected result: Description
ldi r16, 0 ; Initialize
; ... your code
done:
jmp done ; Halt- Educational value: Demonstrate a clear concept
- Comments: Explain the "why", not just the "what"
- Deterministic: Use fixed inputs for reproducibility
- Test coverage: Add corresponding unit tests
- Documentation: Reference in README or docs if significant
- Create an issue for non-trivial changes to discuss approach
- Branch from main: Use descriptive branch names
fix/short-descriptionfor bug fixesfeat/short-descriptionfor featuresdocs/short-descriptionfor documentationtest/short-descriptionfor tests
- Make atomic commits with clear messages
- Update tests to cover your changes
- Run the full test suite and linter
- Update documentation if needed
Write clear, concise commit messages:
feat: add MUL instruction support
- Implement 8-bit multiplication
- Update instruction decoder
- Add comprehensive tests
- Update documentation
Closes #123
Format:
- First line:
<type>: <summary>(50 chars max) - Types:
feat,fix,docs,test,refactor,perf,chore - Body: Explain what and why (optional)
- Footer: Reference issues (optional)
Before submitting your PR, ensure:
- Code follows style guidelines (
ruff checkpasses) - All tests pass (
pytestsucceeds) - New tests added for new functionality
- Documentation updated (if applicable)
- Commit messages are clear and descriptive
- PR description explains changes and motivation
- Branch is up-to-date with main
- No unrelated changes included
- Maintainers will review PRs within a few days
- Address feedback constructively
- Push additional commits to the same branch
- Request re-review after addressing comments
- Be respectful: Treat everyone with respect and professionalism
- Be welcoming: Foster an inclusive environment for all contributors
- Be collaborative: Work together constructively
- Be patient: Remember we're all volunteers with varying experience levels
- Issues: Use for bug reports, feature requests, and discussions
- Pull Requests: Use for code contributions
- Discussions: Use GitHub Discussions for questions and ideas
- Email: For security issues only (see below)
If you discover a security vulnerability:
- Do NOT open a public issue
- Email the maintainers directly (see
pyproject.tomlfor contact info) - Provide detailed information about the vulnerability
- Allow time for a fix before public disclosure
By contributing to Tiny8, you agree that your contributions will be licensed under the MIT License.
Your contributions will be attributed in the project's commit history and release notes.
- Check the documentation
- Search existing issues
- Open a new issue for discussion
- Join GitHub Discussions
Thank you for taking the time to contribute to Tiny8! Your efforts help make this project a better learning tool for everyone exploring computer architecture.
Every contribution, no matter how small, makes a difference. We appreciate your support! β