r/TrunkbasedDevelopment • u/ElectricalAge2906 • Aug 13 '25
TBD implementation and QA process questions
We are trying to adopt Trunk-Based Development (TBD) to improve stability. Currently, we work with develop, beta, and master branches. We have separate repositories for API, web, and mobile.
Our main pain point right now is that it’s hard to make a release without including code that hasn’t been tested or has failed tests. This happens because once a PR is approved by a partner, we merge it into develop, regardless of whether QA has validated it.
At the moment, the mobile app points to the develop server, which mirrors the develop branch of the API repo. The same applies to web. The current flow is:
• All developers create PRs to develop.
• A partner reviews and approves them.
• Changes are merged and become immediately available to the whole team, including mobile and QA.Our goal with TBD is to keep main as a stable branch containing only QA-approved code. However, I’m wondering how to handle certain scenarios—for example:
• Mobile working on a feature that is being developed in API at almost the same time.
• QA needing to test multiple features, bug fixes, or tasks before they are merged into main and deployed, given that we may resolve several tickets in a single day.For context, our team consists of 4 full-stack developers and 3 mobile developers. We use GitLab and Jira.
I’ve researched ephemeral environments and feature flags/toggles.
• Ephemeral environments make more sense to me and I see how they could fit our workflow. Still, they require careful coordination to define client endpoints before merging, because an environment created from a card identifier won’t necessarily match what web or mobile are working on.
• Feature flags: I understand the general concept but not yet the technical implementation or how they would fit into our desired flow. Many developers work on different bug fixes and features that QA must review before merging and making them available to the whole team.Most of my questions are related to defining a clear QA flow in TBD. Any guidance would be greatly appreciated.
3
u/krazykarpenter Aug 13 '25
The main shift from your current process is this: QA happens before a merge to main, not after. Your develop branch, in its current form, becomes obsolete.
For e.g Step 1: The Feature Branch (or "Short-Lived Branch") A developer picks up a ticket from Jira (e.g., PROJ-123-new-api-endpoint) and creates a branch from the latest main.
The developer completes their work on this branch. This applies to your API, web, and mobile repos.
Step 2: The Pull Request (PR) & Automated Validation The developer pushes their branch and opens a Pull Request in GitLab, targeting main. This PR is the central point for review and validation. The moment the PR is opened, your CI/CD pipeline should automatically:
Step 3: The Ephemeral Environment for QA An ephemeral environment is a complete, temporary, and isolated instance of your application stack created on-demand for a specific PR. You get a unique URL like proj-123.yourapi.com that runs the exact code from that API branch. QA tests the feature in complete isolation. Nothing else from other developers is present, so you are only validating that one change.
Step 4: The Merge Once the code is peer-reviewed AND the feature is validated by QA in the ephemeral environment, the PR can be merged into main. The CI/CD pipeline should then:
Feature flags work hand-in-hand with ephemeral environments but solve a slightly different problem.
Hope this helps.
1
u/ElectricalAge2906 Sep 26 '25
The main idea is to have only QA-approved code in the main. But I now realize that possible issues could arrive after code is integrated, so a second round of testing is needed once the feature or fix is merged into the main. Does it make sense? QA can test issue A and approve it, and issue B can also be approved individually, but once each issue branch is merged, something could be broken, and we need to avoid this in the main.
How is that avoided?
1
u/martindukz Aug 13 '25
A few questions before answering:-)
Feature toggles and backwards compatible APIs are really important in working trunk based development. I.e it is entirely ok to have non-working code in main, as they can be disabled untill QA approves. Trunk based development is about integrating work and that requires you to adopt certain practices. One of the practices is that you decouple deployment and release, so you can have "half a feature" done, maybe just half the api, but it is not exposed anywhere else than test.
But it is easier to dive into that from some more specific examples.
2
u/elperroborrachotoo Aug 14 '25
The main change that I see rarely mentioned is that you need to structure your issues very very differently, with significant impact on even the tracking tool, QA procedures and process
A change like "change app and backend in a coordinated way to add feature X" may become
These are potentially separate issues with their own merge requests, and they have a block hierarchy and implementing this feature may run in parallel to unrelated MRs
With some infrastructure and experience in place, this isn't as painful as it sounds, but that's what's behind "the smallest step towards the girl that keeps the product alive"
1
u/EvilTribble Aug 13 '25
I have seen it work where you take the develop and main branching similar to gitflow, but instead of feature branches devs work off develop as their trunk. Before a release you merge develop into main as essentially a release candidate and QA can do regression testing on main and you can do any (rare) hotfixing in short lived cherry pick branches. post release QA goes back to testing dev's trunk.
Devs still need to treat every commit as a releaseable chunk and CICD still applies but there is a firewall so that other contributors can inspect main in a preproduction way that doesn't shackle the dev cycle to a specific release cycle.
1
u/Own_Dimension_2561 Aug 13 '25
We PR everything into main, but have a separate release branch that gets updated once QA is happy with what’s in main. All CI/CD uses the release branch.