Top Banner
Continuous Integration für PHP Der heilige Gral der Codequalität? 1
28

Continuous Integration für PHP

Dec 01, 2014

Download

Technology

Sebastian Bauer

Slides meines Talks über Continuous Integration auf den Linuxwochen Wien 2011.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Continuous Integration für PHP

Continuous  Integration  für  PHPDer  heilige  Gral  der  Codequalität?

1

Page 2: Continuous Integration für PHP

Vorstellung

o Sebastian  Bauer

o SCRUM  Master

o LOTUM  GmbH

o Bad  Nauheim,  bei  Frankfurt/Main

o Unsere  Ideen  -­‐>  unsere  Projekte!

o @litervollmilch  /  blog.gjl-­‐network.net

2

Page 3: Continuous Integration für PHP

CONTIN..-­‐WHAT?!

3

Page 4: Continuous Integration für PHP

4

Page 5: Continuous Integration für PHP

5

„You  cannot  controlwhat  you  cannot  measure“

 -­‐  Tom  DeMarco

Page 6: Continuous Integration für PHP

6

AGILE  PRINZIPIEN

Page 7: Continuous Integration für PHP

7

FRÜHE  INTEGRATION

Page 8: Continuous Integration für PHP

8

Page 9: Continuous Integration für PHP

9

Page 10: Continuous Integration für PHP

Kernbestandteile  von  CI

o Automatisierte  Tests

o Statische  Code-­‐Analyse

o Compilierung  des  Codes

o Generierung  derDokumentation

10

Page 11: Continuous Integration für PHP

Und  womit  macht  man  das?

11

Jenkins  (Hudson)

CruiseControl

Atlassian

Page 12: Continuous Integration für PHP

12

UND  WIE  SIEHT‘S  AUS  MIT  ...

Page 13: Continuous Integration für PHP

PHP_Depend

PHPMD

PHP  Unit

PHPDoc

Syntax

PHP_CodeSniffer

CRAP

Code  Coverage

13

Page 14: Continuous Integration für PHP

Unit  Tests  mit  PHP  Unit

o Unit  Tests  wichtigster  und  elementarer  Bestandteil!

o Code  Coverage  messen

o Broken  Tests  sofort  fixen!

o Test  it  right!

14

Page 15: Continuous Integration für PHP

Tests  mit  Selenium

o Testen  von  UI  Funktionalität

o Mit  verschiedenen  Browsern

o Ermöglicht  Browser-­‐Kompatibilität  abzudecken

15

Page 16: Continuous Integration für PHP

Statische  Code-­‐Analyse  mit  PHP_Depend

o Umfangsmetrikeno LOC  -­‐  Lines  of  Codeo CLOC  -­‐  Comment  Lines  of  Codeo ELOC  -­‐  Executable  Lines  of  Code

o Komplexitätsmetrikeno CCN  -­‐  Zyklische  Komplexitäto NPath  Komplexität

o OO-­‐Metrikeno Code  Ranko Chidamber  &  Kemerer  (WMC,  DIT,  NOC,  .  .  .  )

16

Page 17: Continuous Integration für PHP

PHP_CodeSniffer

o Coding  Standard  Validierung

o PHP,  JavaScript,  CSS

o Regelsets:o PEARo Zendo Squizo .  .  .o

17

Page 18: Continuous Integration für PHP

PHP_CodeSniffer

o Sniffs  z.B.  für:o Tabs/Spaces  Policyo Naming  Conventions  (PASCAL/Camel-­‐Casing  usw)o Code  Indentiono Klammersetzungo Platzierung  von  Operatoreno .  .  .

18

Page 19: Continuous Integration für PHP

PHP_CodeSniffer

o Um  eigene  Sniffs  erweitern:o Debug  Code  findeno Verwendung  von  Deprecated  Codeo  .  .  .o Alles  ist  möglich  ;)

19

Page 20: Continuous Integration für PHP

20

IMMER  AUF  VOLLGAS?

Page 21: Continuous Integration für PHP

Builds  nach  Commit

21

Automatischer  Build

•  Unit  Tests•  Syntax  Tests•  Coding  Standards•  Copy/Paste  Detection•  Dokumentation•  ...

Page 22: Continuous Integration für PHP

Niemand  wartet  gerne!

22

Automatischer  Build

•  Unit  Tests•  Syntax  Tests•  Coding  Standards•  Copy/Paste  Detection

Täglicher  Build

•  Unit  Tests•  Syntax  Tests•  Coding  Standards•  Copy/Paste  Detection•  +  Dokumentation•  +  sonstige  Intensivere              Tests

Page 23: Continuous Integration für PHP

23

ALSO  ALLES  COOL?

Page 24: Continuous Integration für PHP

Einführung  mit  Bedacht

o Neue  Projekte  -­‐>  kein  Problem

o Legacy  Code  -­‐>  tausende  Violations

o Neue  Fehler  gehen  unter  /  werden  ignoriert

o Lösung:o alte  Violations  fixeno getrennte  Tests  für  Legacy  Code  /  modifizierte  Dateien

24

Page 25: Continuous Integration für PHP

25

FAZIT?

Page 26: Continuous Integration für PHP

Fazit

o CI  ist  extrem  wichtig

o Spart  Zeit!

o Spart  Kosten!

o Erspart  viel  Frust

o Verringert  Risiko

o Gibt  ein  gutes  Gefühl  :)

26

Page 27: Continuous Integration für PHP

Fazit

o CI  System  hinstellen  reicht  nicht

o Konzept  für  Projekt  benötigto Welche  Checks  zu  welcher  Zeit?o Richtige  Metriken  messen  UND  überwachen

o CI  muss  „gelebt“  werden

o Auftretende  Probleme  müssen  angegangen  werden

27

Page 28: Continuous Integration für PHP

DAS  WAR‘S!Fragen?

28

Rocke  mit  uns  das  Web!www.lotum.de/jobs