Share
Embed
Continuous Integration for PHP with Jenkins and Sonar
Presented at GeekCampSG on 18 August 2012.
Michael Cheng
August 18, 2012
Transcript
15 slides
-
Continuous Integration for PHP with Jenkins & Sonar GeekCampSG, Aug
18, 2012 1 Saturday, 18 August, 12 -
• What is Continuous Integration? • What is Jenkins? •
What is Sonar? • QA Tools for PHP • Demo • http://bit.ly/geekcampsg-ci-php Agenda 2 Saturday, 18 August, 12 -
What is Continuous Integration? • Continuous integration (CI) implements continuous
processes of applying quality control — small pieces of effort, applied frequently. • Quality control as a continuous process - in small chunks rather than at the end of a development cycle / iteration. • Merging of smaller manageable change sets instead of large ones. 3 Saturday, 18 August, 12 -
Important Ingredients • Version Control Software for your source code
(Git, SVN, Darcs). • Self-Testing Code. (eg. Unit Tests, BDD, Selenium) • Agreement on Agile processes to adopt (in your team). • Bonus: • Project Management Tool. (eg. Pivotal Tracker, JIRA) • Branching Strategy (for development & deployment) 4 Saturday, 18 August, 12 -
Continuous Integration in Action • Checkout mainline from code repository.
• Write tests. Fail tests. Write Code. Pass tests. Refactor. (TDD, BDD) • Commit locally. Pull changes. Resolve merge conflicts. • Run full suite of tests locally. Push commits to server. • CI runs automated tests & builds. (If fail, fix it ASAP) 5 Saturday, 18 August, 12 -
Getting the most out of CI • Keep stories small
& granular (smaller change sets). • Merge early, merge often. • Reduce the pain of resolving conflicts later. • Write tests that runs fast. • Use Mocks and test doubles as much as you can. • Automate, Automate, Automate. (or one click action). 6 Saturday, 18 August, 12 -
What is Jenkins CI? • Application that monitors executions of
repeated jobs, such as building a software project or jobs run by cron. • Building/testing software projects continuously. • Monitoring executions of externally-run jobs. • http://jenkins-ci.org/ 7 Saturday, 18 August, 12 -
What is Sonar? • Sonar is an open platform to
manage code quality. As such, it covers the 7 axes of code quality: • http://www.sonarsource.org/ 8 Saturday, 18 August, 12 -
QA Tools for PHP • Template for Jenkins Jobs for
PHP Projects by Sebastian Bergmann (of PHPUnit fame) • Kitchen sink of Quality Assurance tools. • Build automation with Apache Ant. • Compile PHP? No... :( (unless u use HipHop) • http://jenkins-php.org/ 10 Saturday, 18 August, 12 -
QA Tools for PHP • Checkstyle (for processing PHP_CodeSniffer logfiles
in Checkstyle format) • DRY (for processing phpcpd logfiles in PMD-CPD format) • PMD (for processing PHPMD logfiles in PMD format) • JDepend (for processing PHP_Depend logfiles in JDepend format) • xUnit (for processing PHPUnit logfiles in JUnit format) • Violations (for processing various logfiles) • Clover PHP (for processing PHPUnit code coverage xml output) • HTML Publisher (for publishing the PHPUnit code coverage report, for instance) • Plot (for processing phploc CSV output) 11 Saturday, 18 August, 12 -
Installation • OS that supports Java (eg. CentOS) • Java
• Install Jenkins • Install PHP-QA tools • Install Sonar • Add your project (Make sure build server supports your VCS) 13 Saturday, 18 August, 12 -
About Me • Michael Cheng • Senior Software Engineer, mig33
(http://mig33.com) • Contactable at: • http://sg.linkedin.com/in/miccheng • http://b.mig33.com/u/miccheng • http://twitter.com/coderkungfu • https://www.facebook.com/groups/sghypertextpreprocessors/ 14 Saturday, 18 August, 12