Ge#ng Started with Con1nuous Integra1on Beth Tucker Long - - PowerPoint PPT Presentation

ge ng started with con1nuous integra1on
SMART_READER_LITE
LIVE PREVIEW

Ge#ng Started with Con1nuous Integra1on Beth Tucker Long - - PowerPoint PPT Presentation

Ge#ng Started with Con1nuous Integra1on Beth Tucker Long @e3betht Who am I? Beth Tucker Long (@e3betht) PHP Developer at Code Climate


slide-1
SLIDE 1

Ge#ng ¡Started ¡with ¡ Con1nuous ¡Integra1on ¡

Beth ¡Tucker ¡Long ¡ @e3betht ¡

slide-2
SLIDE 2

@e3betht

Who ¡am ¡I? ¡ Beth ¡Tucker ¡Long ¡ ¡ ¡(@e3betht) ¡

  • PHP ¡Developer ¡at ¡ ¡

Code ¡Climate ¡

  • Stay-­‑at-­‑home ¡mom ¡
  • User ¡group ¡leader ¡
  • Mentor ¡& ¡Appren1ce ¡

¡

slide-3
SLIDE 3

@e3betht

Audience ¡Par1cipa1on? ¡

  • Yes, ¡there ¡will ¡be. ¡So, ¡when ¡I ¡ask ¡the ¡audience ¡

a ¡ques1on, ¡don’t ¡be ¡shy ¡about ¡answering. ¡ ¡

slide-4
SLIDE 4

@e3betht

Will ¡you ¡cover ¡everything? ¡

  • No. ¡
slide-5
SLIDE 5

@e3betht

Con1nuous ¡Integra1on ¡

That’s ¡only ¡for ¡the ¡big ¡guys. ¡ ¡ My ¡team ¡is ¡small, ¡my ¡projects ¡are ¡small. ¡ ¡ So, ¡why ¡am ¡I ¡up ¡here? ¡

slide-6
SLIDE 6

@e3betht

What ¡is ¡con1nuous ¡integra1on? ¡

According ¡to ¡Wikipedia: ¡ ¡ In ¡soWware ¡engineering, ¡con1nuous ¡integra1on ¡(CI) ¡implements ¡ con1nuous ¡processes ¡of ¡applying ¡quality ¡control ¡— ¡small ¡ pieces ¡of ¡effort, ¡applied ¡frequently. ¡Con1nuous ¡integra1on ¡ aims ¡to ¡improve ¡the ¡quality ¡of ¡soWware, ¡and ¡to ¡reduce ¡the ¡1me ¡ taken ¡to ¡deliver ¡it, ¡by ¡replacing ¡the ¡tradi1onal ¡prac1ce ¡of ¡ applying ¡quality ¡control ¡aWer ¡comple1ng ¡all ¡development. ¡ ¡ hZp://en.wikipedia.org/wiki/Con1nuous_integra1on ¡ ¡

slide-7
SLIDE 7

@e3betht

¡ ¡

Mar1n ¡Fowler ¡-­‑ ¡ hZp://mar1nfowler.com/ar1cles/ con1nuousIntegra1on.html ¡ ¡

slide-8
SLIDE 8

@e3betht

¡ ¡

Con1nuous ¡Integra1on ¡is… ¡

…a ¡soWware ¡development ¡prac1ce ¡where ¡members ¡of ¡ a ¡team ¡integrate ¡their ¡work ¡frequently, ¡usually ¡each ¡ person ¡integrates ¡at ¡least ¡daily ¡-­‑ ¡leading ¡to ¡mul1ple ¡ integra1ons ¡per ¡day. ¡Each ¡integra1on ¡is ¡verified ¡by ¡an ¡ automated ¡build ¡(including ¡test) ¡to ¡detect ¡integra1on ¡ errors ¡as ¡quickly ¡as ¡possible. ¡Many ¡teams ¡find ¡that ¡ this ¡approach ¡leads ¡to ¡significantly ¡reduced ¡ integra1on ¡problems ¡and ¡allows ¡a ¡team ¡to ¡develop ¡ cohesive ¡soWware ¡more ¡rapidly. ¡

slide-9
SLIDE 9

@e3betht

¡ ¡

Step ¡1 ¡

Con1nuous ¡Integra1on ¡is ¡a ¡soWware ¡development ¡prac1ce ¡ where ¡members ¡of ¡a ¡team ¡integrate ¡their ¡work ¡frequently, ¡ usually ¡each ¡person ¡integrates ¡at ¡least ¡daily ¡-­‑ ¡leading ¡to ¡ mul1ple ¡integra1ons ¡per ¡day. ¡

slide-10
SLIDE 10

@e3betht

¡ ¡

Step ¡2 ¡

