Top Banner
Net Perspective, LLC. http://www.net-perspective.com/ The Modern Development Workflow Automate, Automate, Automate!
12

Modern Development Workflow

May 09, 2015

Download

Technology

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: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

The Modern Development Workflow

Automate, Automate, Automate!

Page 2: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

Before We Get Started…

• I Am…o Daniel Cousineau

• Lead Developer at Net Perspective, LLC• [email protected]

• We Are…o Full service web agency (development) firm based out of

College Station, TX

• About This Topic…o The utilities presented are biased towards PHP and OSS

• All are interchangeable with other languages and utilities

o We are always improving and getting bettero Constructive feedback always welcome

Page 3: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

Source Control

• More than 0 people on a project?o Extremely beneficial when with 2+ member teams

• SVN most popularo Integration with EVERYTHING

o Showing its age• No native branching/tagging

• GIT: the up-and-coming superstaro Not as well integrated

o Still new

Page 4: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

Unit Testing

• Old and Busted: GDB, New Hotness: TDDo Test Driven Development

o Write tests first, code until all tests pass

• PHPUnit very popularo Based on the NUnit standard (JUnit sound familiar?)

• Our Goal? 100% Code Coverageo Means every line of source code should have been

executed at least once when all tests completed

• Alternativeso SimpleTest, PHPT

Page 5: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

PHPUnit Exampleclass StringFunctionTest extends PHPUnit_Framework_TestCase

{

protected $_fixture;

//Run before each test

public function setup()

{

$this->_fixture = fopen("./sample.txt","w");

}

//Example test

public function testStrToLower()

{

//Object is constructed/destructed after each test

//Data saved to a fixture here is not preserved for the next test

$actual = strtolower("SaMpLe");

$expected = "sample";

$this->assertEquals($expected, $actual, 'comment here'); //

}

//Run after each test

public function tearDown()

{

fclose($this->_fixture);

}

}

Page 6: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

Build Management

• Generating AutoDoc, running UnitTests, and packaging is BORINGo “Laziness is the mark of a great developer” – Me

• Automate with Phingo Native PHP build system based on the popular Ant build

system for Javao $ phing TARGET_NAME

• Looks for build.xml which contains commands for the target

o Tasks for running PHPDoc, PHPUnit, and…

Page 7: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

Phing Example<?xml version="1.0" encoding="UTF-8"?>

<project name="Latitude" default="dist" basedir=".">

<target name="test">

<phpunit2 haltonfailure=“true" haltonerror=“true" printsummary="true">

<batchtest classpath="${project.basedir}/lib">

<fileset dir="${project.basedir}/tests">

<include name="RouteTest.php" />

<include name="DispatcherTest.php" />

</fileset>

</batchtest>

</phpunit2>

</target>

<target name="doc" depends="test">

<phpdoctitle="Latitude API Documentation“ destdir="${project.basedir}/docs/“ >

<fileset dir="${project.basedir}/lib" >

<include name="**/*.php" />

</fileset>

</phpdoc>

</target>

<target name="dist" depends="test">

<tar destfile="${project.basedir}/builds/latitude.tar.gz" compression="gzip">

<fileset dir="${project.basedir}">

<exclude name="**/.svn" />

</fileset>

</tar>

</target>

</project>

Page 8: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

Database Versioning

• DBDeployo Every change to the database structure is in its own .sql file

• Each file contains the SQL to perform changes and SQL to roll back those changes

o Revision information is stored in a table

o Written in Java, Phing has a native port built in

o Only version structure changes and default values• Don’t version test and sample data!

Page 9: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

DBDeploy Example

--//

CREATE TABLE `sample` (

`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,

PRIMARY KEY (`id`) )

ENGINE = InnoDB;

--//@UNDO

DROP TABLE `sample`;

--//

db/deltas/1-REVISION_COMMENT.sql

Page 10: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

Continuous Integration

• Wraps everything up…o Ties in Versioning, Build Management, Unit Testing, [Auto

generated Documentation, ] and Database Versioning

o Xinc (http://xinc.eu) (a pure PHP solution)• CruiseControl would be the “original”

• What happens?o CI monitors SVN working copy

o On update, run specified build script (Phing)• Phing generates UnitTest reports, API documentation, and archive files

• Deployment code (upload to live server?)

• UnitTest fails? Build fails

o Store “artifacts” (generated reports, etc.) for each build

Page 11: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

Xinc Interface

Notice the Deliverable and Documentation artifacts

Page 12: Modern Development Workflow

Net Perspective, LLC.http://www.net-perspective.com/

In Conclusion

Charts Are Useless

Pac Man

Blinky