New businesses that master software delivery can reach valuations of 1 billion in a matter of months, disrupting established ecosystems. To do this, they have to have the capability to deliver software with quality and speed enabling them to rapidly scale valuable offerings based on experimentation. In that context, existing businesses are pressured to compete at the same pace or risk falling behind. | ||
The rise of Agile methodologies and DevOps practices have improved the capability to deliver in faster cycles by leveraging techniques like Continuous Integration and Continuous Delivery (CI/CD). The main challenge with such practices is to ensure that quality requirements are met, as faster iterations increase the risk of defects and the accumulation of technical debt. | ||
While the latest technologies play a critical role in accelerating the delivery of valuable software, efficient and effective software development processes are at the core of streamlined software activities. The development team must be able to perform rapid code changes and deliver them in small and reliable increments to support business goals. | ||
Inscrever-se | ||
Trunk-based development is a branching practice, identified as a core capability in the DORA research program, for elite performers delivering multiple times per day. This article compares trunk-based development with other branching strategies and how to implement it in your organization to deliver software with quality and speed. | ||
| ||
What is trunk-based development? | ||
Code versioning, for example, can quickly become a nightmare with an accumulation of small decisions and defects that pile up. When developers work in their own branch with a local version, the effort to merge multiple changes made in the meantime can take hours, if not days. All that time lost merging issues and the accidental complexity is a waste of effort for the company. | ||
Trunk-based development is a software development methodology that focuses on keeping a single source of truth for the code repository, often referred to as the “trunk”, or “main” in the Git ecosystem. One important point is that this master software lane must always be considered as ready for deployment to production, without depending on other branches. | ||
Trunk-based development is based on the following ingredients: | ||
| ||
The Lean Principle of limiting the work-in-progress is central to trunk-based development, helping to reduce waste and the number of defects on the production line. In software, its application means that small code changes are very frequently integrated into the main line and incorporated into the releasable version once they pass the quality requirements. | ||
This paradigm encourages developers to commit their code regularly, resolving conflicts early on rather than letting them accumulate over time. By reducing the number of branches with a single source of truth with the latest code version, trunk-based development helps reduce the risk of merge conflicts, improves code quality, and accelerates software delivery. | ||
Trunk-based development is not dependent on software architecture like modular monoliths or microservices — yet, it requires an alignment with the software system. For example, trunk-based development enforces frequent commits that must be reviewed quickly to keep up the fast flow of iteration, and is supported by practices like a release train and feature flags. | ||
How trunk-based development differs from other practices | ||
Gitflow, GitHub Flow, or Feature Branch structure team collaboration around different branches based on workflows like development versions, release, or hotfix. While developers feel safe working in a given branch, the release process is painful due to complex merging processes, slow testing, and multiple versions to manage at any given point in time. | ||
Trunk-based development is different from other branching models with just-in-time integration and release of code changes on a single branch. In this model, software delivery constraints cannot be hidden as pending changes, making it the best way to streamline the software pipeline. | ||
The key differences of trunk-based development lie in: | ||
| ||
The choice of branching model depends on the specific needs of the team and context of the organization and its alignment with the development team. Google, Spotify, Etsy, Netflix are popular examples of organizations applying the practice, but other branching models may be more suitable for teams with a different organization and culture. | ||
Furthermore, experience matters with trunk-based development. The State of DevOps Report (page 31) identified that new developers tend to make more mistakes and have lower performance, whereas developers with 16+ years of experience take full benefit of trunk-based development and perform better overall. | ||
How to implement trunk-based development | ||
Trunk-based development is like the cherry on the cake, as it requires multiple software practices to support its performance. Its implementation requires a gradual approach for developers to have the time to incorporate new practices in their work routines, and also for the team to grow in maturity with this paradigm. | ||
It all starts by making it clear that the trunk or main branch is the only one considered as the source of truth for team collaboration. The following 4 steps support the implementation of mature trunk-based development practices to effectively harness its benefits. The key point is to align the software’s technical and organizational systems to work in concert. | ||
1. Ad-hoc/initial maturity | ||
The first level of implementation focuses on convincing the team of the benefits by making them understand the differences from other models they may be used to, and making small yet important changes in their working routines, i.e. to code and review more frequently. | ||
The actions to drive are: | ||
| ||
2. Repeatable maturity | ||
A team with an accelerated rhythm of iteration needs specific elements of software automation and environments to keep changing code frequently in small increments with a good degree of confidence. | ||
The following practices must be implemented for this to work: | ||
| ||
3. Managed maturity | ||
Once a team masters the repeatable process of trunk-based development, the focus shifts to make the process more robust and scalable over-time. That’s where a clear release process that can be improved based on outcomes becomes necessary. | ||
These elements become necessary at that stage: | ||
| ||
4. Scalable maturity | ||
The various parts of the process must be delegated to dedicated roles when the codebase reaches a certain size. This final stage consists of supporting a continuous flow of changes with practices requiring an advanced degree of maturity. | ||
The main practices relevant for this stage are: | ||
| ||
Which technologies support trunk-based development? | ||
The technology foundations of trunk-based development are similar to other branching strategies as the code still needs versioning, automated build, deployment and testing stages. The key differences for the trunk-based development tooling is to support a faster flow of iteration, requiring advanced capabilities. | ||
The core tooling of trunk-based development is based on: | ||
| ||
This tooling will support the progressive maturity of trunk-based development that needs to evolve to support the scalability of the practice. The increased flow of developers committing multiple times per day to the same codebase will drastically increase the number of builds, tests and deployments to be performed in a given timeframe. | ||
As a result, if the integrated tooling takes too much time to perform the cycle of build to deployment, code changes will start to accumulate, increasing the work-in-progress and associated risks of defects, as is often the case with other branching strategies. Specific parts of the system require specific attention so they don’t become limiting factors. | ||
The key potential choke points to address with the trunk-based development pipeline are: | ||
| ||
This integrated tooling will set the right foundations, so that you can scale trunk-based development across your organization. As we have seen, experience matters and there are best-practices and recommendations that will accelerate the deployment of trunk-based development in a more structured way. | ||
Overcoming the challenges of trunk-based development? | ||
Trunk-based development is a structuring practice that impacts the day-to-day workflow of all developers and, in the end, the quality and speed of software delivery. Common challenges have been identified and can be overcome with good preparation and progressive changes in your organization. | ||
The following challenges will be faced when migrating to a trunk-based development pipeline: | ||
| ||
Conclusion | ||
Trunk-based development can be a game-changer for organizations looking to deliver software with quality at speed. Similarly to the flow of lean factories, organizations able to deploy this practice can benefit from the fast flow of code changes, which can be quickly adapted and delivered to customers to support business goals. | ||
Implementation challenges are fundamental points to consider before launching such an initiative. Development team maturity must be assessed first to determine if the practice would suit the current maturity and character of the organization. For instance, a fully decentralized development team with many juniors would not be a suitable context for implementing trunk-based development. | ||
Trunk-based development represents the imperative to master the end-to-end software pipeline integration to support a fast flow of iterations. It is not only about mastering the code workflow between developers — it also requires organizational alignment with mature processes and tooling that can keep up with a growing codebase. | ||
It represents the move from Software Engineering to Quality Engineering for better and faster software delivery with trunk-based development at its core. | ||
Interested in trying it out? You can start implementing powerful trunk-based development today with Semaphore. |