DevOps
Navdeep Singh Gill | 01 - April - 2022
Subscription
Thanks for submitting the form.
In the early days of software development, programmers did not have the luxury of sophisticated version control systems. Instead, they created two versions of their programme concurrently to track changes and, if required, reverse them. This procedure proved to be labour-intensive, expensive, and inefficient over time.As version control systems evolved, several development approaches arose, allowing programmers to detect defects more readily, write in tandem with their colleagues, and speed release cadence. Most programmers use one of two development approaches to build high-quality software: Gitflow or trunk-based development.
Trunk-based development is one of the characteristics that contribute to improved software delivery and organisational effectiveness. Take the DORA assessment to measure your Software Delivery Performance.
There are two ways in which developers can work together using version control.
Trunk-based development is a software development strategy where engineers incorporate small changes to a core codebase.
Trunk based development is a branching model where a developer makes regular changes to the Trunk or main or master branch directly. This phenomenon minimizes the situation of merge-hell and prevents release branches from bugs. Suppose a new code needs to be added to the main code, so a developer needs to follow the below steps:
Trunk Based Development enforces CI/CD(Continuous Integration and Continuous Development) at its full potential. The focus is on feature branches and code review practices, aiming to maintain excellent quality and collaboration.
A single developer or pair of developers can directly commit to Trunk after build.
Introduction of short-lived feature branches. As the code base scales and the team grows, the merge conflict situation also scales up. In this situation, developers create feature branches and work on them, generate pull requests, and integrate them to master or trunk after code-review and build.
The TBD phenomenon stands over short-lived feature branches, which are extracted from the master itself and will ultimately merge into the master branch after the successful build of new code. This enables you to work directly with the master branch.
The main benefits of trunk-based development are that it enforces Continuous Integration, Code review and smooth code releases.
TBD prevents merge-hell situations by providing developers with the potential to merge new work to the main branch directly. The code is still not to be merged to production until they have passed the build stage.
Allow continuous code integration to the main branch. As the code went through different pipeline stages, the code is now reliable enough to do the production.
Small feature development gives greater visibility of features being developed.
Expressway of delivering new features more frequently.
Properties |
Git-Flow |
Trunk Based Development |
Philosophy |
Keep development far from the main branch. |
Keep development as close as possible to main branch |
Working principle |
Create feature branches from the main branch, when work is done, the developer creates pull requests, other developers comment on the changes and may have discussions. |
Create a feature branch from the main branch, when work is done, the developer directly merges code in the main branch after passing build and test. |
Release frequency |
Review code is sometimes a very time consuming process which results in slow releases. |
TBD is used where frequent releases are required. |
Restrict Access |
Users are restricted to branch access. |
No restriction over branch access. |
Life of Feature branch |
Long lived feature branch |
Short lived Feature branch |
CI/CD |
Different deployment methods used. |
Enforces CI/CD best practices for quick releases. |
Application |
|
|
Trunk based development is not a new idea but is gaining more popularity recently. In past, these practises have been given various names like, 'Software Configuration Management', 'Version control systems' which is evolved to simple 'Source Control'.
Big IT giants like Google, Amazon and Facebook have successfully adopted the TBD approach in their companies. A small team lowers the cost of software development. This is because engineers now have to maintain only the master branch and other branches have a limited period. As a result, it helps in minimizing merge conflicts. Due to its lightweight workflow, TBD is highly recommended by the software development community.
Trunk based development has drastically improved how we use version control systems in the software development process. Now developers have more transparency as they can work directly over the master branch. This concept also enforces the use of CI/CD efficiently to get the full benefits of TBD. This approach will benefit organizations to produce high-quality code at a higher pace. This also brings confidence as the code is always production-ready. If you want to take TBD at an advanced level, you can use feature flags. But you should keep in mind that you must know the use cases where Trunk-based development brings you joy and where it can put you in trouble(Use Git flow instead).
- Measure Your Team's Software Delivery Performance with DORA Assessment
- Read how Nexastack is enabling Continuous Delivery
Related resources
Thanks for submitting the form.
Continuous Integration and Continuous Deployment Effectively