๐ณ Git Workflow & Conventions¶
A guide to our Git workflow and commit conventions
๐ Commit Message Structure¶
๐ท๏ธ Commit Types¶
Type | Icon | Description |
---|---|---|
feat |
โจ | New feature |
fix |
๐ | Bug fix |
docs |
๐ | Documentation changes |
style |
๐ | Formatting changes |
refactor |
โป๏ธ | Code restructuring |
test |
๐งช | Test updates |
chore |
๐ง | Build tasks, configs |
ops |
๐ | Infrastructure, deployment |
โ๏ธ Writing Rules¶
- ๐ฏ Scope: (Optional) Component/module affected
- ๐ Subject: Use imperative mood ("Add" not "Added")
๐ฟ Branch Organization¶
๐ Core Branches¶
Branch | Icon | Purpose | Key Rules |
---|---|---|---|
main |
๐ญ | Production | โข No direct commits โข Only release /hotfix mergesโข Version tagged |
develop |
๐จ | Development | โข Feature integration โข Next release prep |
๐ Supporting Branches¶
Type | Pattern | Flow | Purpose |
---|---|---|---|
Feature | feature/* |
develop โ develop |
โจ New features |
Release | release/* |
develop โ main+develop |
๐ฆ Release prep |
Hotfix | hotfix/* |
main โ main+develop |
๐ Quick fixes |
โก Quick Commands¶
๐ Feature Development¶
Bash
# ๐ Start feature
git checkout -b feature/name develop
# โ
Complete feature
git checkout develop
git merge --no-ff feature/name
git branch -d feature/name
git push origin develop
๐ฆ Release Process¶
Bash
# ๐ Start release
git checkout -b release/1.0.0 develop
# โ
Complete release
git checkout main
git merge --no-ff release/1.0.0
git tag -a v1.0.0
git checkout develop
git merge --no-ff release/1.0.0
git branch -d release/1.0.0
git push --all && git push --tags
๐ Hotfix Process¶
Bash
# ๐ Start hotfix
git checkout -b hotfix/fix-name main
# โ
Complete hotfix
git checkout main
git merge --no-ff hotfix/fix-name
git checkout develop
git merge --no-ff hotfix/fix-name
git branch -d hotfix/fix-name
git push --all
๐ GitHub Actions CI/CD Workflow¶
Automated testing, code quality checks, docs deployment, and releases
๐ CI/CD Pipeline Structure¶
๐ CI/CD Pipeline File¶
YAML
---
name: CI/CD Pipeline
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch: true # Allow manual triggering
jobs:
test:
name: Run Tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install uv tox tox-gh-actions
uv pip install -e .[test]
- name: Run tests with tox
run: tox
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install uv
uv pip install -e .[lint]
- name: Run ruff
run: ruff check .
- name: Run black
run: black --check .
- name: Run mypy
run: mypy .
docs:
name: Build and Deploy Docs
runs-on: ubuntu-latest
needs: [test, lint]
# Only deploy docs when pushing to main/master, not on PRs
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get all history for proper versioning
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install uv
uv pip install -e .[docs]
uv pip install mike
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Build documentation
run: mkdocs build -v
- name: Deploy documentation to GitHub Pages
run: |
# If using versioned docs with mike
mike deploy --push --update-aliases $(git describe --tags --abbrev=0) latest
# Alternatively, for non-versioned docs, use the mkdocs gh-deploy command
# mkdocs gh-deploy --force
# Add deployment job for production releases
release:
name: Create Release
runs-on: ubuntu-latest
needs: [test, lint, docs]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build package
run: python -m build
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
generate_release_notes: true
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload --skip-existing dist/*
# Configuration for tox to run in GitHub Actions
# Add this to tox.ini:
# [gh-actions]
# python =
# 3.11: py311
# 3.12: py312
Our workflow file .github/workflows/ci-cd.yml
automates the following processes:
Job | Icon | Purpose | Trigger |
---|---|---|---|
test |
๐งช | Multi-platform testing | All pushes and PRs |
lint |
๐ | Code quality checks | All pushes and PRs |
docs |
๐ | Documentation build & deploy | Pushes to main |
release |
๐ฆ | Package build & PyPI publish | Tagged releases |
๐๏ธ Workflow Overview¶
graph TD
A[Push/PR] --> B[Test]
A --> C[Lint]
B --> D{Main Branch?}
C --> D
D -->|Yes| E[Build & Deploy Docs]
D -->|Tagged Release| F[Build & Publish Package]
๐งช Testing Job¶
YAML
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: python -m pip install uv tox tox-gh-actions
- run: tox
๐ Linting Job¶
YAML
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: python -m pip install uv
- run: uv pip install -e .[lint]
- run: ruff check .
- run: black --check .
- run: mypy .
๐ Documentation Job¶
YAML
docs:
runs-on: ubuntu-latest
needs: [test, lint]
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- run: uv pip install -e .[docs] mike
- run: git config --local user.email "github-actions[bot]@users.noreply.github.com"
- run: git config --local user.name "github-actions[bot]"
- run: mkdocs build -v
- run: mike deploy --push --update-aliases $(git describe --tags --abbrev=0) latest
๐ฆ Release Job¶
YAML
release:
runs-on: ubuntu-latest
needs: [test, lint, docs]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: python -m pip install build twine
- run: python -m build
- uses: softprops/action-gh-release@v1
with:
files: dist/*
generate_release_notes: true
- run: twine upload --skip-existing dist/*
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
๐ ๏ธ Configuration Tips¶
Tip | Icon | Description |
---|---|---|
Secrets | ๐ | Add PYPI_USERNAME and PYPI_PASSWORD to repository secrets |
Tox Integration | ๐ | Add [gh-actions] section to tox.ini |
Branch Protection | ๐ก๏ธ | Require status checks to pass before merging |
Manual Triggers | ๐ | Use workflow_dispatch for manual runs |
Caching | โก | Dependencies cached for faster runs |
๐ Tox GitHub Actions Integration¶
Add this to your tox.ini
file:
๐งฉ Workflow Events¶
Event | Icon | Trigger | Purpose |
---|---|---|---|
push |
๐ค | Pushing to main/master | Run tests and deploy docs |
pull_request |
๐ | PRs to main/master | Run tests and linting |
workflow_dispatch |
๐ | Manual UI trigger | Run full pipeline on demand |
tags |
๐ท๏ธ | Creating v* tags | Create releases and publish packages |
๐ก Best Practices¶
Practice | Description |
---|---|
๐ Commit Messages | Write clear, descriptive messages |
๐ Code Review | Create PRs for all changes |
โ Testing | Ensure all tests pass before merge |
๐ Documentation | Keep docs updated with changes |
๐ CI/CD | Use automated quality checks |
๐ Deployment | Automate from main branch |
๐ Resources¶
๐ Conventional Commits¶
Resource | Icon | Purpose |
---|---|---|
Conventional Commits | ๐ | Official specification |
Angular Guidelines | ๐ ฐ๏ธ | Reference implementation |
Commitlint | โจ | Commit message linting |
Commitizen | ๐ ๏ธ | Interactive commit tool |
๐ Git Flow Resources¶
Resource | Icon | Purpose |
---|---|---|
Git Flow Original | ๐ | Original workflow guide |
Atlassian Guide | ๐ | Comprehensive tutorial |
GitHub Flow | ๐ | Simplified workflow |
GitLab Flow | ๐ | Enterprise approach |
โ๏ธ GitHub Actions Resources¶
Resource | Icon | Purpose |
---|---|---|
GitHub Actions Docs | ๐ | Official documentation |
Marketplace | ๐ | Community actions |
Workflow Syntax | ๐ | YAML format reference |
Python CI Examples | ๐ | Python-specific workflows |
๐ ๏ธ Helpful Tools¶
Tool | Icon | Purpose |
---|---|---|
Husky | ๐ถ | Git hooks automation |
Semantic Release | ๐ฆ | Version management |
Conventional Changelog | ๐ | Auto-generate changelogs |
Git Flow AVH | ๐ง | Extended Git Flow CLI |
Pre-commit Hooks Guide | ๐ | Code quality automation |
๐จ Icon Resources¶
Resource | Icon | Purpose |
---|---|---|
Gitmoji | ๐ | Emoji guide for Git commits |
GitHub Emoji | ๐ | Complete emoji cheatsheet |
Emojipedia | ๐ | Emoji meanings and variants |
Unicode Emoji | ๐ | Official Unicode emoji list |
๐ก Tip: Bookmark this guide for quick reference during development