Skip to content

Juicymo/drone-ruby

Repository files navigation

Juicymo Drone CI Ruby image

We use this image on a daily basis at Juicymo for Continuous Integration of Ruby on Rails apps we make for our clients.

Installation

Compiled Docker image can be pulled from: Docker Hub.

About

This is a Ruby image for Drone, inspired by 413x/ruby-2.3.3-alpine.

Intent of this image is CI testing of Ruby or Rails projects with Drone.

This image supports Drone 0.7.0 and MRI Ruby 2.5.3:

It has a bundler installed.

If you need more Ruby versions, let us know via GitHub issues or feel free to fork this Docker image or build a new one based on this one.

We use the drillster/drone-volume-cache image to smartly cache the ./bundle and ./node_modules folders to have faster builds which consume less resources because only updated gems and npm packages are reinstalled.

Usage

Just add similar .drone.yml to you project (example is compatible with Drone 0.7.0):

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    restore: true
    mount:
      - ./bundle
      - ./node_modules
    volumes:
      - /tmp/cache:/cache

  build:
    image: juicymo/drone-ruby:2.5.3
    environment:
      - RAILS_ENV=test
    commands:
      - bundle install --path ./bundle --without production,development

  rebuild-cache:
    image: drillster/drone-volume-cache
    rebuild: true
    mount:
      - ./bundle
      - ./node_modules
    volumes:
    - /tmp/cache:/cache

  test:
    image: juicymo/drone-ruby:2.5.3
    environment:
      - RAILS_ENV=test
      - DB_HOST=database
    commands:
      - bundle install --path ./bundle --without production,development
      - bundle exec rake db:create
      - bundle exec rake db:migrate
      - bundle exec rspec
      - bundle exec rake spinach

  notify:
    image: plugins/slack
    webhook: https://team.slack.com/hooks/XXX...
    channel: dev
    username: drone
    when:
      status: [ success, failure ]

services:
  database:
    image: postgres:10.5
    environment:
      - POSTGRES_USER=...
      - POSTGRES_PASSWORD=...

The example drone.yml file above shows how RSpec and Spinach can be used for BDD Testing in a Ruby on Rails application. This is what we use at Juicymo, but feel free to adjust the test step of a pipeline to suit your needs.

At Juicymo, we use GitLab which is connected to our Drone CI server. With this setup Drone is able to detect all projects from GitLab automatically. After particular Ruby on Rails project is enabled for testing in Drone, all you need to do is to add, commit and push a .drone.yml to the git repository. Drone will automatically load it and start the integration.

See source at GitHub.