Skip to content

Configuring lernanta on hudson

jtatum edited this page May 25, 2011 · 3 revisions

Hudson

Hudson is a continuous integration server. It watches the source tree for changes and when they're detected, obtains the source and performs some actions. Here we'll document how that's configured for Lernanta. The server is online at coin.5cat.com.

Goals

  1. Run migrations and unit tests on each commit
  2. Setup a bleeding edge test server where the latest code can be previewed

General

The Hudson 2.0.0 .deb was installed on a relatively clean Ubuntu 11.04 Linode. All apt-gettable prerequisites for Lernanta development were installed (as described in the readme.) An email server and other system packages were installed.

Hudson configuration

Hudson was configured for a basic security model (although this will likely change). Hudson emails were configured.

Three Hudson plugins were installed: git, github and setenv

The lernanta job

The job is configured with the git:// URL to the sources. The job is set to poll every 5 minutes for updates. @@TODO: Switch to a github commit hook. Email notification is enabled for p2pu-dev@lists.p2pu.org. Publish junit test report is configured for nosetests.xml. Setenv is configured as follows:

PATH=.env/bin:$PATH

Four build scripts are configured representing four stages:

#!/bin/bash
# Step 1 - create virtualenv
if [ -d ".env" ]; then
        echo "**> virtualenv exists"
else
        echo "**> creating virtualenv"
        virtualenv .env
fi 
source .env/bin/activate

#!/bin/bash
# Step 2 - install required dependencies
pip install -r requirements/compiled.txt
pip install -r requirements/prod.txt
pip install -r requirements/dev.txt

#!/bin/bash
# Step 3 - copy settings_local if needed
if [ -f "settings_local.py" ]; then
        echo "**> settings_local.py exists"
else
        echo "**> creating settings_local.py"
        # cp settings_local.dist.py settings_local.py
fi 

@@TODO: At some point, we should commit a settings_local for Hudson.


#!/bin/bash
# Step 4 - sync and tests
source .env/bin/activate
./manage.py syncdb --noinput --migrate
FORCE_DB=True ./manage.py test --with-xunit --noinput

Tests failed due to a line in settings.py: ROOT_URLCONF = 'lernanta.urls' The paths are not the same as a typical Lernanta developer's paths. This was overridden in settings_local.py: ROOT_URLCONF = 'urls' This might be a bug in Lernanta but is easy enough to work around.