Moose 4.8 on Jenkins

We have ported Moose to Pharo 2.0. One of the nice additions in Pharo is the command line infrastructure that brings the opportunity to have a smooth integration with a continuous integration server like Jenkins.

Here is what we did for Moose. First, let’s start with the requirements:

  1. We wanted to use the latest Pharo 2.0 image and VM so that we can provide instant feedback
  2. We wanted to load the code that comes with ConfigurationOfMoose
  3. We wanted to run all the tests that come with our configuration
  4. We wanted to setup the image with Moose-specific settings and tools

The first requirement is supported out of the box via the bash scripts supplied by Pharo:

wget --quiet -qO - http://pharo.gforge.inria.fr/ci/script/ciPharo20.sh | bash
wget --quiet -qO - http://pharo.gforge.inria.fr/ci/script/ciPharoVMLatest.sh | bash

These scripts will download the latest image and VM and will unzip them in the current folder. Easy.

The second requirement is also supported nicely by the Pharo image:

REPO=http://www.smalltalkhub.com/mc/Moose/Moose/main
./vm.sh $JOB_NAME.image config $REPO ConfigurationOfMoose --install=development

What the script does is to trigger the config command line handler that corresponds to executing the code from ConfigurationCommandLineHandler. The CommandLineHandler hierarchy is a new addition to Pharo, and it essentially lets you customize from within the image the handling of command line arguments. In this case, the scripts loads the #development version of the ConfigurationOfMoose from $REPO, and at the end it saves the image.

The third requirement was only partially supported. The image comes with a TestRunnerCommandLineHandler that lets you specify something like:

./vm.sh $JOB_NAME.image test --junit-xml-output "Moose-.*"

However, Moose is a large project formed by multiple sub-projects, and we wanted to run not only the tests that are in Moose core packages, but also the tests that come with the sub-projects. To solve this problem, I created the MooseTestRunnerCommandLineHandler subclass that specializes the default test runner with a list of packages derived from the configuration:

MooseTestRunnerCommandLineHandler>>packages
  | packages |
packages := Set new.
self addTestPackagesFrom: self mooseDevelopmentVersion to: packages.
self mooseDevelopmentVersion projects do: [ :each |
self addTestPackagesFrom: each version to: packages ].
^ packages

The code makes use of the infrastructure provided by the superclass and just lists all packages that are in the ’Tests’ group in the current configuration and in all directly referred configurations. Once this new command is available in the image, we can invoke it via the command line:

./vm.sh $JOB_NAME.image moosetest --junit-xml-output

However, still the question was how to get it in the image. Nothing simpler: I just added it in a package loaded by the configuration (the package is called Moose-Development-Tools). Thus, once the configuration is loaded, we can simply run the tests.

This final requirement can not be supported out of the box by Pharo given that it is highly specific to Moose. To support it, I created another command line handler that can install the settings:

activate
self cleanupWorld.
self installLogo.
self installGLMTheme.
self installGTInspector.
  Smalltalk snapshot: true andQuit: true

This being achieved, we can run:

./vm.sh $JOB_NAME.image mooseimagesetup

That is it. With minimal shell scripting dependency we have achieved a rather complex setup of an image. For reference, here is the whole script:

wget --quiet -qO - http://pharo.gforge.inria.fr/ci/script/ciPharo20.sh | bash
wget --quiet -qO - http://pharo.gforge.inria.fr/ci/script/ciPharoVMLatest.sh | bash
wget --quiet -qO - http://pharo.gforge.inria.fr/ci/image/PharoV20.sources
./vm.sh Pharo.image save $JOB_NAME
REPO=http://www.smalltalkhub.com/mc/Moose/Moose/main
./vm.sh $JOB_NAME.image config $REPO ConfigurationOfMoose --install=development
./vm.sh $JOB_NAME.image mooseimagesetup
./vm.sh $JOB_NAME.image moosetest --junit-xml-output
zip -r $JOB_NAME.zip $JOB_NAME.image $JOB_NAME.changes PharoV20.sources

The resulting image can be found at: https://ci.inria.fr/moose/job/moose-latest-dev-4.8/

Posted by Tudor Girba at 17 March 2013, 9:59 pm with tags moose link