Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking...

48
Victor Ciura Technical Lead, Advanced Installer www.advancedinstaller.com April, 2019 Bristol Fighting Git Workflows @ciura_victor

Transcript of Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking...

Page 1: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

Victor Ciura Technical Lead, Advanced Installer www.advancedinstaller.com

April, 2019 Bristol

Fighting Git Workflows

@ciura_victor

Page 2: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�X

Abstract

A medium size team, on a monthly release cycle, for a mature commercial product developed for almost 15 years.

About a year ago we decided to join the rest of the Universe and switched from SVN to Git. What could go wrong there ?

Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

Prepare yourself for an equal amount of stories, gotchas and workarounds, both on the developer side of things, as well as the DevOps maintenance nightmare of CI/CD pipelines for testing, validation, daily builds and other necessary gears.

Please join me for a quick tour of a blatantly honest case-study on using Git / GitLab and related tools in a dynamic development team. Learn about the tools & scripts we built to help up navigate this treacherous land...

Spoiler: no unicorns here.

2019 Victor Ciura | @ciura_victor

Page 3: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�X2019 Victor Ciura | @ciura_victor

This session is first and foremost a blatantly honest case-study on using Git / GitLab and related tools in a dynamic development team and the struggles of switching from a centralized SCM system.

I’ll present a path we explored as we learned what works and doesn’t work for our team in terms of Git workflows, tools and accepted best practices.

I don’t think our methodology is universally applicable to other teams and it isn’t all perfect for us either, but some of the things we found out the hard way may serve others attempting similar changes.

Intro

Page 4: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

Who Am I ?

@ciura_victor

�X

Advanced Installer Clang Power Tools

2019 Victor Ciura | @ciura_victor

Page 5: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�22019 Victor Ciura | @ciura_victor

Some context

www.advancedinstaller.com

Advanced Installer

• 16 year old code base, under active development

• 3+ million lines of C++ code

• ~146 Visual Studio 2017 projects (EXEs, DLLs, LIBs)

• Windows-only deployment

• Monthly release cycle

Page 6: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�32019 Victor Ciura | @ciura_victor

Some context

www.advancedinstaller.com

Advanced Installer

• 20 C++ developers

• 5 QA engineers

• 6 solution engineers / analysts

• 3 visual designers

• 2 technical writers

Page 7: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�42019 Victor Ciura | @ciura_victor

SVN mono-repo (15yo) ⬇

GIT repo + submodules

Page 8: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�52019 Victor Ciura | @ciura_victor

✅ Learn git basics

✅ Evaluate tooling options

😧 Learn about idiomatic git workflows

✅ Prepare a migration strategy

Page 9: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�62019 Victor Ciura | @ciura_victor

Page 10: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�72019 Victor Ciura | @ciura_victor

development on trunk

Our team on SVN

seldom feature branches (experiments)

release branches (for easy patches 4.3.1)

code freeze period in each release cycle

For 15 years...

Page 11: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�82019 Victor Ciura | @ciura_victor

Our team on SVN

Recurring issues:

imprecise planning/scheduling of features

=> feature flags #

breach of code freeze period

very painful feature/change removal (rollback)

Page 12: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�92019 Victor Ciura | @ciura_victor

What we want:

(predictably) deliver high quality features on time

avoid painful rollbacks 🔥

Page 13: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�102019 Victor Ciura | @ciura_victor

A timid start down the right path...Embrace feature branches

GitFlow

Page 14: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�112019 Victor Ciura | @ciura_victor

A timid start down the right path...

Two important decisions:

- when to integrate changes into master ?

- how to integrate them ?

Page 15: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�122019 Victor Ciura | @ciura_victor

How to integrate changes (from feature branches)

Page 16: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�132019 Victor Ciura | @ciura_victor

This being git, there isn't one answer to rule them all...

Page 17: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�142019 Victor Ciura | @ciura_victor

Merging vs. Rebasing

https://medium.com/@porteneuve/getting-solid-at-git-rebase-vs-merge-4fa1a48c53aa

Page 18: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�152019 Victor Ciura | @ciura_victor

Merging vs. Rebasing

https://www.atlassian.com/git/tutorials/merging-vs-rebasing

Page 19: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�162019 Victor Ciura | @ciura_victor

Merging

https://www.atlassian.com/git/articles/git-team-workflows-merge-or-rebase

Pros:

Traceability: helps keeping information about the historical existence of a feature branch and groups together all commits part of the feature

Cons:

History can become intensely polluted by lots of merge commits => visual graphs can have many tangled branch lines, difficult to follow

Page 20: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�172019 Victor Ciura | @ciura_victor

Rebasing

https://www.atlassian.com/git/articles/git-team-workflows-merge-or-rebase

Pros:

History remains flat and readable. Clean, clear commit messages are encouraged.

Reverting a single commit is easy.

Cons:

Squashing the feature down to a handful of commits can hide context.

