How Google Said - Ninja Code Review With Gerrit

56
How Google Said Ninja Code Review created by Anuar Nurmakanov 1

Transcript of How Google Said - Ninja Code Review With Gerrit

How Google Said

Ninja Code Review

created by Anuar Nurmakanov1

-35 ?

Welcome to JavaUser Group!!!

2

About me

Kazakhstan, Karaganda

Lead SoftwareEngineer

XP/EngX Practices fan

Agile Believer

And I love Java!

3

What does it mean to be brave developer?4

IntroThe world without you...

5

When you start new project

It's new opportunity. You feel like a hero!

It's gonna be the best project!!

6

Sometimes our projects become

7

Code Smells

8

And it is tough to make it better

9

And only one thing you wannado

Run away!!!!!!10

Why?

11

Feedback matters

12

Lack of Code Review Lack of TDD Lack of Testing Pyramid

Lack of CI/CD/CD Lack of Release Strategy

and other engineering and agile practices13

A few words about CodeReview

14

How much does it cost?

15

When you fix it too late...

16

Code Review Goals

Definition of Done Collective CodeOwnership

Code Quality

Knowledge Sharing Find compromise Education

17

High-level overview

18

Code Review

Is so huuuuuge topic

Why and whenBenefitsGoalsApproachesRolesStrategiesToolsBest practicesetc

19

Your code is not yourwife! You can share

it!

First rule of Code Review

20

Pre-commit CodeReview

21

Before or After

Changes aren't in abranch.

Changes are in in abranch.

22

Make the right decision

To prevent anything like this

23

Unstable build

24

No one can make pushesJenkins is redWe cannot prepare buildFix might break one of the test environmentsIt might take lots of time

25

Who broke the build?

26

Stable build

27

What is Stable build?

Changes do not have any bugs

They do not fail existing tests

They have good test coverage

CI jobs are green

Unit/Integration/System/End-To-End tests passed

Existing functionality works

28

I wanna see everything in oneplace

Feedback from teammates

Feedback from Team Lead

Feedback from Architect

Check that build is not broken

Check any type of tests

Feedback from Architect

New violations and errors

Any blocker issues

Any static analyse

29

Trunk BasedDevelopment

30

Branching StrategiesFeature Branch DevelopmentGit FlowMainlineTrunk Based Development

31

32

33

34

35

Trunk Based DevelopmentEveryone Develops in the trunkBug fixes tooNo Code FreezeNo Merge HellBuild never broken. It's always ready tobe released

36

Don't mix them up

37

Past Experience

38

39

Only with patches

Forget about CI integration

Forget about StaticAnalyse Integration

40

Pull/Merge Requests

41

Pull requests are not purepre-commit review

You can integrate it withCI. Some have CI out of the

box

Pull requests do notshow Static Code

Analyse comments

Pull/Merge Requests

42

Gerrit Ninja

43

Who is Ninja?

Always ready to hear feedbackfrom others and make changesFixes build before it breaksmain branches buildsRemoves all SonarQubeviolationsKnows how GIT worksReady to share knowledge andhelpChecksUnit/Integration/System/End-To-End/UI tests

44

What is Gerrit?

Created for AndroidDevelopment and now it's

in Google

And lots of other companies

45

Gerrit Workflow

46

Gerrit Review

47

Diff and comments

48

Access Control

A developer cansay that it's good

Architects andLeads can approve

merge

49

Gerrit Roles Model

Group Label RangeRegistered Users Code-Review -1..+1

Team Leads Code-Review -2..+1

Architects Code-Review -2..+2

Non-interactiveusers

Code-Review -1..+1

“ For example, only Architectscan allow to make a merge

50

Patch Set

One code change, (be it a feature ora bugfix, ) is one commit. Use

Ammend to update it.

git push gerritHEAD:refs/for/master

When it'sready for

review

51

Live Demo

Let's check it out.

52

If you have a chance to try it

Do it!53

Gerrit Users

Android – LibreOffice – Wikimedia – Golang – Tuleap – Star Wars Galaxies Emulator –

https://android-review.googlesource.com/https://gerrit.libreoffice.org/https://gerrit.wikimedia.org/

https://go-review.googlesource.com/https://gerrit.tuleap.net/

http://review.swgemu.com/

54

Thanks

Feel free to ask any questions. =)

55

Have a niceweekend!

56