Source Management
2 minute read
Use Trunk Based Development
- All branches originate from the trunk
- All branches merge into the trunk
- Branches, if used, are very short-lived
- The smaller the PR, the easier it is to identify issues. The smaller the change, the less risk associated with that change.
- The trunk can always be built and deployed without breaking production.
- When needed, use techniques such as Branch by Abstraction or feature flags to ensure backward compatibility.
- The change includes all appropriate automated tests to validate that the change is deliverable.
Branching vs. Forking
Use the right pattern for the right reason. Branches are the primary flow for CI and are critical for allowing the team to have visibility to work in progress that the team is responsible for completing. Forks are how proposed, unplanned changes are made from outside the team to ensure quality control and to reduce confusion from unexpected branches.
- Use forks for:
- Contribution from a contributor outside the team to ensure proper quality controls are followed and to prevent cluttering up the team’s repository with external contributions that may be abandoned.
- Use branches for:
- All internal work to keep that work visible to the team.
Tips
- Story Slicing helps break development work into more easily consumable, testable chunks.
- You don’t have to wait for a story/feature to be complete as long as you have tested that won’t break production.
- Pull requests should be small and should be prioritized over starting any new development.
Common Issues
Trunk-based development and continuous integration often take workflow adjustments on the team. The main reasons teams struggle with CI are:
- Test architecture
- Work that is too big and/or lacks proper refinement
- Issues with source code ownership (one repo owned by more than one team)
- Workflow management within the team
References
FAQ
- Pre-requisites for TBD
- Benefits of using TBD
- Releasing From Trunk
- Handling Infrequent Releases
- Handling Bug Fixes
- Handling Incomplete Code/Features
- Validating Release Quality
- Transitioning to Trunk Based Development
- Trunk Based Development- You’re doing it wrong