GitHub Flow vs. OneFlow: Which Git Workflow Works the Best for You? | by Nuno Barreto | Apr, 2022

A easy Git repository technique I exploit in my groups

For a few years I’ve been utilizing what everybody calls the Git Flow mannequin to arrange code branches, environments, and deployments. Though it was not the intention of the creator, many individuals I’ve met have develop into fairly dogmatic about it. The creator himself factors to that in a 2020 “trying again” word.

The issue with accepting dogmas, is that we attain some extent the place we consider that that is the one means of doing it, and we cease on the lookout for alternate options, or doable enhancements.

Whereas Git Stream remains to be fairly helpful for the kind of software program it was created for. As its’ creator Vincent Driessen mentioned in 2020: “If (…) you’re constructing software program that’s explicitly versioned, or if it’s good to help a number of variations of your software program within the wild, then Git Stream should be nearly as good of a match to your staff because it has been to folks within the final 10 years”.

The groups I’ve led have been extra centered on creating Internet Apps and APIs, the place the Git Stream mannequin provides pointless complexity. In most of these tasks, branches grasp and develop are extremely redundant, creating many merge issues between branches, and making a spaghetti git historical past that’s onerous to comply with. To not point out what number of groups even add a stage department on prime of that.

If we take into consideration the present practices of CI / CD, it turns into clear that each one of this added effort and issues turned simply pointless paperwork that steals the enjoyment and productiveness of any developer.

I bought a bit bored with the fixed merge conflicts (and builders’ conflicts ensuing from that) and determined to look into what different groups have been doing.

I began with the large ones and was stunned to study that Google was utilizing a mono repository with only one lengthy dwelling department: grasp. And with actual CI / CD, each commit is a launch!

That made me query why I used to be utilizing such advanced fashions. The primary time I discussed this to one in every of my groups, there was a mixture of “It could actually’t be true!” with “If we did that our merchandise can be all the time damaged!”. It made me understand that the primary purpose why we create advanced programs with increasingly more steps is worry! Many tasks don’t have the mandatory fail-safes in place (Computerized testing, code evaluations, and many others).

That’s after I began to analyze extra, and quite a bit based mostly on the OneFlow mannequin determined to discover a center floor that labored for many groups. For easy tasks what I exploit is the GitHub Flow mannequin, with an actual CI / CD course of: Solely a grasp department and branches are created for options and bug fixes which are merged on to the grasp when full.

When the staff is greater, and the undertaking extra advanced (monolith anybody?), then I apply my simplified model of the OneFlow mannequin with a weekly launch. That is the mannequin I describe right here.

That is the mannequin I exploit when the undertaking is advanced and/or the corporate/consumer needs or wants to have greater management on what’s launched. That is usually linked to a number of of:

  • Previous monoliths that don’t have correct automated testing in place, and depend on QA groups (the most typical case).
  • Lack of belief by the Enterprise staff due to what occurred up to now (usually linked to monoliths, or too inexperienced badly paid groups).
  • Merchandise the place the results are fairly severe if one thing goes unsuitable (assume banking, hospitals, army, and many others).

Branches

Chances are you’ll not want all most of these branches, however the primary level is that there’s just one lengthy dwelling department: grasp.

  • grasp: The one everlasting department. The grasp department is taken into account the primary department, and may all the time be in a release-ready and production-ready state.
  • launch/x.y.z: A launch that’s being ready to be launched. As soon as tagged with the model, it’s launched. It’s then merged to grasp.
  • characteristic/XYZ-1234: A characteristic linked to a Story or Job ticket. As soon as full, it’s merged to grasp.
  • bugfix/XYZ-1234: A repair linked to a excessive, medium, low, or lowest Bug ticket. As soon as full, it’s merged to grasp.
  • hotfix/XYZ-1234: A repair linked to the best Bug ticket. It’s taken from the commit with essentially the most present model tag. As soon as tagged with the model, it’s launched. It’s then merged to grasp.

Pull Requests

Earlier than a characteristic or a bug department is merged to grasp, a Pull Request should be created by the developer, and it ought to solely be merged as soon as the Pull Request has been authorised by at the least 2 builders.

You will need to have the code nicely examined earlier than merging, which suggests having automated testing with excessive code protection and relying on the staff, perhaps authorised by each the Product Proprietor and the QA staff.

Environments

The truth that we’ve fewer branches, doesn’t imply that we’ve fewer environments. Relying on how your staff is organized, you could want all of those environments or not. Examine for the true want. However automate the entire course of.

  • Manufacturing: Reside atmosphere, the place your shoppers use the product.
  • Staging: production-like atmosphere used for the QA exams earlier than launch. No want for this if we’re doing actual CI / CD.
  • Growth: Used for improvement when not doable or fascinating to launch the whole atmosphere domestically. An excellent instance is a frontend developer wanting to make use of an API endpoint that was simply developed. May also be utilized by QAs or POs for particular testing.
  • Testing: Used for working automated exams. Created, ran and destroyed at every commit. Usually as a part of the CI / CD course of.
  • Characteristic: A much bigger characteristic that must be examined individually. Can be utilized by PO for validation. It’s created on-demand every time obligatory and destroyed after now not wanted.

When the staff and/or the undertaking are small, I exploit the Github Flow mannequin. That implies that each merge on grasp turns into a launch, with real-time CI / CD occurring.

In comparison with the OneFlow mannequin above, I take away the necessity for launch branches and the model tagging complexities related to it. I nonetheless add model tags, however they’re carried out straight on grasp.

Nothing wakes you up greater than the sensation of releasing one thing straight in manufacturing everytime you merge to grasp. YOLO 🙂

So, how has this been working for me and my groups? Very nicely, I’ve to say. There may be all the time some worry and resistance on the groups every time I suggest this, however the outcomes have been nice:

  • Happier builders really feel they’ll focus extra on improvement and fewer on forms and issues.
  • Fewer private conflicts are brought on by merge conflicts.
  • Much less human error (Fewer alternatives to merge to the unsuitable department and create merge conflicts).
  • A course of is simpler to automate for the DevOps staff.
  • A course of is simpler to grasp by Enterprise departments.

However it all the time begins with speaking with the folks and exhibiting the advantages of the alternate options. After which inviting them to be courageous and take a look at it. It’s okay to be afraid, however don’t let worry cease you from advancing to one thing higher for you and your staff.

Begin with OneFlow, with weekly or bi-weekly releases. You’re nonetheless 100% protected there, nothing will get launched except you resolve. And as you and your staff achieve belief within the course of, and automates it higher and higher, at some point you’ll have the ability to resolve to go full auto on the discharge course of for a few of your merchandise utilizing GitHub Stream. No have to rush it.

More Posts