Build Process
The beginnings of
Continuous Integration
Who Am I?

CTO/Founder of Pamiris, Inc.

Extensive NPO board service

Overseen payroll conversions
& HRIS implementations with
over 600 employees

BBA, MIS from EWU 2004
(manga cum laude, BGS)
Build Process: wait... why?
But PHP doesn't have to compile!
definition - Build /bild/: The
process of preparing
software for deployment
and/or distribution.
PHP Deployment Prep
● Lint (syntax/compile error checking)
● SLOC (source lines of code) metrics
● Unit testing
● Code coverage analysis
● Functional Testing
● Code style checking
● Cyclomatic and N-path complexity
● Code duplication (DRY)
PHP Deployment Prep:
Again... why should we?
● Ability to track code quality trends
● More people/other teams can contribute
safely(er. Saflier. Saferly?)
● Accountability for all
● Nervous sleep deprivation, anyone?
● Sooner found = cheaper fixed
Quick Feedback
● Total coverage statistics
● Complexity measures
● CRAP index: Change Risk Anti- Patterns
● Pass/No Pass for tests
PHP Deployment Prep:
Why doesn't it happen?
● “Never enough time”
● “It worked fine on my machine”
● “It didn't seem like a big deal”
If it isn't easy and repeatable,
it won't happen.
Build Automation:
Make it easy, make it happen
Developers and QA folks alike should be able to
check a commit with absolute ease. The easier it
is, the more it happens. The more it happens,
the better the code is.
Build Automation Tools
● GNU Make
http://www.gnu.org/software/make/
● Phing (PHing Is Not Gnu make)
http://www.phing.info/
● Apache Ant
http://ant.apache.org/
Start Simple
● Get PHPUnit, behat, PHPspec or other unit
test running
● Get PHPLOC to run (composer makes it easy)
● Install a build automation tool
● MAGIC... ??? … profit.
Basic build.xml
My current build.xml
● ~175 Lines
● Tasks:
– Build (prepare, lint, phpunit-ci, phploc, pdepend,
phpmd)
– Build-parallel
– Phpcs (coding standard analysis)
– Selenium-install
– Selenium-start -stop
Ant usage: running the build
● Just 'ant' will autorun the whole build command
● 'ant <target-name>' will run any part of it
● Different targets for different uses
– Developers WIP: fast unit tests w/o coverage or
functional
– Developers pre-commit: all tests plus coverage
– Metric tracking: all static analysis tools
– Pre-deploy: all of the above
Next Steps
● Flesh out other valuable build steps
● Store build results
● Automate build on check-in with
Jenkins/TravisCI
● Add charting (trend display)
● Continuous deployment
Resources
● http://jenkins-php.org/index.html
● Integrating PHP Projects with Jenkins by
Sebastian Bergman (on Kindle, etc)
● http://marcelog.github.io/articles/ci_jenkins_hudson
● https://www.phptesting.org/

Lighning Talk: PHP build process

  • 1.
    Build Process The beginningsof Continuous Integration
  • 2.
    Who Am I?  CTO/Founderof Pamiris, Inc.  Extensive NPO board service  Overseen payroll conversions & HRIS implementations with over 600 employees  BBA, MIS from EWU 2004 (manga cum laude, BGS)
  • 3.
    Build Process: wait...why? But PHP doesn't have to compile! definition - Build /bild/: The process of preparing software for deployment and/or distribution.
  • 4.
    PHP Deployment Prep ●Lint (syntax/compile error checking) ● SLOC (source lines of code) metrics ● Unit testing ● Code coverage analysis ● Functional Testing ● Code style checking ● Cyclomatic and N-path complexity ● Code duplication (DRY)
  • 5.
    PHP Deployment Prep: Again...why should we? ● Ability to track code quality trends ● More people/other teams can contribute safely(er. Saflier. Saferly?) ● Accountability for all ● Nervous sleep deprivation, anyone? ● Sooner found = cheaper fixed
  • 6.
    Quick Feedback ● Totalcoverage statistics ● Complexity measures ● CRAP index: Change Risk Anti- Patterns ● Pass/No Pass for tests
  • 8.
    PHP Deployment Prep: Whydoesn't it happen? ● “Never enough time” ● “It worked fine on my machine” ● “It didn't seem like a big deal” If it isn't easy and repeatable, it won't happen.
  • 9.
    Build Automation: Make iteasy, make it happen Developers and QA folks alike should be able to check a commit with absolute ease. The easier it is, the more it happens. The more it happens, the better the code is.
  • 10.
    Build Automation Tools ●GNU Make http://www.gnu.org/software/make/ ● Phing (PHing Is Not Gnu make) http://www.phing.info/ ● Apache Ant http://ant.apache.org/
  • 11.
    Start Simple ● GetPHPUnit, behat, PHPspec or other unit test running ● Get PHPLOC to run (composer makes it easy) ● Install a build automation tool ● MAGIC... ??? … profit.
  • 12.
  • 13.
    My current build.xml ●~175 Lines ● Tasks: – Build (prepare, lint, phpunit-ci, phploc, pdepend, phpmd) – Build-parallel – Phpcs (coding standard analysis) – Selenium-install – Selenium-start -stop
  • 14.
    Ant usage: runningthe build ● Just 'ant' will autorun the whole build command ● 'ant <target-name>' will run any part of it ● Different targets for different uses – Developers WIP: fast unit tests w/o coverage or functional – Developers pre-commit: all tests plus coverage – Metric tracking: all static analysis tools – Pre-deploy: all of the above
  • 18.
    Next Steps ● Fleshout other valuable build steps ● Store build results ● Automate build on check-in with Jenkins/TravisCI ● Add charting (trend display) ● Continuous deployment
  • 19.
    Resources ● http://jenkins-php.org/index.html ● IntegratingPHP Projects with Jenkins by Sebastian Bergman (on Kindle, etc) ● http://marcelog.github.io/articles/ci_jenkins_hudson ● https://www.phptesting.org/