Trunk-Based Development

Trunk Based Development is a source control strategy where developers commit all changes to a single branch in the version control system known as the 'trunk'. This approach minimises the duration and size of branches and encourages frequent integrations.

Goal

The goal of Trunk Based Development is to speed up the development process by reducing the complexity of each commit, reducing merge conflicts and lowering lead time for changes.

Context

Code versioning systems enable branching which lets developers work on features or bug fixes in isolation. However, long-lived branches can lead to integration issues and conflicts when merging back into the main branch. In addition, they make continuous integration more complex as there are different test code bases for each branch as well. Trunk Based Development aims to address these issues by promoting frequent integrations and reducing the complexity of each commit.

Enablers

If teams are committing to the main branch frequently, they need to ensure that the branch is always in a deployable state. To achieve this, there are a few essential practices.

PracticeDescriptionBenefits
Short-Lived Feature BranchesCreating branches for new features that are merged back into the trunk frequently (typically within a day or two).Reduces the risk of merge conflicts and integration issues.
Implementing Feature TogglesEnabling or disabling features at runtime without changing the code.Allows unfinished features to be merged into the trunk safely.
Continuous Integration (CI)A development practice where code is validated by running an automated build and test suite on every commit.Ensures that trunk is in a deployable state at all times.

Inputs

ArtifactDescription
User StoriesDetailed descriptions of the functionality, performance criteria, and interfaces needed for each component.

Outputs

ArtifactDescriptionBenefits
Unvalidated CodeA feature that has been implemented but not yet validated with users.A working product that can be tested and validated with users.

Anti-patterns

  • Large, Infrequent Commits: Neglecting to commit small changes frequently can lead to integration nightmares and conflicts.
  • Ignoring Failing Builds: Not addressing build failures immediately can result in a destabilised trunk, affecting all team members.

Was this page helpful?

Previous
Acceptance Test-Driven Development (TDD)
© ZeroBlockers, 2024. All rights reserved.