The Way I Used Magnum CI for Rails Test


Magnum CI is a CI environment which we can use for free. Here, I wrote how I setup Rails code into Magnum CI, which is managed at Bitbucket.

Basically, applying codes in Bitbucket to Magnum CI is not so difficult.

Add Magnum Enivronment

For Magnum CI integration, add Magnum Environment. If you use test environment in Magnum CI, you don’t have to do anything.

  • Add magnum.rb into config/environments directory. And create magnum environment label.
  • Add secret key for magnum environment. Write it into config/secrets.yml.
  • Add database setting for magnum environment. Write it into config/database.yml. My database.yml is like the following, username is root.
  • Create other magnum setting when you have to change other setting for magnum environment.

That’s it. Change in Rails code is finished. After that, you can control Magnum CI build setting by creating script, but I didn’t. In my project, I controlled build instruction on Magnum CI setting page.

Build Configuration

I assume you can add project to Magnum CI. Here, I wrote Build Configuration setting example I used in the project.

Runtime Version

Set version of Ruby. When I used Magnum CI, the maximum Ruby version that Magnum CI supported was Ruby 2.2.0. On the other hand, Ruby version of the project was 2.2.2. I couldn’t set correct Ruby version in here, but I apply correct version in other way. Build Steps can solve it, that I wrote below.

Resources

Add required database or redis, etc.

Environment Variables

Set RAILS_ENV.

Build Step
Before installation

Set correct Ruby version.

Before test execution

Create DB.

Test suit commands

Execute test.