Trunk-Based Development
Trunk-Based Development
Trunk-Based Development was popularized in the svn
and perforce
days. It's very similar to the GitHub Flow based development, except that unfinished work is gated behind a feature flag. The focus of this method is that all changes should be small, incremental changes. You should aim to merge into main as often as possible, multiple times a day if possible.
Workflow
- Create a branch off of
main
for a new small piece of work. - (maybe) Add a feature flag to your FF system (e.g. LaunchDarkly).
- Commit changes to this new branch.
- PR to merge into main.
- Merge into main.
- CI automatically deploys to staging.
- (maybe) Turn feature flag on in staging.
- Test in staging.
- When ready, run CI action to deploy to production.
Pros
- Continuous Integration of new code.
- Very simple.
- Merging often and in small increments mitigates merge conflict overhead.
Cons
- Adequate automated testing is assumed in this process.
- Needs a feature flag system for anything non-trivial.
- PR process might be too slow. Best if you do Pair/Mob programming to avoid external code review.