What Is Trunk-Based Development?

Book description

Software development often goes wrong. Very wrong. Trunk-based development (TBD) not only eases the problem, but it helps you make things go very well. In this report, independent technical coach Clare Sudbery explains how TBD has become a technique that many professionals advocate enthusiastically—and one that, for many developers, is essential for continuous integration.

Still, TBD isn't a technique you can adopt lightly. It's very effective for developers who collaborate closely but not very appropriate for open source projects. In order to reap the benefits of TBD, there are several associated practices you need to learn and adopt first. This report helps you get started.

You will:

  • Learn about several problems that TBD can handle successfully
  • Explore several code integration issues that TBD can help your team manage
  • Learn how to write code in tiny chunks, create tests in tandem with code and run them when you commit, and write code designed to be merged several times a day
  • Explore the human factor and learn techniques to help avoid the debilitating effects of guilt and shame
  • Learn how TBD gets you fast feedback about your code

Table of contents

  1. 1. Introduction: What Is Trunk-Based Development?
    1. When Software Development Goes Wrong
    2. What If Things Could Be Better, Faster, Happier?
    3. Isn’t Trunk-Based Development Just Continuous Integration?
    4. Continuous Integration Enables Continuous Delivery
    5. OK, Tell Me More!
  2. 2. Why Does Trunk-Based Development Make Things Better?
    1. The Shining, Happy Example
    2. Two Key Principles
      1. Small Steps
      2. Fast Feedback
    3. The Benefits of TBD
      1. Collective Ownership
      2. Faster Integration, Faster Feedback, Fewer Queues
      3. Reducing Risk
      4. Better Code
      5. Improved Culture
      6. Avoiding Merge Hell
  3. 3. How Do You Practice Trunk-Based Development?
    1. Prerequisites
    2. Commit Frequently
    3. Push Frequently
    4. Build and Test on Your Own Machine Before Remote Integration
    5. Automate Your Builds and Tests
    6. Speed Up Your Builds and Tests
    7. Keep the Pipeline Green
    8. Minimize Dependencies
    9. Throw Things Away
    10. Use Feature Flags
    11. Branch by Abstraction
  4. 4. The Human Factor
    1. Mea Culpa Stories
      1. Overusing Branches
      2. Not Paying Attention to the Pipeline
      3. Not Building and Testing Locally Between Merging and Pushing
    2. Solutions
      1. Reduce Friction
      2. Cultivate an Open, Honest Culture
      3. Use Information Radiators
      4. Collaborate and Communicate
      5. Get Help, not Heroes
  5. 5. But What About...
    1. How Can I Get My Code Reviewed Without Branches and Pull Requests?
      1. Code Reviews Delay Integration
      2. PRs Can Decrease Quality
      3. PRs Discourage Trust
      4. Alternatives
    2. What If I Need Branches and Pull Requests for Regulatory Compliance?
    3. What If I Want to Create Short-Lived Branches?
    4. Won’t Frequent Integrations and Merges Just Slow Me Down?
    5. What If We Need Branches Because…
    6. What If My Colleagues Don’t Want to Practice TBD?
  6. Conclusion
  7. About the Author

Product information

  • Title: What Is Trunk-Based Development?
  • Author(s): Clare Sudbery
  • Release date: June 2023
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098146641