It's more work: using rebase to keep your feature branch updated requires that you resolve similar conflicts again and again.

You need to force push at some point.

Re-writing history can be dangerous.

Page 21: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�182019 Victor Ciura | @ciura_victor

Coming from SVN, the natural choice, seems to merge

Page 22: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�192019 Victor Ciura | @ciura_victor

Merge Mania

http://www.tugberkugurlu.com/archive/resistance-against-london-tube-map-commit-history-a-k-a--git-merge-hell

Page 23: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�202019 Victor Ciura | @ciura_victor

https://github.com/vbarbaresi/MetroGit

Paris Metro

Each metro line is represented by a branch.

A commit corresponds to a station.

A merge is a connection between one or more lines.

300 metro stations from Paris

Page 24: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�212019 Victor Ciura | @ciura_victor

Git rebase

Edvard Munch (1893)

Page 25: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�222019 Victor Ciura | @ciura_victor

In the end we opted for a clean, flat history

git rebase

Page 26: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�232019 Victor Ciura | @ciura_victor

When to integrate changes (from feature branches)

Page 27: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�242019 Victor Ciura | @ciura_victor

When to integrate changes

We started an experiment:

6 months: workflow A 6 months: workflow B

Page 28: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�252019 Victor Ciura | @ciura_victor

Workflow AFirst 6 months on git

Very similar to our old SVN workflow (min. disruption)

Approve MRs for next milestone (eg 4.6) => integrate into develop/master branch

QA on develop/master branch

Bug-fixes on multiple independent branches => develop/master

Page 29: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�262019 Victor Ciura | @ciura_victor

Workflow A drawbacks

Has many of the old SVN workflow drawbacks

Difficult to pull back integrated feature branches in case of QA issues before delivery

develop/master branch is not stable, up to release day

Bug-fixes on multiple independent branches => develop/master

Release day can be pushed back (days), when 🔥 occurs

Page 30: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�272019 Victor Ciura | @ciura_victor

Workflow BNext 6 months on git

Highly disruptive, but fits within traditional agile models...

Approve MRs for next milestone (eg 4.6) if it passes QA on time => integrate into develop/master branch

QA on feature branch + light integration testing

Bug-fixes on feature branch => often rebases needed

Page 31: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�282019 Victor Ciura | @ciura_victor

Workflow B drawbacks

If FeatureX doesn't pass QA on time => long-lived branch...

QA on feature branches => light integration testing needed

Bug-fixes on feature branch => often rebases needed

QA will pick-up testing on deferred branch and report bugs weeks after developer finished work on that component.

Page 32: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�29

Contemplating a git rebase 🤔2019 Victor Ciura | @ciura_victor

Brunel's SS Great Britain Dry dock

I thought I was done with this...

Page 33: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�302019 Victor Ciura | @ciura_victor

When to integrate changes

We're currently on Workflow B,

but the experiment is far from over* as we gain more experience with it every day....

* although its 6 months trial has passed

Page 34: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�312019 Victor Ciura | @ciura_victor

Why should we do work that can be automated ?

MR ⬇

code review ⬇

build pipeline ⬇

QA pass ⬇

merged

Page 35: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�322019 Victor Ciura | @ciura_victor

GitLab Runner Pipeline

Page 36: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�332019 Victor Ciura | @ciura_victor

GitLab Pipeline Scheduler

Page 37: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�342019 Victor Ciura | @ciura_victor

MRs with QA passed

Page 38: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�352019 Victor Ciura | @ciura_victor

MR behind master

Page 39: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�362019 Victor Ciura | @ciura_victor

MR rebased -> build pipeline

Page 40: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�372019 Victor Ciura | @ciura_victor

MR Pipeline Failed

Page 41: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�382019 Victor Ciura | @ciura_victor

MR was merged

Page 42: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�392019 Victor Ciura | @ciura_victor

Project Running Pipelines

Page 43: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�402019 Victor Ciura | @ciura_victor

🔥

Sometimes...

Page 44: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�412019 Victor Ciura | @ciura_victor

3 x🔥

Page 45: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�422019 Victor Ciura | @ciura_victor

https://en.meming.world/wiki/Hide_The_Pain_Harold

It's all good 👍

Page 46: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�432019 Victor Ciura | @ciura_victor

Tools & People

This was not just about tools & processes, rather about PEOPLE

🙍(

Thanks to my colleagues for their patience and willingness to experiment

👏

Page 47: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

�442019 Victor Ciura | @ciura_victor

I'm curious to learn about your experiences...

Page 48: Fighting Git Workflows · Centralized workflow, feature branch workflow, GitFlow, forking workflow, OneFlow, No flow ?! Oh my ! To rebase or not to rebase ? That is the question.

Victor Ciura Technical Lead, Advanced Installer www.advancedinstaller.com

April, 2019 Bristol

Fighting Git Workflows

@ciura_victor