Each ¡integra1on ¡is ¡verified ¡by ¡an ¡automated ¡build ¡ (including ¡test) ¡to ¡detect ¡integra1on ¡errors ¡as ¡quickly ¡ as ¡possible. ¡

slide-11
SLIDE 11

@e3betht

¡ ¡

Code ¡Quality ¡

Why? ¡ ¡

  • Easier ¡to ¡test ¡
  • Easier ¡to ¡measure ¡
  • Easier ¡to ¡follow ¡
  • Streamlines ¡the ¡development ¡process ¡
slide-12
SLIDE 12

@e3betht

Use ¡the ¡"S" ¡Word ¡

Standards! ¡

slide-13
SLIDE 13

@e3betht

Use ¡the ¡"S" ¡Word ¡

Wait, ¡lots ¡of ¡standards? ¡

slide-14
SLIDE 14

@e3betht

¡ ¡

Popular ¡Standards ¡

  • PHP ¡Framework ¡Interoperability ¡Group ¡(PHP-­‑FIG) ¡-­‑ ¡

hZp://www.php-­‑fig.org/ ¡ ¡

  • PSR ¡-­‑ ¡PHP ¡Standard ¡Recommenda1on ¡ ¡
slide-15
SLIDE 15

@e3betht

PSR-­‑1 ¡

  • Files ¡must ¡only ¡use ¡<?php ¡and ¡<?= ¡tags. ¡
  • Class ¡names ¡must ¡be ¡declared ¡in ¡StudlyCaps. ¡
  • Method ¡names ¡must ¡be ¡declared ¡in ¡camelCase. ¡
slide-16
SLIDE 16

@e3betht

PSR-­‑2 ¡

  • Code ¡must ¡use ¡4 ¡spaces ¡for ¡inden1ng, ¡not ¡tabs. ¡
  • Opening ¡braces ¡must ¡go ¡on ¡the ¡next ¡line ¡for ¡

classes ¡and ¡methods, ¡but ¡on ¡the ¡same ¡line ¡for ¡ control ¡structures. ¡

  • Control ¡structure ¡keywords ¡must ¡have ¡one ¡space ¡

aWer ¡them; ¡method ¡and ¡func1on ¡calls ¡must ¡not. ¡

slide-17
SLIDE 17

@e3betht

PHP ¡Coding ¡Standards ¡Fixer ¡

hZp://cs.sensiolabs.org ¡ ¡

  • Fixes ¡"most" ¡issues ¡
  • PSR-­‑1 ¡and ¡PSR-­‑2 ¡compliant ¡
slide-18
SLIDE 18

@e3betht

Other ¡Standards ¡

  • Zend ¡Framework ¡
  • WordPress ¡
  • Symfony ¡
  • Pear ¡
slide-19
SLIDE 19

@e3betht

Custom ¡Standards ¡

  • Broad ¡
  • Strict, ¡but ¡flexible ¡
  • Based ¡on ¡a ¡“standard” ¡standard ¡
  • Everyone ¡must ¡follow ¡
slide-20
SLIDE 20

@e3betht

PHP_CodeSniffer ¡

"tokenizes ¡your ¡PHP, ¡JavaScript ¡and ¡CSS ¡files ¡and ¡ detects ¡viola1ons ¡of ¡a ¡defined ¡set ¡of ¡coding ¡ standards“ ¡ hZps://github.com/squizlabs/PHP_CodeSniffer ¡ ¡ ¡

  • Phar, ¡Composer, ¡or ¡PEAR ¡installa1on ¡
  • Single ¡file ¡or ¡en1re ¡directory ¡
  • Preset ¡and ¡customizable ¡
  • Will ¡fix ¡items ¡for ¡you ¡automa1cally ¡
slide-21
SLIDE 21

@e3betht

Output ¡

$ ¡phpcs ¡/myDir/myFile.php ¡ FILE: ¡/myDir/myFile.php ¡

  • ­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑ ¡

FOUND ¡3 ¡ERROR(S) ¡AFFECTING ¡3 ¡LINE(S) ¡

  • ­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑ ¡

¡ ¡2 ¡ ¡| ¡ERROR ¡| ¡[ ¡ ¡] ¡Missing ¡file ¡doc ¡comment ¡ ¡20 ¡| ¡ERROR ¡| ¡[x] ¡PHP ¡keywords ¡must ¡be ¡lowercase; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡expected ¡"false" ¡but ¡found ¡"FALSE" ¡ ¡47 ¡| ¡ERROR ¡| ¡[x] ¡Line ¡not ¡indented ¡correctly; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡expected ¡4 ¡spaces ¡but ¡found ¡1 ¡

  • ­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑ ¡
slide-22
SLIDE 22

@e3betht

Monitoring ¡Code ¡Quality ¡

