Thank you for your interest in contributing! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Coding Standards
- Testing
- Submitting Changes
This project follows a standard code of conduct. Please be respectful and constructive in all interactions.
- Fork the repository
- Clone your fork locally
- Set up the development environment
- Create a feature branch
- Make your changes
- Submit a pull request
- Python 3.9+
- Ansible 2.14+
- Git
# Clone your fork
git clone https://github.com/yourusername/mac-fleet-automation.git
cd mac-fleet-automation
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r scripts/requirements.txt
pip install -r web/requirements.txt
# Install development dependencies
pip install pytest ansible-lint shellcheck-py black isort flake8
# Set up pre-commit hooks (optional)
pip install pre-commit
pre-commit installUse descriptive branch names:
feature/add-new-featurebugfix/fix-issue-descriptiondocs/update-readmerefactor/improve-function
Follow conventional commit format:
type(scope): description
[optional body]
[optional footer]
Types: feat, fix, docs, style, refactor, test, chore
Examples:
feat(scripts): add support for bulk DNS operations
fix(ansible): correct homebrew path for Apple Silicon
docs(readme): update installation instructions
- Follow PEP 8 style guide
- Use type hints for functions
- Maximum line length: 100 characters
- Use docstrings for modules, classes, and functions
def process_hostname(hostname: str, domain: str) -> str:
"""
Process hostname and append domain if needed.
Args:
hostname: The hostname to process
domain: The domain to append
Returns:
Fully qualified domain name
"""
if not hostname.endswith(domain):
return f"{hostname}.{domain}"
return hostname- Use YAML syntax consistently
- Include comments for complex tasks
- Use
ansible-lintbefore committing - Follow role directory structure conventions
---
# tasks/main.yml
- name: Install required packages
homebrew:
name: "{{ item }}"
state: present
loop: "{{ required_packages }}"
become_user: "{{ admin_user }}"- Use
shellcheckfor linting - Include shebang:
#!/usr/bin/env bash - Use
set -euo pipefailfor safety - Quote variables:
"${variable}"
#!/usr/bin/env bash
set -euo pipefail
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"# Run all tests
pytest scripts/tests/
# Run with coverage
pytest --cov=scripts scripts/tests/
# Run specific test
pytest scripts/tests/test_powerdns_manager.py# Syntax check
ansible-playbook --syntax-check ansible/mac-mini-base-config.yml
# Lint
ansible-lint ansible/
# Dry run (check mode)
ansible-playbook -i inventory.ini playbook.yml --check# Lint all shell scripts
shellcheck pipelines/*.sh
shellcheck web/setup.sh- Ensure all tests pass
- Update documentation if needed
- Add entry to CHANGELOG.md (if applicable)
- Create pull request with clear description
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Refactoring
- [ ] Other (describe)
## Testing
- [ ] Unit tests added/updated
- [ ] Manual testing completed
- [ ] Documentation updated
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Comments added for complex code
- [ ] No sensitive data includedIf you have questions, feel free to open an issue for discussion.
Thank you for contributing! 🎉