Wednesday 17 July 2013

Continuous Integration with python and blink(1)

I've been a big fan of Continuous Integration / Continuous Deployment (CI/CD) for some time now, and we've been using it with great success in my day job building something awesome. But that setup is team-focussed, uses a build server, is triggered from revision code checkin, with promotion between development, test, staging and production environments gated by passing all the regression suite tests.  We even spam the team over Jabber when tests fail.

At the other end of the scale is personal software development on my laptop.  Here I want something more lightweight that the excellent Jenkins, and I want builds triggered not on revision control checkins, but on every save.  In essence, something compatible with the team-focussed environment, but something even more agile and lightweight.

My personal development is more likely to be in Python than anything else, and I like to write my code test-first. Normally I have three windows open - one editor for code, one editor for test code, and one shell with onchange.pl running to automatically run tests every time a change is made to tests or code.  This is all well and good, but it still requires me to take my focus off the editors and check that tests succeeded in the shell window.  This can be improved upon.

Enter my latest toy, blink(1).  It's a USB multi-coloured RGB LED, that's easily programmable with code available.  But they provide a command-line tool which is sufficient for many use cases.

With a small script that checks the result of the test run, it's very easy to get blink(1) to give me a quick visual indication of the result of my development efforts.  It's as simple as...

#!/bin/bash
nosetests
if [ "$?" -eq "1" ]
then
    blink1-tool --red --blink 5 2>&1 >/dev/null
else
    blink1-tool --green 2>&1 >/dev/null
    sleep 5
fi
blink1-tool --off 2>&1 >/dev/null



Maybe it's a bit gimmicky, but so far I'm loving it!

Monday 8 July 2013

Updating Ubuntu's sources.list

Frustratingly, I keep on forgetting to:

sudo bash
cd /etc/apt
cp sources.list sources.list-`date +%Y%m%d`
sed -i 's#au.archive.ubuntu.com/ubuntu#mirror.internode.on.net/pub/ubuntu/ubuntu#g' sources.list

This really needs to be a post-install hook or something.