Trunk-based Development

Published date: April 15, 2024, Version: 1.0

Overview

Trunk-based development (TBD) is a software development practice where all developers work on a single shared codebase branch called "trunk" or "mainline" instead of creating long-lived feature branches. In TBD, developers commit their changes to the trunk frequently, often multiple times a day, after ensuring that their changes don't break the existing codebase by running automated tests. This enables early detection and resolution of conflicts and integration issues, resulting in a more stable codebase and faster delivery of features.

TBD also emphasizes keeping the trunk in a releasable state at all times, meaning that the code in the trunk should be tested and ready for deployment at any given moment. This encourages developers to prioritize quality and testing as part of their development process, rather than as a separate phase of development.

Trunk-based development practices

1. Small batch sizes:

  • High-performing organizations practice small batch sizes when making changes to the codebase. They make small, incremental changes to the codebase and continuously integrate them into the trunk/mainline branch. This reduces the risk of large, complex changes and makes it easier to detect and fix issues.

2. Continuous integration:

  • High-performing organizations practice continuous integration (CI), which involves integrating all changes to the trunk/mainline branch on a daily or more frequent basis. This helps ensure that the codebase is always in a working state and reduces the risk of merge conflicts.

3. Version control:

  • High-performing organizations use a version control system (VCS) to manage their codebase. They use branching and merging strategies to facilitate trunk-based development and minimize conflicts.

4. Code reviews:

  • High-performing organizations use code reviews to ensure that changes to the codebase are of high quality and meet coding standards. Code reviews are an essential practice in trunk-based development because they help catch issues before they are merged into the trunk/mainline branch.

5. Monitoring and feedback:

  • High-performing organizations use monitoring and feedback mechanisms to detect and respond to issues quickly. They use automated testing, monitoring, and alerting to ensure that the codebase is always in a working state and to detect issues early.

Adoption expectations

System Components  MVP MVP+

Adopt new branching strategy and policies to limit number of branches

+

+

Simplify and streamline code review

+

+

Optimize CI process to take less than 15 min

 

+

Establish a rule in the team to merge changes back into the trunk at least once a day

 

+

 

Tools

Functionality  Tool Name

Version Control System

Git

Version Control Collaboration

Azure DevOps Repo, Bitbucket

Artifact Management System

JFrog Artifactory, Azure Artifacts

 

Roles

Name  Responsibilities

Scrum Master/Team Coach

Coach and support usage of the best engineering practices to support trunk-based development

Developer

Adopt practices to develop new changes in a small easy to implement and test steps

Build Engineer

Integrate automated quality gates and deployment process

Test Automation Engineer (TAE)

Implement automated tests in advance allowing continuous testing process