+ All Categories
Home > Documents > DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration...

DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration...

Date post: 16-Jul-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
178
CODE REVIEW AND CONTINUOUS INTEGRATION DAVE LIDDAMENT
Transcript
Page 1: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

CODE REVIEW AND CONTINUOUS INTEGRATION

DAVE LIDDAMENT

Page 2: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs
Page 3: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

MORAL OF THE STORY

▸ We all make mistakes.

▸ If the mistakes are spotted and rectified quickly the consequences of the mistakes are minimal.

▸ We want to make mistakes easy to spot.

Page 4: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HOW CAN WE REDUCE THE COST OF SOFTWARE DEVELOPMENT?

QUESTION

Page 5: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

COST OF A BUGCo

st

DESIGN WRITING CODE

TEST RELEASE MAINTENANCE

FIND BUGS SOONER

Page 6: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHY CODE REVIEW AND CONTINUOUS INTEGRATION

TYPES OF BUGS

▸ Code doesn’t work

▸ Code works but does the wrong thing

▸ Poor architecture / design

Page 7: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

COST OF A BADLY WRITTEN CODECo

st

Time

COST TO DEVELOP SIMILAR SIZED FEATURE OVER TIME

Page 8: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHY DO BUGS HAPPENRa

te o

f int

rodu

cing

bug

s

Experience / Skill

SKILL AND EXPERIENCE VS BUGS

Page 9: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHY THIS TALK

CODE REVIEW AND CI DONE WELL WILL REDUCE COST OF SOFTWARE DEVELOPMENT

▸ Fewer bugs

▸ Cheaper bugs

▸ Write code quicker (by making code easier to read)

▸ Providing opportunities to quickly up skill team members

Page 10: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

Pay attention!

@DaveLiddament

Dave Liddament @daveliddament

Lamp Bristol

15+ years software development (PHP, Java, Python, C)

Organise PHP-SW user group and Bristol PHP Training

Page 11: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

AGENDA

▸ Why

▸ Code review

▸ CI - Continuous Integration

▸ Branching strategies

▸ Github / Bitbucket setup

▸ CircleCI example

▸ Wrap up

Page 12: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HOW

HOW ARE WE GOING TO REDUCE COSTS?

Page 13: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HOW

HOW ARE WE GOING TO REDUCE COSTS?

▸ Code Review

▸ github

▸ bitbucket

▸ gerrit

Page 14: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HOW

HOW ARE WE GOING TO REDUCE COSTS?

▸ Code Review

▸ github

▸ bitbucket

▸ gerrit

▸ Continuous Integration (CI)

▸ Jenkins

▸ CircleCI

▸ Travis CI

Page 15: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

CODE REVIEW

Page 16: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

CODE REVIEW SHOULD FOCUS ON THINGS THAT CAN NOT BE AUTOMATED

Page 17: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

DO THE TESTS TEST THE REQUIRED FUNCTIONALITY?

Page 18: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

ARE THE TESTS ADEQUATE?

Page 19: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

ARE THERE ENOUGH TESTS

IS THIS ENOUGH TESTING?

Scenario: Navigation at T junction in a cave Given: I am coming up to a T. When: Before I pass the T junction. Then: I should drop a cookie.

Page 20: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

ARE THERE ENOUGH TESTS

HOW MANY TESTS DO WE NEED?

class Person {

/** * Returns true if the person is 18 or over */ public function isAdult(): bool {

.. some implementation .. }

}

Page 21: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

ARE THERE ENOUGH TESTS

HOW MANY TESTS DO WE NEED (2)?

/** * @param int $id * @return bool * @throws NotFoundException */ public function isAllowed(int $id): bool { .. some implementation .. }

Page 22: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

WILL I UNDERSTAND THIS CODE IN 6 MONTHS TIME?

Page 23: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

COST OF WRITING CODE CODE

Page 24: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

“THE RATIO OF TIME SPENT READING VERSUS WRITING IS WELL OVER 10 TO 1. WE ARE CONSTANTLY READING OLD CODE AS PART OF THE EFFORT TO WRITE NEW CODE. … [THEREFORE,] MAKING IT EASY TO READ MAKES IT EASIER TO WRITE.”

Robert C. Martin (Clean Code)

COST OF WRITING CODE CODE

Page 25: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HOW CAN WE REDUCE COST OF WRITING CODE

COST OF WRITING CODE

Reading Writing