Sensio ¡Insight ¡ hZps://insight.sensiolabs.com/ ¡ ¡

  • Free ¡for ¡open ¡source ¡
  • Integrated ¡with ¡Git ¡
  • Symfony-­‑focused, ¡but ¡works ¡with ¡any ¡PHP ¡

code ¡

  • Checks ¡PHP, ¡XML, ¡YAML, ¡Twig ¡templates, ¡

and ¡Composer ¡dependencies ¡

slide-23
SLIDE 23

@e3betht

Monitoring ¡Code ¡Quality ¡

Scru1nizer ¡ hZps://scru1nizer-­‑ci.com/ ¡ ¡

  • Free ¡for ¡open ¡source ¡
  • Integrated ¡with ¡Git ¡
  • Integrates ¡open ¡source ¡

checking ¡tools ¡like ¡ PHP_CodeSniffer ¡and ¡PHP ¡ Mess ¡Detector ¡ ¡

  • Checks ¡PHP, ¡Python, ¡and ¡

Ruby ¡

slide-24
SLIDE 24

@e3betht

Monitoring ¡Code ¡Quality ¡

Codacy ¡ hZps://www.codacy.com ¡ ¡

  • Free ¡for ¡open ¡source ¡
  • Integrated ¡with ¡Git ¡
  • Integrates ¡open ¡source ¡

checking ¡tools ¡like ¡ PHP_CodeSniffer ¡and ¡PHP ¡ Mess ¡Detector ¡ ¡

  • Checks ¡PHP, ¡Python, ¡Scala, ¡

JavaScript, ¡and ¡CSS ¡

slide-25
SLIDE 25

@e3betht

Monitoring ¡Code ¡Quality ¡

Code ¡Climate ¡ hZps://codeclimate.com/ ¡

  • Free ¡for ¡open ¡source ¡
  • Integrated ¡with ¡Git ¡
  • Hosted ¡or ¡on-­‑site ¡versions ¡
  • Quality, ¡security, ¡style, ¡ ¡

and ¡bug ¡risk ¡checks ¡

  • Checks ¡PHP, ¡JavaScript, ¡

Python, ¡and ¡Ruby ¡

  • Takes ¡security ¡seriously: ¡

codeclimate.com/security ¡ ¡

slide-26
SLIDE 26

@e3betht

Unit ¡Tests ¡

Unit ¡-­‑ ¡the ¡smallest ¡piece ¡of ¡testable ¡code ¡within ¡my ¡ applica1on ¡or ¡script. ¡ ¡ Unit ¡test ¡-­‑ ¡a ¡piece ¡of ¡code ¡that ¡executes ¡the ¡unit ¡ and ¡then ¡evaluates ¡the ¡result ¡returned. ¡

slide-27
SLIDE 27

@e3betht

Tips ¡

  • Make ¡sure ¡the ¡unit ¡is ¡small ¡enough ¡so ¡the ¡test ¡is ¡

tes1ng ¡a ¡single ¡func1on. ¡

  • Make ¡sure ¡the ¡test ¡is ¡efficient ¡enough ¡to ¡run ¡

repeatedly, ¡perhaps ¡even ¡a ¡thousand ¡1mes ¡a ¡

  • day. ¡
  • Make ¡sure ¡the ¡tests ¡do ¡not ¡depend ¡on ¡each ¡
  • ther. ¡Each ¡test ¡should ¡be ¡able ¡to ¡run ¡

completely ¡separately ¡from ¡other ¡tests. ¡

slide-28
SLIDE 28

@e3betht

¡ ¡

Saving ¡Time ¡

func1on ¡validateName($name) ¡{ ¡ ¡if ¡((strlen($name) ¡> ¡1) ¡&& ¡(strlen($name) ¡< ¡50)) ¡{ ¡ ¡ ¡if ¡(ctype_alpha(str_replace(array(" ¡",",","-­‑","'"),"",$name))) ¡{ ¡ ¡ ¡ ¡return ¡true; ¡ ¡ ¡ ¡} ¡ ¡ ¡else ¡{ ¡ ¡ ¡ ¡return ¡false; ¡ ¡ ¡} ¡ ¡} ¡ ¡ ¡else ¡{ ¡ ¡ ¡return ¡false; ¡ ¡} ¡ } ¡ ¡ assert(validateName("Beth's ¡Test ¡Name")); ¡

slide-29
SLIDE 29

@e3betht

¡ ¡

How ¡Many ¡Tests? ¡

¡ Enough ¡to ¡test ¡every ¡basic ¡func1on ¡of ¡the ¡code. ¡

slide-30
SLIDE 30

@e3betht

¡ ¡

Tes1ng ¡Frameworks ¡

  • Standardize ¡test ¡format ¡
  • Easily ¡run ¡tests ¡
  • Analyze ¡results ¡
slide-31
SLIDE 31

@e3betht

