In Dragonlance, Kenders are fast and clever. They are impossible to contain and unrelenting in the pursuit of their goal - exactly the kind of traits you want in a continuous integration (CI) environment.

The problem

Tests are fundamental to the development of any software package. Fortunately we have many tools available for testing. Unfortunately with so much choice available it may be difficult to know which tools any given project relies on to execute its tests.

When moving a project from one continuous integration environment to another, a mistake in the configuration could lead to tests not being executed in the new environment.

Also, long gone are the days when a project would pass all its tests after running only functional or unit tests. These days we have tools to check for security problems, security problems in dependent gems, in the UI’s Javascript, in the quality of the code, etc.

It is very challenging and tedious for any given project to know what tools have to be executed and to execute them all without forgetting anything. And it is error prone to manually run a command in the development environment that may be different from the command run by the CI or by other developers which produce inconsistent results.

The solution

We created Kender to solve these problems.

Kender scans your Gemfile and greedily finds tools that you want to call in your CI. If you have rspec in your Gemfile, it will run it, same for Cucumber. If you are using ParallelTest, Kender will run them in parallel for you. If you have analysis tools such as brakeman or bundle_audit for security holes, consistency_fail or reek, Kender will run all these tools and fail the build if any of them returns an error.

You do not need to remember what tools are in use for each specific project, once Kender is installed you will have available a rake task called ‘ci’ which will run all the testing tools available in the Gemfile of the project.

Example

You are in charge of improving security of some Rails projects. You first clone some project you’ve never touched before:

$ git clone some_interesting_project

Install its dependencies:

$ bundle install 

And run all the tests:

$ rake ci 

‘rake ci’ will use Dicebag to setup the project and create all the databases needed for testing. Thanks to Dicebag, an engineer does not need to worry about setting up a testing environment, test can be run just after bundle installing the dependencies of the project. When you verify the new project is passing all its tests with ‘rake ci’ then you know you can work safely on this project.

You open the Gemfile and add a security tool (in this case, Brakeman) to it.

$ gem 'brakeman'

Run ‘rake ci’ again. Now we can see in the output that Brakeman was also run and it passed with no security problems. You push the changes. From now on, not only you but the CI and every other developer is going to run Brakeman when they run the tests. And of course, if ever Brakeman finds a security issue, it will fail the tests for this project.

Where to find it

Kender is this simple and yet is this useful. You can find its code at https://github.com/mdsol/kender and its rubygem information at http://rubygems.org/gems/kender

Like DiceBag, Kender is opensource and available for you to use.

Analytics