CircleCI Setup For Ruby On Rails Project

Ben Tran
3 min readMay 20, 2022

This is the ultimate guide for your next Ruby on Rails project setup on Github with CircleCI for continuous integration.

Why should we use CircleCI for Ruby on Rails app?

  • CircleCI is a Continuous Integration and Delivery cloud provider.
  • It integrates with Github, so using both of them together is as simple as creating your accounts and setting up the Ruby on Rails project.
  • No custom servers maintenance, just going through some web forms and you are all set.
  • No credit card information required, a perfect combination to start small with your project and pay for what you use as you grow.
  • CircleCI provides an intuitive, well-organized UI with all the information required to establish the problem that occurs when the new code was integrated into the Github hosted codebase.
  • It is crucial to set up the Continuous Integration system for any project, let alone Ruby on Rails, from the first day of the development.
  • This is a great way to avoid a lot of technical debt, protect yourself from common mistakes and enforce certain standards that make working with Ruby on Rails codebase pleasing and its maintenance much, much easier.

Get Started

Before you start, please visit CircleCI document to understand all configurations: https://circleci.com/docs/2.0/config-intro/?section=configuration

1. Add CircleCI Config To Rails

Add .circleci/config.yml file with below content to your project root path.

Note: Please make sure that you have installed enough gems to able to run above commands (rubocop, brakeman, rspec, simplecov, …). You can also remove useless steps in your case.

2. Connect & Setup Github Project On CircleCI

Follow the instructions below to create your CircleCI account linked to your Github account, and to set up the Ruby on Rails project continuous integration.

  • Sign up with Github
  • After register account successfully, go to Projects from left side menu, then on your target project select a Set Up Project
  • Select a config.yml file for the project — We have already added it so please use the 2nd option, remember to input correct branch name.
  • If everything goes well, you will have success build screen like this

3. Require CircleCI status check to pass before merging

  • Go to Github project settings, add new rule for your branch
  • Input correct branch matching pattern, add ci:circleci build status check

Done!

--

--