Release trains
Problem to solve
A commit might be merged and ready for rollout, but each commit has to be potentially built (for deployments), QA completed and then deployed to an environment. This time is the commit transit time, the time between two commits ready for rollout.
This transit time can be of varying duration, but the goal is to have many commits ready for rollout in sequence.
For example, let's take a look at two commits (A and B) in the main
branch added 1 minute apart. Let's say that for each of them we want to build a docker image which will then be rolled out to environments. After each rollout, we expect a set of QA tests to complete prior to exposing the commits to public, and let's say that takes 3 hours. In this example, commits A and B are added 1 minute apart, but they will be deployed 6 hours apart. This is because the transit time of commit A is 3 hours, commit A is confirmed to ready for public, and then the transit time of commit B just starts adding 3 more hours to the rollout.
We've already addressed a similar problem for commits before they get merged, by creating merge trains. With Merge Trains, commits A and B would be stacked, ensuring that they get added to the main branch in close succession while the testing would be completed in parallel.
This is what we want to achieve with deployments, ensure that the consecutive commits are ready for rollout even if the transit time might be long.
Proposal
There are different ways to address the above problem, but one proposal that came from a discussion with @nolith was to consider extending merge trains to do additional actions when a MR gets added to a merge train.
The merge train logic depends on pipelines for the merged results, where pipeline runs on a branch containing the existing main
branch and the commits in the merge requests as if the merge has already occurred. If we also build and deploy the proposed commit to a set of environments, and have that result contribute to the decision on whether a MR can be merged, we can deploy the commit almost at the same time as it is merged into the main branch.