Create a special branch that points to the last passing commit on master
Problem to solve
There may be periods in time where there are prolonged cases of a failing master branch. This causes a bit of pain for developers while they write features, since their pipelines will always fail if they start a topic branch off a failing master or rebase onto a failing master. CI failures are then more difficult to read and to diagnose, which may contribute to lower velocity and possibly introducing uncaught failures into master once a topic branch is merged.
Many devs have instead been rebasing off the lastest green commit in master so that they are unimpeded by CI failures, then bring the branch up to date in the review phase. Further, this strategy allows CI failures on the topic branch to be seen and dealt with immediately.
I propose an auto-incrementing, read-only branch, called latest-green (or similar, possibly namespaced to prevent user conflicts), that points to the latest green commit on master. Devs can git checkout -b off of that branch to create a failure-free topic branch, or git rebase latest-green to incorporate the latest changes into a topic branch without introducing existing failures.
Intended users
Developers
Further details
Some edge-cases we must account for:
- What if an existing project already has a
latest-greenbranch?- Should this new branch be rename-able in the project settings?
- Should it be on by default?
- Should it be namespaced?
- Which namespace do we pick to lower chance of collisions, but also allow the possiblity of incorporating more special branches in the future?
- What if a project doesn't have a
masterbranch?- Should this feature be allowed for multiple branches (e.g. have a
master/latest-greenanddevelop/latest-green)?
- Should this feature be allowed for multiple branches (e.g. have a
Proposal
To begin, we may consider implementing an API endpoint that retrieves the last green commit for a specific branch.
Permissions and Security
The latest-green branch must be read only for everyone except the machine, so that no one accidentally pushes to it.
Documentation
Testing
What does success look like, and how can we measure that?
- New metric: average number of commits between
latest-greenandmasterwould indicate the general health of the branch better than the passing-failing ratio. - Lower rate of new failures in
master - Higher velocity for devs during the development phase
- Lower rate of CI failures on topic branches
Links / references
Discussion on a recent age of red masters on gitlab-ce/ee: gitlab-com/www-gitlab-com!23796 (merged)