¡ ¡

PHPUnit ¡ ¡

hZp://www.phpunit.de ¡ ¡ Pros: ¡ ¡

  • Good ¡documenta1on ¡
  • Lots ¡of ¡examples ¡online ¡
  • Integrates ¡with ¡many ¡other ¡popular ¡tools ¡and ¡

pla€orms ¡ ¡ Cons: ¡

  • Command ¡line ¡only ¡
slide-32
SLIDE 32

@e3betht

¡ ¡

SimpleTest ¡ ¡

hZp://simpletest.sourceforge.net/ ¡ ¡ Pros: ¡

  • Run ¡on ¡command ¡line ¡or ¡in ¡browser ¡
  • Can ¡test ¡front-­‑end ¡func1onality ¡

¡ Cons: ¡

  • Not ¡as ¡integrated ¡as ¡PHPUnit ¡
  • No ¡longer ¡in ¡ac1ve ¡development ¡
slide-33
SLIDE 33

@e3betht

¡ ¡

atoum ¡

hZps://github.com/atoum/atoum ¡ ¡ Pros: ¡

  • Easy ¡to ¡install ¡
  • Allows ¡wri1ng ¡unit ¡tests ¡in ¡natural ¡language ¡style ¡

¡ Cons: ¡

  • Requires ¡PHP ¡5.3+ ¡
  • Newer ¡project, ¡but ¡ac1vely ¡development ¡
slide-34
SLIDE 34

@e3betht

¡ ¡

Selenium-­‑WebDriver ¡ ¡

hZp://seleniumhq.org/ ¡ ¡ ¡ Pros: ¡

  • Can ¡test ¡front-­‑end ¡func1onality ¡
  • Makes ¡direct ¡calls ¡to ¡the ¡browser ¡using ¡each ¡browser’s ¡

na1ve ¡support ¡for ¡automa1on ¡ Cons: ¡

  • Not ¡a ¡na1ve ¡PHP ¡tool, ¡but ¡bindings ¡are ¡available ¡from ¡

several ¡third-­‑par1es, ¡including ¡one ¡from ¡Facebook ¡

  • phpUnit ¡Integra1on: ¡

hZps://github.com/giorgiosironi/phpunit-­‑selenium ¡ ¡

slide-35
SLIDE 35

@e3betht

¡ ¡

Selenium ¡IDE ¡

  • Firefox ¡extension ¡
  • Record ¡or ¡write ¡scripts ¡by ¡

hand ¡ ¡

slide-36
SLIDE 36

@e3betht

¡ ¡

Automate ¡The ¡Build ¡

Perform ¡a ¡DB ¡query ¡to ¡update ¡the ¡schema, ¡clear ¡a ¡ cache, ¡upload ¡files, ¡run ¡cron ¡tasks, ¡etc. ¡ ¡ ¡

slide-37
SLIDE 37

@e3betht

¡ ¡

Phing ¡

hZp://phing.info ¡

  • PHP ¡project ¡build ¡system ¡
  • Based ¡on ¡Apache ¡Ant ¡
  • XML ¡build ¡files ¡and ¡PHP ¡"task" ¡classes ¡
  • Integrates ¡with ¡both ¡PHPUnit ¡and ¡SimpleTest ¡as ¡

well ¡as ¡phpDocumentor ¡

  • Pla€orm ¡independent ¡
  • No ¡required ¡external ¡dependencies ¡
slide-38
SLIDE 38

@e3betht

¡ ¡

Maven ¡

hZp://maven.apache.org ¡

  • Supports ¡Ant ¡tasks ¡
  • Large ¡library ¡of ¡third-­‑party ¡plug-­‑ins ¡to ¡integrate ¡
  • ther ¡con1nuous ¡integra1on ¡tools ¡
  • Helps ¡shield ¡you ¡from ¡the ¡details ¡of ¡the ¡build ¡
  • For ¡Java-­‑based ¡projects, ¡so ¡you’ll ¡need ¡Maven ¡for ¡

PHP: ¡hZp://www.php-­‑maven.org/ ¡

slide-39
SLIDE 39

@e3betht

¡ ¡

