Ghetto-CI script is mostly self-contained, easy to understand, easy to hack into pieces, for your very own need. It is a solution that scales down. Just toss it on a corner of a server and it will churn happily and keep its owners proud. Ghetto-CI does not you give fancy web interface, statistics, bling bling or even a pony. However, it tells when someone breaks something and it is time for team building via blanket party.

Installation

As a prerequisitement you need a working Python 3 command installed on your operating system with virtualenv package. For more detailed instructions see VVV installation manual.Read these instructions especially if you get “SyntaxError: invalid syntax” when running virtualenv command – older Ubuntus ship with virtualenv which is not compatible with Python 3.

Usage

A software repository folder. This must be pre-checked out Subversion repository where ghetto-ci can run svn up command.

A command to execute unit tests and such. This command must return process exit code 0 on success. If you don’t bother writing tests, low end alternative is just lint and validate your source code.

A file storing the test status. Ghetto-CI status file keeps track whether the last round or tests succeeded or failed. You’ll get email reports only when the test status changed – there is little need to get “tests succeeded” email for every commit.

Email server details to send out notifications. Gmail works perfectly if you are in short of SMTP servers.

Example of a command for running continuous integration against /my/svn/repo checkout where bin/test command is used to run the unit tests:

# Will print output to console because email notification details are not given
ghetto-ci /my/svn/repo /tmp/status-file.ci "cd /my/svn/repo && bin/test"

If the tests status have changed since the last run, or the running fails due to internal error, the command outputs the result. The status file keeps log of the last run. Exit code 0 indicates that test succeeded.

After Ghetto-CI has been succefully run once by hand you want make it poll the repository regularly. This is can be easily achieved using UNIX cron clock daemon. Create a dummy UNIX user which can checkout and pull updates on the source code. Then create a file /etc/cron.hourly/continuous-integration-tests which will hourly run the tests (Ubuntu example):

Complex usage example

Below is a real life example , again triggered by Cron job, to poll several SVN repositories which have different test sets to run. We use GMail user to send out the email notifications. This is convenient, as we do not need to care about SMTP environment and we can easily drop this code on any server.

Internals

Future tasks

To make this script even more awesome, the following can be considered

Using some Python library as the abstraction layer over different version control systems

Using more intelligent Python library for the notifications: have email, IRC and Skype notifications (How Skype bots are built nowadays?)

Use a proper emailing library. I still believe it is easier to configure one GMail account for SMTP purposes instead of Postfix or Exim. Also GMail nicely collects outgoing messages to log even if email delivery has temporary problems.

I would be happy if someone told how to change -smtpport styles options to –smtp-port with plac

I would be also happy if someone shows how to tame shell script quotation marks properly