Work Culture & Behind the Scenes

Trunk-Based Development: DORA's Guide to Merging Small Changes Daily with Measurable Targets

DORA compares long-lived feature branches with trunk-based development, including adoption practices and measurable targets for tracking a team's progress.

By Oemah Solution Editorial 4 min read

This article was prepared with AI assistance from the official sources listed below, and checked automatically before publication.

A large moss-covered tree trunk seen from below, rising towards a canopy of green leaves and a blue sky
Photo: Olsztyn tree trunk (Unsplash) by freestocks.org freestocks · CC0 · Wikimedia Commons

Many development teams still work with code branches that live for weeks and then merge them all at once shortly before a release. The result is often a large merge that is prone to bugs, followed by a code freeze that holds up work. The DORA research programme (Google Cloud) addresses this problem on its capability page about trunk-based development, and offers a measurable alternative.

What is trunk-based development

According to DORA, there are two main patterns for collaborating with version control. The first is the feature branch: one developer or a group of developers creates a branch from the trunk (also called main or mainline), works in isolation until the feature is finished, and then merges it back.

The second pattern is trunk-based development. Here, each developer breaks their work into small batches and merges them into the trunk at least once a day, and possibly several times. The key difference is scope. Feature branches usually involve many developers and take days to weeks, whereas branches in trunk-based development generally live for only a few hours.

DORA notes that long-lived branches produce larger and more complex merges. Teams then need additional stabilisation effort as well as "code lock" or "code freeze" periods, because large merges often introduce bugs or regressions. Conversely, when releases are made several times a day, release branches are not needed at all.

How it works in practice

DORA describes trunk-based development as a required practice for continuous integration (CI), that is, the combination of trunk-based development with a suite of fast automated tests that run after every commit to the trunk. The aim is to eliminate long integration and stabilisation phases.

In the CI paradigm, developers are responsible for keeping the build green. If the CI process fails, they stop and fix it immediately, or revert the change if it cannot be fixed within a few minutes.

Practices recommended by DORA to strengthen this approach:

  • Work in small batches, which requires training and organisational support.
  • Carry out code review synchronously, so that changes do not wait for hours or days.
  • Apply comprehensive automated testing that runs before every commit. For example, on GitHub a team can protect a branch so that a pull request can only be merged when all tests pass.
  • Have fast builds. The build and test process should finish within minutes. If this is hard to achieve, there may be room for improvement in the system architecture.
  • Form a core group of supporters and mentors.

Common pitfalls

DORA highlights several common obstacles:

  • Review processes that are too heavy. If a review requires many approvals and takes hours or days, developers tend to accumulate many changes. Review of large changes is then postponed, and defects slip past more easily.
  • Asynchronous review. According to DORA, additional review should be done synchronously: as soon as the code is ready, the developer asks a colleague to review it right then, rather than sending a request and moving on to another task. The longer a merge is delayed, the greater the chance of conflicts. This requires the team to agree to prioritise reviewing peers' code.
  • Not running automated tests before commit. Tests need to run against a change before it enters the trunk so that the trunk keeps working. When getting code into the trunk is not convoluted, changes become small, easy to understand, and reach production faster.

How to apply it for teams and clients

DORA provides a table of measurements that can be used as a simple health check, both by internal teams and by project owners who use external development services:

  • Active branches: count them in the application repository and show the number to all teams. The target is three or fewer active branches.
  • Code freezes: measure how many occur and how long they last. The target is no code freezes.
  • Merge frequency to the trunk: measure it as yes/no per branch or as the percentage of branches merged each day. The target is at least once a day.
  • Change approval time: if review is still asynchronous, measure the average time and look closely at requests that take much longer. The target is to make review a synchronous activity.

These figures can serve as material for discussion or as a reference in working agreements with vendors. Bear in mind that DORA describes this change as significant for developers who are not used to breaking work down. For that reason, DORA recommends finding experienced developers to coach their peers, and starting with a single pilot team. Other teams are moved over only after the first team has proven that it works as expected. This phased approach makes cultural change more realistic than changing everything at once.

#trunk-based-development#dora#continuous-integration#version-control#code-review

Sources & references

This article is a summary and interpretation by the Oemah Solution team of the sources below. Refer to the original sources for full details and context.

  1. DORA | Capabilities: Trunk-based development DORA (Google Cloud) · dora.dev