Trunk-based Development for CI/CD

Florian Tichawa
13.05.2024
Why?
An Average Git Repository:
  • Where is the main branch?
  • What are the other branches?
  • Which builds are runnable?
  • Where are my release builds?
  • Where should I branch off?
An Attempt to Fix This: GitFlow
  1. Main "release" branch with tags for every version
  2. Main "development" branch
  3. Feature branches from development for every new feature
  4. Hotfix branches from release for every urgent bugfix
Does It Work?
A New Attempt: Trunk-based Development
Advantages of GitFlow:
  • Where is the main branch?
  • Which builds are runnable?
  • Where are my release builds?
  • Where should I branch off?
  • development (For features) or release (For hotfixes)
  • Clearly defined role for every branch
  • Every commit in release and development
  • Every commit in release is a release build
  • development (For features) or release (For hotfixes)
  • Buffer
Issues of GitFlow:
  • Too many active branches
  • Two main branches
  • Big features might require complicated merges
 
The solution: Less and shorter branches
Trunk-based Development
  1. Main branch with runnable builds
  2. Short feature branches (1-2 commits) for every new feature
  3. Stale release branches for every release build
-> Bonus effect: We have a single, runnable branch containing all builds, which is perfect for CI/CD!
Trunk-based Development

Any Questions?

Sources:
trunkbaseddevelopment.com
devcycle.com Trunk-based Blog Post
Atlassian CI / Trunk-based Blog Post
CovPy Auto Reporte GitHub Repository