This guide outlines the complete branching strategy and development workflow for PyBiorythm.
Author: Peter Rosemann (dkdndes@gmail.com)
Branch Type | Purpose | Naming Convention | Examples |
---|---|---|---|
main |
Production releases | - | main |
develop |
Integration branch | - | develop |
Feature | New features | feature/description |
feature/json-export |
Bug Fix | Bug fixes | fix/description |
fix/date-validation |
Documentation | Documentation only | docs/description |
docs/api-reference |
Security | Security fixes | security/description |
security/cve-fix |
Refactor | Code refactoring | refactor/description |
refactor/calculator-class |
main (production)
βββ develop (integration)
βββ feature/new-charts
βββ fix/critical-bug
βββ docs/workflow-guide
βββ security/vulnerability-patch
# Clone repository
git clone https://github.com/dkdndes/pybiorythm.git
cd pybiorythm
# Pull current status from GitHub (ONLY ONCE)
git checkout main
git pull origin main
git checkout develop
git pull origin develop
# Set up development environment
uv sync --group dev
β οΈ IMPORTANT: After this initial setup, NEVER work directly in main
or develop
locally again!
# 1. Create feature branch from develop
git checkout develop # Last time using develop locally!
git checkout -b feature/my-awesome-feature
# 2. Make your changes
# ... edit files, write code, update docs ...
# 3. Local testing (REQUIRED before pushing)
# Test code quality
uv run ruff check .
uv run ruff format .
uv run pytest --cov=. --cov-report=term-missing --cov-fail-under=85
# Test GitHub Actions locally with act
act --list # Validate workflow syntax
act -W .github/workflows/ci.yml --pull=false --dryrun # Test CI workflow
act -W .github/workflows/sbom.yml -j python-sbom --dryrun # Test SBOM workflow
./local-test.sh quick # Quick development tests
# 4. Commit changes
git add .
git commit -m "feat: add awesome new feature
- Implement feature X with Y capability
- Add comprehensive tests
- Update documentation"
# 5. Push feature branch to GitHub
git push origin feature/my-awesome-feature
# 6. Create Pull Request using GitHub CLI (recommended)
gh pr create --base develop --head feature/my-awesome-feature \
--title "feat: add awesome new feature" \
--body "$(cat <<'EOF'
## Summary
Brief description of what this PR does.
## Changes Made
- List key changes
- Include any breaking changes
- Note new features or fixes
## Test Plan
- [x] Unit tests pass locally
- [x] Integration tests pass
- [x] GitHub Actions tested with act
- [x] Documentation updated
## Related Issues
Fixes #123
EOF
)"
Alternative: Create PR via GitHub web interface at https://github.com/dkdndes/pybiorythm/pulls
# 7. Clean up local feature branch (after GitHub merge)
git branch -d feature/my-awesome-feature # Delete local branch
git remote prune origin # Clean up stale remote references
Before pushing ANY branch, you MUST run these tests locally:
# Linting and formatting
uv run ruff check .
uv run ruff format .
# Test suite with coverage
uv run pytest --cov=. --cov-report=term-missing --cov-fail-under=85
# Security scanning
uv run safety check
uv run bandit -r biorythm/ main.py
act
# Validate all workflows
act --list
# Test specific workflows
act -W .github/workflows/ci.yml --container-architecture linux/amd64 --pull=false --dryrun
act -W .github/workflows/sbom.yml -j python-sbom --dryrun
# Quick local development tests
./local-test.sh quick # ~30 second validation
./local-test.sh validate # Workflow syntax check
β οΈ Never push without local testing! This catches issues early and saves CI/CD credits.
Change Type | Target Branch | PR Required? |
---|---|---|
New features | develop |
β Always |
Bug fixes | develop |
β Always |
Documentation | develop |
β Always |
Security fixes | develop |
β Always |
Hotfixes | main |
β Always (emergency only) |
Use Conventional Commits:
type(scope): description
Examples:
feat(calculator): add cycle repeat calculation
fix(cli): handle invalid date input gracefully
docs(api): update calculator examples
security(deps): update vulnerable dependency
refactor(core): simplify date validation logic
## Summary
Brief description of changes and motivation.
## Changes Made
- Specific change 1
- Specific change 2
- Breaking changes (if any)
## Test Plan
- [x] Unit tests pass (`uv run pytest`)
- [x] Coverage maintained (β₯85%)
- [x] Linting passes (`uv run ruff check .`)
- [x] Security scans clean
- [x] Local GitHub Actions testing (`act`)
- [x] Documentation updated
## Related Issues
Closes #123
Fixes #456
Related to #789
## Additional Notes
Any extra context, deployment notes, or breaking changes.
Option | When to Use | Git History |
---|---|---|
Merge Commit | Feature branches with multiple commits | Preserves branch history |
Squash and Merge | Simple features, clean up history | Single commit |
Rebase and Merge | Linear history preferred | Clean linear timeline |
Recommendation: Use Squash and Merge for most feature branches to keep history clean.
Our repository enforces:
main
or develop
# NEVER do these:
git checkout main # Don't work in main locally
git checkout develop # Don't work in develop locally (after initial setup)
git merge feature-branch # Don't merge locally - use GitHub PRs
git push origin main # Don't push directly to main
git push --force origin main # Never force push to protected branches
main
or develop
branchesact
# Branch management
git checkout -b feature/name # Create new feature branch
git branch -d branch-name # Delete merged branch
git remote prune origin # Clean up stale remotes
# GitHub CLI (recommended)
gh pr create --base develop # Create pull request
gh pr list # List open PRs
gh pr merge 123 # Merge PR #123
# Local testing
act --list # List available workflows
./local-test.sh quick # Quick validation tests
uv run pytest --cov=. # Full test suite
Configure your IDE/editor for:
ruff
formatting on save# 1. Create hotfix branch from main (EXCEPTION to normal workflow)
git checkout main
git pull origin main
git checkout -b hotfix/critical-security-fix
# 2. Apply minimal fix
# ... make only essential changes ...
# 3. Test thoroughly
uv run pytest
act -W .github/workflows/ci.yml --pull=false
# 4. Create emergency PR to main
gh pr create --base main --head hotfix/critical-security-fix \
--title "HOTFIX: critical security vulnerability" \
--body "Emergency fix for production issue..."
# 5. After merge, backport to develop
gh pr create --base develop --head hotfix/critical-security-fix \
--title "backport: security hotfix to develop"
If a merged PR causes issues:
Next Steps: