A continuous Integration process with Ruby On Rails

Ruby on Rails developer @ 

Technical Lead

Jan Varljen

Part 1: Pinpoint problems

  • in-house development (4 years)
  • large codebase
  • no tests whatsoever
  • three environments
    • development
    • staging
    • production

Part 1: Requirements

 

  • iterative development model
    • Develop something, try it out on real users
  • daily deploys
    • A couple of times a day
  • no deployment model
    • Who deployed what? Where?
  • data migrations
    • We often change the data structure

What is Continous Integration (CI)?

software development practice where members of a team integrate their work as frequently as possible to reduce integration problems and code conflicts

  1. You need tests
  2. You need to have a workflow
  3. You need to automate the workflow

What do you need?

Part 2: Write tests

  • model specs
  • controller specs
  • javascript specs
  • feature specs
  • RSpec
  • FactoryGirl
  • Shoulda gem
  • Jasmine-rails
  • Capybara

Types of tests we write

Tools we use

Problem

~ 1900 tests

~ 8 min on MacBookAir

Tests are slow

 

Developers don't run them

Part 3: Workflow

 

  • feature branching
  • master always "deployable" - don't pollute master with buggy code
  • first deploy big changes to staging environment

 

  • use automated data migrations always
  • centralised communication system

Part 4: Automate the workflow

  • set up and maintain your own CI server
  • or go with a hosted solution

Why Semaphore?

  • easy configuration (Ruby, PHP, Javascript...)
  • automatic trigger on every code commit
  • nice GUI
  • easy integrations
  • supports notifications
  • setup deploys (Capistrano, Heroku...)
  • activity feed
  • free for public projects
  • is from Serbia :)
  • http://semaphoreapp.com

Part 5: Automated code review

  • test coverage
  • code complexity
  • code smells
  • security issues
  • potential vulnerabilities

Part 6: Nag people

  • integration with Semaphore and CodeClimate
  • increased visibility/accountability
  • nags developers to solve the issues

The entire process

Next steps

  • Continuous Deployment - deploy automatically after commiting to master
  • Move to parallel spec execution
  • Move from Capistrano to Mina for deployment (deploys are now ~4:00)
  • Spin a big disco ball in the office when tests fail (using WeMo) :)

Nag me :)

Jan Varljen

jan.varljen@infinum.hr

Made with Slides.com