Skip to content

Trunk Based Development

Morales Patty Jose Manuel edited this page Oct 27, 2024 · 1 revision

Trunk-Based Development

Table of Contents

  1. Introduction
  2. Core Principles
  3. Workflow
  4. Best Practices
  5. Continuous Integration

Introduction

Trunk-Based Development (TBD) is a version control methodology that prioritizes collaboration on a single main branch ("trunk" or "main"). This guide establishes the guidelines for implementing TBD in our development team.

Core Principles

  • Single Source of Truth: The main branch is always the single source of truth
  • Frequent Integration: Daily commits to trunk
  • Frequent Deployments: Continuous Delivery/Deployment

Workflow

  1. Branch Creation

    git checkout main
    git pull origin main
    git checkout -b [branch-name]
  2. Development and Commits

    git add .
    git commit
  3. Update with Main

    git checkout main
    git pull origin main
    git checkout [branch-name]
    git rebase main
  4. Pull Request

    • Create PR to main
    • Request code review
    • Ensure CI passes
    • Merge after approval

Best Practices

Code Reviews

  • Daily reviews
  • Maximum 400 lines per PR
  • Use of automatic linters
  • Documentation required for significant changes

Integration

  • No more than 1-2 days without integrating
  • Short-lived branches (<24 hours ideal)
  • Early conflict resolution

Continuous Integration

Required Pipeline

  1. Lint
  2. Unit Tests
  3. Build

Pipeline Requirements

  • All tests must pass
  • Code review approvals required
  • No deployment with failing tests
  • Automatic rollback on failure

Clone this wiki locally