Phing ¡Buildfile: ¡ <?xml ¡version="1.0" ¡encoding="UTF-­‑8"?> ¡ ¡ <project ¡name="FooBar" ¡default="dist"> ¡ ¡ ¡ ¡ ¡ ¡<!-­‑-­‑ ¡============================================ ¡ ¡-­‑-­‑> ¡ ¡ ¡ ¡ ¡<!-­‑-­‑ ¡Target: ¡prepare ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡-­‑-­‑> ¡ ¡ ¡ ¡ ¡<!-­‑-­‑ ¡============================================ ¡ ¡-­‑-­‑> ¡ ¡ ¡ ¡ ¡<target ¡name="prepare"> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<echo ¡msg="Making ¡directory ¡./build" ¡/> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<mkdir ¡dir="./build" ¡/> ¡ ¡ ¡ ¡ ¡</target> ¡ ¡ ¡ ¡ ¡ ¡<!-­‑-­‑ ¡============================================ ¡ ¡-­‑-­‑> ¡ ¡ ¡ ¡ ¡<!-­‑-­‑ ¡Target: ¡build ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡-­‑-­‑> ¡ ¡ ¡ ¡ ¡<!-­‑-­‑ ¡============================================ ¡ ¡-­‑-­‑> ¡ ¡ ¡ ¡ ¡<target ¡name="build" ¡depends="prepare"> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<echo ¡msg="Copying ¡./about.php ¡to ¡./build ¡directory..." ¡/> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<copy ¡file="./about.php" ¡tofile="./build/about.php" ¡/> ¡ ¡ ¡ ¡ ¡</target> ¡ ¡ ¡ ¡ ¡<!-­‑-­‑ ¡============================================ ¡ ¡-­‑-­‑> ¡ ¡ ¡ ¡ ¡<!-­‑-­‑ ¡(DEFAULT) ¡ ¡Target: ¡dist ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡-­‑-­‑> ¡ ¡ ¡ ¡ ¡ ¡<!-­‑-­‑ ¡============================================ ¡ ¡-­‑-­‑> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ <target ¡name="dist" ¡depends="build"> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<echo ¡msg="Crea1ng ¡archive..." ¡/> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<tar ¡des€ile="./build/build.tar.gz" ¡ compression="gzip"> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<fileset ¡dir="./build"> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<include ¡name="*" ¡/> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡</fileset> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡</tar> ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡<echo ¡msg="Files ¡copied ¡and ¡compressed ¡in ¡build ¡ directory ¡OK!" ¡/> ¡ ¡ ¡ ¡ ¡</target> ¡ </project> ¡

slide-40
SLIDE 40

@e3betht

¡ ¡

Documenta1on ¡

phpDocumentor ¡2: ¡hZp://www.phpdoc.org/ ¡ ¡ ¡

  • Automates ¡documenta1on ¡
  • Tutorial: ¡

hZp://manual.phpdoc.org/HTMLSmartyConverter/ HandS/phpDocumentor/ tutorial_phpDocumentor.howto.pkg.html ¡ ¡

slide-41
SLIDE 41

@e3betht

¡ ¡

/** ¡ ¡ ¡* ¡Put ¡your ¡short ¡descrip1on ¡here. ¡ ¡ ¡* ¡ ¡ ¡ ¡* ¡Put ¡your ¡long ¡descrip1on ¡here. ¡ ¡ ¡ ¡* ¡You ¡may ¡use ¡mul1ple ¡lines. ¡ ¡ ¡* ¡You ¡can ¡even ¡use ¡Markdown. ¡ ¡ ¡* ¡ ¡ ¡* ¡@author ¡ ¡Beth ¡Tucker ¡Long ¡<beth@musketeers.me> ¡ ¡ ¡* ¡ ¡ ¡* ¡@since ¡1.0 ¡ ¡ ¡* ¡ ¡ ¡* ¡@param ¡int ¡$exampleA ¡ ¡This ¡is ¡a ¡method ¡parameter ¡descrip1on. ¡ ¡ ¡* ¡@param ¡string ¡$exampleB ¡This ¡is ¡another ¡example. ¡ ¡ ¡*/ ¡

slide-42
SLIDE 42

@e3betht

¡ ¡

slide-43
SLIDE 43

@e3betht

CruiseControl ¡

hZp://cruisecontrol.sourceforge.net ¡ ¡

  • WriZen ¡in ¡Java ¡
  • Binary ¡distribu1on, ¡a ¡Windows ¡Installer ¡and ¡the ¡source ¡

distribu1on ¡

  • Flexible ¡scheduling ¡system ¡
  • No1fica1ons ¡via ¡e-­‑mail, ¡messaging ¡or ¡viewing ¡HTML ¡reports ¡
  • Integrates ¡with ¡Phing ¡and ¡Maven ¡
  • PHPUnderControl ¡-­‑ ¡op1onal ¡add-­‑on ¡applica1on ¡for ¡

integra1ng ¡PHP_CodeSniffer ¡and ¡PHPUnit ¡

slide-44
SLIDE 44

@e3betht

¡ ¡

Jenkins ¡

hZp://jenkins-­‑ci.org/ ¡ ¡

  • Built ¡on ¡Java ¡
  • Installed ¡via ¡na1ve ¡packages ¡or ¡a ¡war ¡file ¡
  • Easily ¡configured ¡via ¡a ¡GUI ¡web ¡interface ¡
  • Extensive ¡library ¡of ¡third-­‑party ¡plug-­‑ins ¡
  • RSS, ¡e-­‑mail ¡or ¡instant ¡messaging ¡op1ons ¡for ¡build ¡

