Posts Tagged ‘continuous integration’

On version control, automated builds and continuous integration and web development

14 Feb

Most web developers don’t know the first thing about version control. That’s probably not entirely fair. They’ll download the latest version of their CMS, plugins, extensions and whatever from GitHub or even from some subversion repository. But ask them if they keep their own code in version control and you’llĀ  probably just get a blank stare. When I started in the this branch I was initially shocked to see my mentor editing a live site online. Well I got over that, put on my new cowboy hat and got down hacking out code, throwing at a server and forgetting about it.

But recently a client stated that they wanted their new TYPO3 website to done just like their java based sites with version control, automated builds and continuous integration.

Version control

Quite liberating really. I mean really, what’s all the fuss about? Pft. There are backups of the live site (well if I host them there are). If you have to work further on the site you can just tar it up copy it to your development machine and get cracking on the new code. Most of the time we are coding alone so there is no need merge our code with that of another. If the changes are significant then we can just make periodic backups of the work in progress… Ah. That last point. Periodic backups of the work in progress. That’s actually a good reason to use version control. That’s actually what you are doing by making backups.

By using formal version control you get all sorts of tools to help you track your changes, retrieve versions that did work (if you lost the plot after coding a bit too deep into the night), compare files and all sorts of other handy things. The thing is that lots of people do this every day and some of those people have thought long and hard about how to provide general and effective solutions to problems related to version control.

Once you’ve got your sources into a subversion or Git repository and you’re happily making branches, commiting changes and merging back to the trunk you might want to think about an automated build process.

Automated builds

Automated build scripts define the process required to convert your source code to a working deployable program, website or whatever other deliverable software. I like to use Apache Ant for build automation. There are other tools and you can read all about them here.

Now I have to admit that the build process for a website written in PHP is more or less trivial. The source code is all ready to run. If you really want to knock yourself out you can let your build produce a tar but that’s about it as far as building is concerned. There is nothing to compile, except maybe minify some javascripts and remove whitespace from stylesheets but that’s really about it.

On thing that an automated build really helps with configutation management. If you have factored out all the configuration in yours site then you can incorperate the application of the correct configuration into your build process. That means that you can isolate the configuration of all your environments into one file (or one set of files) and chose which configuration set to use when running an automated build of your site.

Continuous integration

Once you have version control and an automated build you can hang it all in a continuous integration environment. A continuous integration environment runs in the background or on a dedicated machine and performs a build based on some trigger. It can be used manually by using the build now button. If can be confugured to run periodically to produce a nightly build for example. Or it can be configured to run whenever changes are committed to the version control system.

Using a continous intergration environment is a nice way to glue your version control, build scripts and configuration management together to produce hassle free repeatable build results.

Selected tools

I’m using Git for version control, Apache Ant t for my build scripts and Hudson as my continuous integration environment.

On version control, automated builds and continuous integration

Stuart McFarlane

Mobile Media Constructs