Skip to content

๐ŸŒณ Git Workflow & Conventions

A guide to our Git workflow and commit conventions


๐Ÿ“ Commit Message Structure

Bash
<type>(<scope>): <subject>

๐Ÿท๏ธ 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:

INI
[gh-actions]
python =
    3.11: py311
    3.12: py312

๐Ÿงฉ 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