phingified ci and deployment strategies ipc 2012
Post on 09-May-2015
1.510 Views
Preview:
TRANSCRIPT
Phingified CI and Deployment Strategies
Oliver Mueller | TEQneers
Montag, 15. Oktober 12
About Me• Founder of and CEO at TEQneers [tɛknɪrz]
• Veteran PHP developer
• PHP since 1996 (v2.0)
• Living in Stuttgart, Germany
• like Flying, Photography, NYC
Montag, 15. Oktober 12
TEQneers
Montag, 15. Oktober 12
Agenda• Introduction to Phing
• Continues Integration
• Deployment Strategy Examples
• Q&A
Montag, 15. Oktober 12
Hands Up!• Who knows or uses build tools?
• Who is using Continues Integration?
Montag, 15. Oktober 12
Agenda• Introduction to Phing
• Continues Integration
• Deployment Strategy Examples
• Q&A
Montag, 15. Oktober 12
Phing is not GNU make• PHP build tool
• based on Apache Ant
• Originally developed by Binarycloud
• Ported to PHP5 by Hans Lellelid
• Lead is Michiel Rook
Montag, 15. Oktober 12
Why use build tools?• We all hate repetition
• We forget things
• We make mistakes
• We have other things todo
• Be independent of key staff
Montag, 15. Oktober 12
Automate it!• Helps developers,
testers, administrators
• Great for new team members
• Consolidate scripts
• Standardize tasks
• Define task dependencies
• Improve quality
• Reduce errors
• Save time
Montag, 15. Oktober 12
Installation• Use PEAR
# pear channel-discover pear.phing.info
# pear install [--alldeps] phing/phing
• Download package
# http://www.phing.info/trac/wiki/Users/Download
• GIT
# git clone git://github.com/phingofficial/phing.git
Montag, 15. Oktober 12
Phing Features• Syntax Checks (PhpLint/JsLint)
• Testing (PHPUnit/SimpleTest)
• Static code analysis (pdepend)
• Version Control (SVN/GIT)
• Documentation (ApiGen/phpDox)
• File manipulation (mv/rm/chmod)
• Compression (Zip/Gzip)
Montag, 15. Oktober 12
Montag, 15. Oktober 12
<?xml version="1.0" encoding="UTF-8" ?><project name="php-git-wrapper" default="test">
<!-- PROPERTIES --> <property name="src" value="${project.basedir}/php-git-wrapper" /> <property file="build.properties" />
<!-- FILESETS --> <fileset dir="${src}/tests" id="tests"> <include name="**/*Test.php" /> <exclude name="**/Abstracts*.php" /> </fileset>
<!-- TARGETS --> <target name="prepare" description="Prepare environment" /> <target name="test" depends="prepare" description="Start PHPUnit" /> <target name="document" description="Generate HTML documentation" />
</project>
XML Build File
Montag, 15. Oktober 12
# phing -l
Buildfile: /build.xml [property] Loading /build.propertiesDefault target:------------------------------------------------------ test Start PHPUnit Tests
Main targets:------------------------------------------------------ document Generate HTML documentation prepare Prepare environment test Start PHPUnit Tests
Target List
Montag, 15. Oktober 12
A Closer LookMontag, 15. Oktober 12
Extending Phing• Tasks (copy, mkdir, camouflage, ...)
• Types (strings, integer, boolean, DSN, ...)
• Selectors (contain, date, ...)
• Filters (replace, stripwhitespace, ...)
• Mappers (glob, regexp, ...)
• Loggers (xml, html, ...)
Montag, 15. Oktober 12
Agenda• Introduction to Phing
• Continues Integration
• Deployment Strategy Examples
• Q&A
Montag, 15. Oktober 12
Continues Integration• Automated build tools
• Short integration phase
• High frequency
• Focus on testing
• Source is XP
Montag, 15. Oktober 12
Standard CI FlowDeveloper SVN CI
Ouch!
Job
ResultsFailure?
Montag, 15. Oktober 12
Phingify CI
Montag, 15. Oktober 12
Agenda• Introduction to Phing
• Continues Integration
• Deployment Strategy Examples
• Q&A
Montag, 15. Oktober 12
DeploymentAll of the activities that make a software system available for use.
InstallationPackaging Distribution
Montag, 15. Oktober 12
What matters• Product
• Project
• Library
• Framework
• Open-Source
• Proprietary code
• Dependencies
• Code size
• Configuration complexity
Montag, 15. Oktober 12
Where matters• Self managed server
• Local server (intranet)
• Customer server
• Multi platform
• Single host
• Server farm
• Cluster
• Cloud
• Appliance
Montag, 15. Oktober 12
Who matters• Internal administrators
• DevOps
• Customers with IT department
• Some developers
• Trained staff
• Anti geek
Montag, 15. Oktober 12
Deployment Strategies
• zip
• phar
• composer
• pear
Packaging Distribution
• ftp
• scp
• rsync
• ssh
•web page
Installation
• shell scripts
• composer
• dep / apt-get
• rpm / yum
•MS WPI
• chef / puppet / juju
• version control
• zookeeper
• doozer
• noah
• accord
Montag, 15. Oktober 12
<pearpkg2 name="phing" dir="${path.src}"> <option name="outputdirectory" value="./build"/> <option name="packagefile" value="package2.xml"/> <option name="packagedirectory" value="./${path.dist}"/> <option name="channel" value="my.pear.channel.com"/> <option name="description" value="${pkg.description}"/> <option name="apiversion" value="${version}"/> <option name="releaseversion" value="${version}"/> <option name="phpdep" value="5.4.0"/> <option name="pearinstallerdep" value="1.4.6"/> <option name="packagetype" value="php"/> <option name="notes" value="${pkg.relnotes}"/> <mapping name="maintainers"> <element> <element key="handle" value="foobar"/> <element key="email" value="foobar@teqneers.de"/> </element> </mapping></pearpkg2>
PEAR
Montag, 15. Oktober 12
<pharpackage destfile="${path.build}/package.phar" basedir="./" compression="bzip2"> <fileset dir="./classes"> <include name="**" /> </fileset> <metadata> <element name="version" value="${version}" /> <element name="authors"> <element name="Foo Bar"> <element name="e-mail" value="foobar@teqneers.de" /> </element> </element> </metadata></pharpackage>
PHAR
Montag, 15. Oktober 12
MS Web Platform InstallerMyApp.zip
MyApp root folder
Manifest.xml (required)
Parameters.xml (required)
Install.sql
MyApp-admin sub folder
MyApp-content sub folder
MyApp-includes sub folder
readme.txt
license.text
web.config
various other files
Montag, 15. Oktober 12
{ "name": "teqneers/PHP-Stream-Wrapper-for-Git", "description": "Git Streamwrapper for PHP", "autoload": { "psr-0": { "TQ\\Git": "src/TQ" } }, "type": "library", "license": "MIT", "require": { "php": ">=5.3.0", "doctrine/orm": ">=2.2.3,<2.4-dev" }, "scripts": { "post-install-cmd": [ "TQ\\Git\\Setup::phingInstall" ], "post-update-cmd": [ "TQ\\Git\\Setup::phingUpdate" ] }}
Composer
Montag, 15. Oktober 12
#!/bin/sh
cd /path/php-git-wrapperunzip php-git-wrapper_1.2.3.zip
# copy configuration file to new versioncopy php-git-wrapper/config.php php-git-wrapper_1.2.3/
# remove symlink and set new onerm appln -s app_1.2.3 app
# clean uprm -rf app_1.2.2
...
Shell Script
Montag, 15. Oktober 12
name: php-git-wrappersummary: "PHP-Stream-Wrapper-for-Git"maintainer: "Foo Bar <foobar@teqneers.de>"description: |
Install the PHP Stream Wrapper for git, relates to the mysql charm. Can be scaled to multiple server
requires: db: interface: mysqlprovides: proxy: git
Juju Charm
Montag, 15. Oktober 12
Summary: A PHP stream wrapper made for GITName: php-git-wrapperVersion: 1.2Release: 3Copyright: GPLGroup: Development/LibrariesSource: https://github.com/PHP-Stream-Wrapper-for-Git.gitURL: https://github.com/teqneers/PHP-Stream-Wrapper-for-GitDistribution: Some LinuxVendor: TEQneers GmbH & Co. KGPackager: Oliver Mueller <oliver@teqneers.de>
%descriptionUse it with your projects...%buildphing rpm%installphing install%files...
RPM Build
Montag, 15. Oktober 12
<ftpdeploy host="your-server-001" username="very" password="secret" dir="/var/www/your-app"> <fileset refid="all-files"></ftpdeploy>
FTP / SCP
<scp username="very" password="secret" host="your-server-001" todir="/var/www/your-app"> <fileset refid="all-files"></scp>
Montag, 15. Oktober 12
# ask which environment to use<input propertyname="env" validargs="dev,test,prod" />
# include file depending on environmnet<property file="properties.${env}"
# start update on remote server<ssh username="${login}" password="${password}" host="${server}" command="phing -f /var/www/app/build.xml update" />
SSH
Montag, 15. Oktober 12
Q&AMontag, 15. Oktober 12
contact me if you have any questions
email: oliver@teqneers.de
twitter: @ogm66
web: www.teqneers.de
Thanks for listening
Have Fun!
Montag, 15. Oktober 12
top related