Page 26: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HOW CAN WE REDUCE COST OF WRITING CODE

COST OF WRITING CODE

Reading Writing

Page 27: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HOW CAN WE REDUCE COST OF WRITING CODE

COST OF WRITING CODE

Reading Writing

Page 28: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HOW CAN WE REDUCE COST OF WRITING CODE

COST OF WRITING CODE

Reading Writing

Code review + refactor

Page 29: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

WHAT DOES THIS CODE DO?

$userFields = [ 'Username', 'Email', 'FirstName', 'LastName', 'Phone', ];

foreach ($userFields as $key) { if ($userDetails->{'get'.$key}()) { $user->{'set'.$key}($userDetails->{'get'.$key}()); } }

Page 30: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

WHAT DOES THIS CODE DO? (2)

if ($userDetails->getUsername()) { $user->setUsername($userDetails->getUsername()); } if ($userDetails->getEmail()) { $user->setEmail($userDetails->getEmail()); } if ($userDetails->getFirstName()) { $user->setFirstName($userDetails->getFirstName()); } if ($userDetails->getLastName()) { $user->setLastName($userDetails->getLastName()); } if ($userDetails->getPhone()) { $user->setPhone($userDetails->getPhone()); }

Page 31: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

/** * Represents a location in the UK. (eg city, town, village) */ class Location {

… other methods …

private $url;

/** * @return string URL */ public function getUrl(): string {

return $this->url; }

Page 32: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

WHAT IS URL?/** * Represents a location in the UK. (eg city, town, village) */ class Location {

… other methods …

private $url;

/** * @return string URL */ public function getUrl(): string {

return $this->url; }

Page 33: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

if ($agent->getType() === 1) {

… do something …

}

Page 34: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WILL I UNDERSTAND THE CODE IN 6 MONTHS TIME?

WHAT DOES 1 MEAN?

if ($agent->getType() === 1) {

… do something …

}

Page 35: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

ARE WE FOLLOWING PROJECT CONVENTIONS?

Page 36: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

ARE WE FOLLOWING PROJECT CONVENTIONS

interface LocationRepository {

public function findClosestTo($point);

public function findByName($name);

public function findBySlug($slug);

public function searchForLocation($name, $type);

public function findAllByType($type);

}

Page 37: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

ARE WE FOLLOWING PROJECT CONVENTIONS

INCONSISTENT METHOD NAMEinterface LocationRepository {

public function findClosestTo($point);

public function findByName($name);

public function findBySlug($slug);

public function searchForLocation($name, $type);

public function findAllByType($type);

}

Page 38: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs
Page 39: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

IS CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE?

Page 40: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS

class MarketingCampaign {

public function addAddress($address) { .. some implementation .. }

}

Page 41: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS (2)

class MarketingCampaign {

public function addEmailAddress($emailAddress) { .. some implementation .. }

}

Page 42: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS (3)

class MarketingCampaign {

/** * Adds email address, person will then be messaged * as part of the campaign. */ public function addEmailAddress($emailAddress) { .. some implementation .. }

}

Page 43: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS (4)

class MarketingCampaign { /** * Add email address that should received campaign * messages. */ public function addEmailAddress(string $emailAddress ): void { .. some implementation .. }

}

Page 44: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

IS THE CODE AS OBVIOUS AND EXPLICIT AS IT POSSIBLY CAN BE

HOW DO WE MAKE THIS MORE OBVIOUS (5)

class MarketingCampaign { /** * Add email address that should received campaign * messages. */ public function addEmailAddress( EmailAddress $emailAddress ): void { .. some implementation .. }

}

Page 45: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

CAN I UNDERSTAND THE FUNCTIONALITY OF THE CODE WITHOUT READING IT?

Page 46: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs
Page 47: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs
Page 48: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

HAS DEFENSIVE CODING BEEN USED?

Page 49: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HAS DEFENSIVE CODING BEEN USED

switch($status) {

case ‘started’: … do something … break;

case ‘finished’: … do something … break;

case ‘quit’: … do something … break; }

Page 50: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HAS DEFENSIVE CODING BEEN USED

MISSING DEFAULTswitch($status) {

case ‘started’: … do something … break;

case ‘finished’: … do something … break;

case ‘quit’: … do something … break; }

Page 51: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HAS DEFENSIVE CODING BEEN USED

/** * Set status (one of started|finished|quit) * * @param string $status */ public function setStatus(string $status): void { $this->status = $status; }

Page 52: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HAS DEFENSIVE CODING BEEN USED

MISSING CHECK THAT STATUS IS A VALID VALUE/** * Set status (one of started|finished|quit) * * @param string $status */ public function setStatus(string $status): void { $this->status = $status; }

Page 53: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

HAS TECHNICAL DEBT BEEN DOCUMENTED?

Page 54: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

HAS TECHNICAL DEBT BEEN DOCUMENTED

ALL TODO COMMENTS MUST REFERENCE A TICKET

// TODO: Refactor to method https://trello.com/c/Aaa123

… some hacky code …

Page 55: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS TO ASK IN CODE REVIEW

CAN ARCHITECTURE BE IMPROVED? (E.G. SOLID)

Page 56: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

BENEFITS OF CODE REVIEW

Page 57: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

CODE REVIEW BENEFITS

SOMEONE IS WATCHING YOU

Page 58: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

CODE REVIEW BENEFITS

LEARNING AND UPSKILLING

Page 59: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

BENEFITS OF CODE REVIEW

COST OF WRITING CODE

Reading Writing

Page 60: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

BENEFITS OF CODE REVIEW

COST OF WRITING CODE

Reading Writing

Code review + refactor

Page 61: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

BENEFITS OF CODE REVIEWCo

st

Time

COST TO DEVELOP SIMILAR SIZED FEATURE OVER TIME

Page 62: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

BENEFITS OF CODE REVIEWCo

st

DESIGN WRITING CODE

TEST RELEASE MAINTENANCE

FIND BUGS SOONER

Page 63: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

BENEFITS OF CODE REVIEW

QUICK FEEDBACK LOOP

Page 64: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHO SHOULD CONDUCT CODE REVIEWS

EVERYONE SHOULD CODE REVIEW

Page 65: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHAT MAKES CODE EASY TO REVIEW?

Page 66: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

ASK PROGRAMMERS TO REVIEW 10 LINES OF CODE THEY’LL FIND 10 ISSUES…

Anyone who’s done code review

WHAT MAKES CODE EASY TO TO REVIEW

Page 67: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

ASK THEM TO DO 500 LINES THEY’LL SAY IT’S GOOD TO GO

Anyone who’s done code review

WHAT MAKES CODE EASY TO TO REVIEW

Page 68: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

GOOD REVIEW COMMENTS

Page 69: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

GOOD REVIEW COMMENTS

DON’T BE A ****

Page 70: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

GOOD REVIEW COMMENTS

NOT CRITICAL OF THE CODE AUTHOR

Page 71: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

GOOD REVIEW COMMENTS

STATE PROBLEM AND SUGGEST IMPROVEMENT

Page 72: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

GOOD REVIEW COMMENTS

LINK TO STACK OVERFLOW, BLOG, ETC

Page 73: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

GOOD REVIEW COMMENTS

USE: ‘LET’S CHAT’

Page 74: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

GOOD REVIEW COMMENTS

USE ‘QUESTION:’

Page 75: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

RECEIVING REVIEW COMMENTS

Page 76: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

RECEIVING REVIEW COMMENTS

DON’T BE A ****

Page 77: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

CONTINUOUS INTEGRATION

Page 78: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

TASKS FOR CONTINUOUS INTEGRATION

RUNNING TESTS

Page 79: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

TASKS FOR CONTINUOUS INTEGRATION

LINT (OR BETTER STILL PARALLEL LINT)

composer require —dev jakub-onderka/php-parallel-lint

vendor/bin/parallel-lint src

Page 80: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

TASKS FOR CONTINUOUS INTEGRATION

CODE STYLE CHECKERcomposer require —dev friendsofphp/php-cs-fixer

vendor/bin/php-cs-fixer fix —dry-run src

# Or locally to fix problems

vendor/bin/php-cs-fixer fix src

Page 81: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

TASKS FOR CONTINUOUS INTEGRATION

VAR DUMP CHECKER

composer require —dev jakub-onderka/php-var-dump-check

vendor/bin/php-var-dump-check —no-colors src

Page 82: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

TASKS FOR CONTINUOUS INTEGRATION

SYMFONY

bin/console lint:twig app

bin/console lint:yaml app

Page 83: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

TASKS FOR CONTINUOUS INTEGRATION

STATIC ANALYSIS TOOLS?

Page 84: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

BENEFITS OF CONTINUOUS INTEGRATION

QUICK FEEDBACK LOOP

Page 85: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

CODE REVIEW & CONTINUOUS INTEGRATION RECAP

Page 86: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

BRANCHING STRATEGIES

Page 87: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

IDEAL PROCESS

ESSENTIAL - CODE CAN ONLY BE DEPLOYED IF:

▸CI passes

▸Code review passes

Page 88: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

IDEAL PROCESS

IDEALLY - OTHERS ONLY DEVELOP WITH CODE THAT:

▸CI passes

▸Code review passes

Page 89: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUESTS

Page 90: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch Feature branch

Page 91: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch Pull Request (PR) based on Feature branch

CI pass

Code review sign off

Page 92: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

CI pass

Code review sign off

Page 93: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

CI fails

OR

Code review not signed off

Page 94: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

CI fails

OR

Code review not signed off

X X

Page 95: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

Page 96: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

Page 97: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

Page 98: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

Page 99: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

X X

Page 100: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

Page 101: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

Page 102: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

PULL REQUEST METHOD

Master branch

Page 103: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

LET’S SET THIS UP

Page 104: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

LET’S SET THIS UPPS It’s really easy

Page 105: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

THE PROCESS IS IMPORTANT NOT THE TOOLS

Page 106: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

GITHUB

Page 107: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 108: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 109: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 110: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 111: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 112: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 113: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 114: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 115: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 116: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 117: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 118: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP GITHUB

Page 119: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

BITBUCKET

Page 120: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 121: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 122: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 123: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 124: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 125: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 126: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 127: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 128: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 129: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 130: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 131: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 132: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP BITBUCKET

Page 133: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

CIRCLE CI

Page 134: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE CI

Page 135: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE CI

Page 136: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE CI

Page 137: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE CI

Page 138: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE CI

Page 139: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE CI

Page 140: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE CI

Page 141: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE CI

Page 142: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE CI

Page 143: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

CIRCLE CI V1 OR V2

Page 144: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

CIRCLE.YML

Page 145: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

CIRCLE BUILD STAGES

▸ machine

▸ dependencies

▸ database

▸ compile

▸ test

▸ deploy

Page 146: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

STEPS WITHIN STAGE

▸ pre

▸ override

▸ post

Page 147: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

MACHINE

machine: timezone: Europe/London php: version: 5.6.22 environment: COMPOSER_CACHE_DIR: ~/.cache/composer

Page 148: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

MACHINE

machine: timezone: Europe/London php: version: 5.6.22 environment: COMPOSER_CACHE_DIR: ~/.cache/composer

Page 149: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

MACHINE

machine: timezone: Europe/London php: version: 5.6.22 environment: COMPOSER_CACHE_DIR: ~/.cache/composer

Page 150: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

MACHINE

machine: timezone: Europe/London php: version: 5.6.22 environment: COMPOSER_CACHE_DIR: ~/.cache/composer

Page 151: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPENDENCIES

dependencies: cache_directories: - "~/.cache/composer" pre: - echo "date.timezone = Europe/London" >> \ /opt/circleci/php/$(phpenv global)/etc/php.ini

Page 152: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPENDENCIES

dependencies: cache_directories: - "~/.cache/composer" pre: - echo "date.timezone = Europe/London" >> \ /opt/circleci/php/$(phpenv global)/etc/php.ini

Page 153: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPENDENCIES

dependencies: cache_directories: - "~/.cache/composer" pre: - echo "date.timezone = Europe/London" >> \ /opt/circleci/php/$(phpenv global)/etc/php.ini

Page 154: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPENDENCIES

dependencies: cache_directories: - "~/.cache/composer" pre: - echo "date.timezone = Europe/London" >> \ /opt/circleci/php/$(phpenv global)/etc/php.ini - cp app/config/parameters.yml.circle \ app/config/parameters.yml

Page 155: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DATABASE

database: override: - mysql -u ubuntu -e "CREATE DATABASE testdb;" - createdb testdb2 - psql -c "CREATE EXTENSION postgis;" testdb2 - app/console doctrine:schema:create -—env=test

Page 156: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DATABASE

database: override: - mysql -u ubuntu -e "CREATE DATABASE testdb;" - createdb testdb2 - psql -c "CREATE EXTENSION postgis;" testdb2 - app/console doctrine:schema:create -—env=test

Page 157: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DATABASE

database: override: - mysql -u ubuntu -e "CREATE DATABASE testdb;" - createdb testdb2 - psql -c "CREATE EXTENSION postgis;" testdb2 - app/console doctrine:schema:create -—env=test

Page 158: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DATABASE

database: override: - mysql -u ubuntu -e "CREATE DATABASE testdb;" - createdb testdb2 - psql -c "CREATE EXTENSION postgis;" testdb2 - app/console doctrine:schema:create -—env=test

Page 159: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DATABASE

database: override: - mysql -u ubuntu -e "CREATE DATABASE testdb;" - createdb testdb2 - psql -c "CREATE EXTENSION postgis;" testdb2 - app/console doctrine:schema:create -—env=test

Page 160: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

COMPILE

compile: override: - bin/parallel-lint src - app/console lint:twig app - app/console lint:yaml app - bin/var-dump-check --no-colors src - bin/php-cs-fixer fix --dry-run src

Page 161: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

COMPILE

compile: override: - bin/parallel-lint src - app/console lint:twig app - app/console lint:yaml app - bin/var-dump-check --no-colors src - bin/php-cs-fixer fix --dry-run src

Page 162: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

TEST

test: pre: - mkdir -p $CIRCLE_TEST_REPORTS/phpunit override: - bin/phpunit -c app/phpunit.xml.dist \ -—log-junit $CIRCLE_TEST_REPORTS/phpunit/junit.xml \ -d memory_limit=512M

Page 163: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

TEST

test: pre: - mkdir -p $CIRCLE_TEST_REPORTS/phpunit override: - bin/phpunit -c app/phpunit.xml.dist \ -—log-junit $CIRCLE_TEST_REPORTS/phpunit/junit.xml \ -d memory_limit=512M

Page 164: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

TEST

test: pre: - mkdir -p $CIRCLE_TEST_REPORTS/phpunit override: - bin/phpunit -c app/phpunit.xml.dist \ -—log-junit $CIRCLE_TEST_REPORTS/phpunit/junit.xml \ -d memory_limit=512M

Page 165: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

TEST

test: pre: - mkdir -p $CIRCLE_TEST_REPORTS/phpunit override: - bin/phpunit -c app/phpunit.xml.dist \ -—log-junit $CIRCLE_TEST_REPORTS/phpunit/junit.xml \ -d memory_limit=512M

Page 166: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPLOY

deployment: live: branch: master commands: - ssh [email protected] \ ”bash --login -c 'deploy "$CIRCLE_SHA1"'"

Page 167: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPLOY

deployment: live: branch: master commands: - ssh [email protected] \ ”bash --login -c 'deploy "$CIRCLE_SHA1"'"

Page 168: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPLOY

deployment: live: branch: master commands: - ssh [email protected] \ ”bash --login -c 'deploy "$CIRCLE_SHA1"'"

Page 169: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPLOY

deployment: live: branch: master commands: - ssh [email protected] \ ”bash --login -c 'deploy "$CIRCLE_SHA1"'"

Page 170: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPLOY

deployment: live: branch: master commands: - ssh [email protected] \ ”bash --login -c 'deploy "$CIRCLE_SHA1"'"

Page 171: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

SETUP CIRCLE.YML

DEPLOY

deployment: live: branch: master commands: - ssh [email protected] \ ”bash --login -c 'deploy "$CIRCLE_SHA1"'"

Page 172: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHEN YOU TRY THIS AT HOME

TIPS

Page 173: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHEN YOU TRY THIS AT HOME

TIPS

▸ https://github.com/DaveLiddament/circle_demo_project

▸ Branches called step-01, step-02, etc

Page 174: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHEN YOU TRY THIS AT HOME

TIPS

▸ https://github.com/DaveLiddament/circle_demo_project

▸ Branches called step-01, step-02, etc

▸ Build things up in steps.

▸ Run only unit tests first

▸ Then get integration tests running

Page 175: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHEN YOU TRY THIS AT HOME

TIPS

Page 176: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WHEN YOU TRY THIS AT HOME

TIPS

Page 177: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

WRAP UP

SUMMARY

▸ Code review and CI done well reduce costs

▸ Fast feedback

▸ Fewer bugs

▸ Cleaner code (which means faster development)

▸ Quickly up skill new people to the project

▸ Tools today mean you can set up quickly

Page 178: DAVE LIDDAMENT CODE REVIEW AND CONTINUOUS INTEGRATION · why code review and continuous integration types of bugs ... cost to develop similar sized feature over time. why do bugs

QUESTIONS


Recommended