no1fica1ons ¡

  • Template ¡for ¡Jenkins ¡Jobs ¡for ¡PHP ¡Projects ¡ ¡

(by ¡Sebas1an ¡Bergmann) ¡

slide-45
SLIDE 45

@e3betht

¡ ¡

Travis ¡CI ¡

hZps://travis-­‑ci.org/ ¡ ¡

  • Integrated ¡with ¡GitHub ¡
  • Comments ¡right ¡on ¡your ¡PR ¡
  • Build ¡no1fica1ons ¡in ¡Slack, ¡HipChat, ¡e-­‑mail ¡and ¡

more ¡

  • Test ¡against ¡mul1ple ¡versions ¡of ¡a ¡language ¡
  • Easy ¡to ¡customize ¡
slide-46
SLIDE 46

@e3betht

¡ ¡

Repor1ng ¡

SonarQube ¡ hZp://www.sonarqube.org/ ¡ ¡

  • Integrates ¡with ¡Hudson ¡and ¡Jenkins ¡
  • PHP ¡plug-­‑in ¡to ¡integrate ¡it ¡directly ¡with ¡other ¡PHP-­‑based ¡

tools ¡

  • Web-­‑based ¡applica1on ¡
  • Overall ¡“health” ¡of ¡project, ¡drill ¡down ¡for ¡details ¡
  • Includes ¡TimeMachine ¡
slide-47
SLIDE 47

@e3betht

¡ ¡

Technical ¡Debt ¡

Integrated ¡into ¡core ¡as ¡of ¡version ¡4. ¡ ¡ Assigns ¡a ¡technical ¡debt ¡value ¡

  • The ¡debt ¡ra5o ¡-­‑ ¡The ¡debt ¡ra1o ¡gives ¡a ¡percentage ¡of ¡the ¡current ¡

technical ¡debt ¡of ¡the ¡project ¡versus ¡the ¡total ¡possible ¡debt ¡for ¡the ¡

  • project. ¡
  • The ¡cost ¡to ¡reimburse ¡– ¡A ¡dollar ¡amount ¡for ¡what ¡it ¡would ¡cost ¡to ¡

clean ¡all ¡defects. ¡

  • The ¡work ¡to ¡reimburse ¡-­‑ ¡The ¡cost ¡expressed ¡in ¡work ¡days. ¡
slide-48
SLIDE 48

@e3betht

¡ ¡

A ¡LiZle ¡Help ¡

TeamCity ¡by ¡JetBrains ¡is ¡a ¡user-­‑friendly ¡con1nuous ¡ integra1on ¡(CI) ¡server ¡for ¡professional ¡developers ¡and ¡ build ¡engineers, ¡like ¡ourselves. ¡It ¡is ¡trivial ¡to ¡set ¡up ¡ and ¡absolutely ¡free ¡for ¡small ¡teams. ¡ ¡ hZp://www.jetbrains.com/teamcity/ ¡ ¡

slide-49
SLIDE 49

@e3betht

¡ ¡

A ¡LiZle ¡Help ¡

NetBeans ¡has ¡support ¡for ¡con1nuous ¡integra1on ¡ (Template ¡for ¡Jenkins ¡Jobs ¡for ¡PHP ¡Projects) ¡ ¡ More ¡info: ¡ hZps://blogs.oracle.com/netbeansphp/entry/ con1nuous_integra1on_support ¡ ¡

slide-50
SLIDE 50

@e3betht

¡ ¡

Yes, ¡But… ¡

  • Project ¡is ¡small, ¡budget ¡is ¡small… ¡
  • Evaluate ¡which ¡tools ¡are ¡worthwhile ¡to ¡your ¡

specific ¡project. ¡

slide-51
SLIDE 51

@e3betht

Make ¡It ¡a ¡Deliverable ¡

Consider ¡including ¡unit ¡tests ¡or ¡code ¡cost/coverage ¡ reports ¡in ¡your ¡deliverables ¡to ¡your ¡customers ¡as ¡an ¡ added ¡value ¡to ¡them ¡(and ¡you ¡down ¡the ¡road). ¡

slide-52
SLIDE 52

@e3betht

¡ ¡

Quick ¡Recap ¡

  • Coding ¡Standards ¡-­‑> ¡PHP_CodeSniffer ¡
  • Code ¡Review ¡-­‑> ¡Insight, ¡Scru1nizer, ¡Code ¡Climate ¡
  • Unit ¡Tests ¡-­‑> ¡PHPUnit, ¡SimpleTest, ¡Selenium ¡
  • Build ¡-­‑> ¡Phing ¡or ¡Maven ¡
  • CI ¡Tools ¡-­‑> ¡CruiseControl, ¡Jenkins, ¡Travis ¡CI ¡
  • Documenta1on ¡-­‑> ¡PHP_Documentor ¡
  • Repor1ng ¡-­‑> ¡SonarQube ¡
slide-53
SLIDE 53

@e3betht

¡ ¡

Project ¡

A ¡customer ¡hires ¡you ¡to ¡create ¡a ¡registra1on ¡form ¡for ¡ a ¡one-­‑1me ¡event. ¡It’s ¡a ¡small ¡customer ¡with ¡a ¡small ¡

  • budget. ¡It ¡should ¡take ¡a ¡couple ¡hundred ¡lines ¡of ¡code ¡

in ¡a ¡single ¡file, ¡results ¡will ¡be ¡e-­‑mailed. ¡It ¡will ¡be ¡ tested ¡by ¡the ¡event ¡staff ¡and ¡the ¡marke1ng ¡ department ¡on ¡the ¡live ¡site ¡as ¡they ¡do ¡not ¡have ¡a ¡test ¡ environment, ¡and ¡it ¡will ¡only ¡be ¡live ¡for ¡two ¡months. ¡ ¡

slide-54
SLIDE 54

@e3betht

¡ ¡

Ideas ¡

What ¡they ¡need: ¡ ¡

  • 1. If ¡they ¡do ¡not ¡have ¡an ¡in-­‑house ¡standard ¡for ¡you ¡to ¡

follow, ¡write ¡it ¡using ¡one ¡of ¡the ¡main ¡coding ¡ standards, ¡like ¡PSR-­‑2. ¡

  • 2. Create ¡unit ¡tests ¡for ¡it. ¡ ¡

¡ What ¡they ¡don’t ¡need: ¡

  • 1. In-­‑depth ¡repor1ng ¡
  • 2. Full ¡automa1on, ¡including ¡build. ¡
  • 3. Documenta1on ¡
slide-55
SLIDE 55

@e3betht

¡ ¡

Project ¡

A ¡customer ¡hires ¡you ¡for ¡an ¡ongoing ¡project. ¡On ¡the ¡ 15th ¡of ¡every ¡month, ¡they ¡need ¡you ¡to ¡go ¡in ¡and ¡add ¡a ¡ new ¡survey ¡to ¡collect ¡data ¡and ¡write ¡it ¡to ¡a ¡database. ¡ The ¡previous ¡month’s ¡survey ¡data ¡needs ¡to ¡be ¡backed ¡ up ¡and ¡cleared ¡out ¡of ¡the ¡database ¡when ¡the ¡new ¡ survey ¡goes ¡live. ¡ ¡

slide-56
SLIDE 56

@e3betht

¡ ¡

Ideas ¡

What ¡they ¡need: ¡ ¡

  • 1. If ¡they ¡do ¡not ¡have ¡an ¡in-­‑house ¡standard ¡for ¡you ¡to ¡

follow, ¡write ¡it ¡using ¡one ¡of ¡the ¡main ¡coding ¡ standards, ¡like ¡PSR-­‑2. ¡

  • 2. Create ¡unit ¡tests ¡for ¡it ¡and ¡use ¡a ¡tes1ng ¡framework. ¡
  • 3. Automate ¡the ¡build. ¡

¡ What ¡they ¡don’t ¡need: ¡

  • 1. In-­‑depth ¡repor1ng ¡(Maybe) ¡
  • 2. Documenta1on ¡(Maybe) ¡
slide-57
SLIDE 57

@e3betht

¡ ¡

Project ¡

A ¡customer ¡hires ¡you ¡to ¡write ¡one ¡part ¡of ¡a ¡very ¡large ¡

  • applica1on. ¡Other ¡consultants ¡that ¡you ¡do ¡not ¡have ¡

access ¡to ¡will ¡be ¡working ¡on ¡other ¡parts ¡of ¡the ¡ applica1on ¡at ¡the ¡same ¡1me. ¡

slide-58
SLIDE 58

@e3betht

¡ ¡

Ideas ¡

What ¡they ¡need: ¡ ¡

  • 1. All ¡of ¡it ¡

In ¡this ¡situa1on, ¡see ¡if ¡you ¡can ¡convince ¡them ¡to ¡get ¡ everyone ¡working ¡on ¡a ¡unified ¡con1nuous ¡ integra1on ¡pla€orm ¡u1lizing ¡a ¡complete ¡suite ¡of ¡ con1nuous ¡integra1on ¡tools ¡from ¡standards ¡to ¡ documenta1on ¡and ¡fully ¡automated ¡everywhere ¡in ¡

  • between. ¡ ¡
slide-59
SLIDE 59

@e3betht

¡ ¡

Take ¡Away ¡#1 ¡ Not ¡everything ¡is ¡beneficial ¡enough ¡to ¡ use ¡in ¡every ¡situa1on, ¡so ¡choose ¡the ¡ right ¡tools ¡for ¡your ¡project ¡and ¡needs. ¡

slide-60
SLIDE 60

@e3betht

¡ ¡

Take ¡Away ¡#2 ¡ The ¡fewer ¡steps ¡I ¡have ¡to ¡ ¡ remember ¡to ¡do ¡manually, ¡ ¡ the ¡more ¡successful ¡ ¡ my ¡project ¡will ¡be. ¡

slide-61
SLIDE 61

@e3betht

¡ ¡

Resources ¡

CruiseControl ¡-­‑ ¡hZp://cruisecontrol.sourceforge.net ¡ ¡ Guide ¡to ¡wri1ng ¡your ¡own ¡PHP_CodeSniffer ¡standards ¡(Official) ¡-­‑ ¡ hZp://pear.php.net/manual/en/package.php.php-­‑codesniffer.coding-­‑standard-­‑tutorial.php ¡ ¡ Guide ¡to ¡wri1ng ¡your ¡own ¡PHP_CodeSniffer ¡standards ¡(Alternate) ¡-­‑ ¡ hZp://luhman.org/blog/2009/12/17/se#ng-­‑custom-­‑coding-­‑standards-­‑php-­‑codesniffer ¡ ¡ Jenkins ¡-­‑ ¡hZp://jenkins-­‑ci.org ¡ ¡ Maven ¡-­‑ ¡hZp://www.php-­‑maven.org ¡ ¡ PEAR ¡coding ¡standard ¡-­‑ ¡hZp://pear.php.net/manual/en/standards.php ¡ ¡ PEAR ¡Package ¡Manager ¡Installa1on ¡-­‑ ¡hZp://pear.php.net/manual/en/installa1on.php ¡ ¡ PEAR ¡Packages ¡Installa1on ¡-­‑ ¡hZp://pear.php.net/manual/en/guide.users.commandline.installing.php ¡ ¡ PEAR2 ¡coding ¡standard ¡-­‑ ¡hZp://pear.php.net/manual/en/pear2cs.rules.php ¡ ¡ Phing ¡-­‑ ¡hZp://phing.info ¡ ¡ PHP ¡Standards ¡Working ¡Group ¡-­‑ ¡hZp://groups.google.com/group/php-­‑standards ¡ ¡ PHP_CodeSniffer ¡-­‑ ¡hZp://pear.php.net/package/PHP_CodeSniffer ¡ ¡ phpDocumentor ¡2 ¡-­‑ ¡hZp://www.phpdoc.org/ ¡ ¡ PHPUnit ¡-­‑ ¡hZp://www.phpunit.de/manual/3.6/en/automa1ng-­‑tests.html ¡ ¡ phpUnderControl ¡-­‑ ¡hZp://phpundercontrol.org ¡ ¡ Selenium ¡-­‑ ¡hZp://seleniumhq.org/ ¡ ¡ SimpleTest ¡-­‑ ¡hZp://simpletest.sourceforge.net/ ¡ SonarQube ¡– ¡hZp://www.sonarqube.org/ ¡ ¡ Sonar ¡PHP ¡Plug-­‑in ¡-­‑ ¡hZp://docs.codehaus.org/display/SONAR/PHP+Plugin ¡ Sonar ¡Technical ¡Debt ¡Plugin ¡-­‑ ¡hZp://docs.codehaus.org/display/SONAR/Technical+Debt+Plugin ¡ ¡ Template ¡for ¡Jenkins ¡Jobs ¡for ¡PHP ¡Projects ¡by ¡Sebas1an ¡Bergmann ¡-­‑ ¡hZp://jenkins-­‑php.org ¡ ¡ Travis ¡CI ¡-­‑ ¡hZps://travis-­‑ci.org/ ¡ ¡

slide-62
SLIDE 62

@e3betht

¡ ¡

PHP ¡Mentoring ¡ hZp://phpmentoring.org/ ¡

slide-63
SLIDE 63

@e3betht

Find ¡Me ¡

  • TwiZer ¡and ¡IRC: ¡e3betht ¡

¡

  • Madison ¡PHP ¡User ¡Group ¡(Meetup) ¡ ¡

hZp://www.madisonphp.com ¡ ¡

  • E-­‑mail: ¡Beth@CodeClimate.com ¡ ¡ ¡

¡

slide-64
SLIDE 64

@e3betht

Feedback ¡

hZps://joind.in/14544 ¡ ¡ ¡

¡ ¡

Slides ¡Available: ¡ hZp://www.TreelineDesign.com/slides ¡ ¡ E-­‑mail: ¡Beth@CodeClimate.com ¡ ¡ ¡ ¡ ¡