Skip to content

Instantly share code, notes, and snippets.

@yahonda
Last active January 20, 2021 02:34
Show Gist options
  • Save yahonda/19b13ffc4bdd62d4f3e3ff4361161e78 to your computer and use it in GitHub Desktop.
Save yahonda/19b13ffc4bdd62d4f3e3ff4361161e78 to your computer and use it in GitHub Desktop.
How to run Rails unit test locally

Purpose

This document explains how to run Rails CI against Ruby master locally. This document is provided as is.

Prerequisite

  • Docker
  • git

Steps

Clone rails/rails repository and clone buildkite repository

git clone https://github.com/rails/rails.git
cd rails
git clone https://github.com/rails/buildkite-config .buildkite/

Build "base" image

RUBY_IMAGE=rubylang/ruby:master-nightly-focal docker-compose -f .buildkite/docker-compose.yml build base

Run CI using the base image

Action Cable

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm postgresdb runner actioncable 'rake test'

Action Mailbox

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner actionmailbox 'rake test'

Action Mailer

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner actionmailer 'rake test'

Action Pack

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner actionpack 'rake test'

Action Text

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner actiontext 'rake test'

Action View

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner actionview 'rake test'

Active Job

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner activejob 'rake test'

Active Model

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner activemodel 'rake test'

Active Record mysql2

CI=1 MYSQL_IMAGE=mysql:5.7 docker-compose -f .buildkite/docker-compose.yml run --rm mysqldb runner activerecord 'rake db:mysql:rebuild test:mysql2'

Active Record postgresql

CI=1 POSTGRES_IMAGE=postgres:9.6-alpine docker-compose -f .buildkite/docker-compose.yml run --rm postgresdb runner activerecord 'rake db:postgresql:rebuild test:postgresql'

Active Record sqlite3

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner activerecord 'rake test:sqlite3'

Active Storage

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner activestorage 'rake test'

Active Support

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner activesupport 'rake test'

guides

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner guides 'rake test'

railties (may fail)

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner railties 'rake test'

Action Cable integration

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner actioncable 'rake test:integration'

Active Job integration

CI=1 docker-compose -f .buildkite/docker-compose.yml run --rm default runner activejob 'rake test:integration'

Note

This document does not include isolation test and Active Record CI against sqlite3_mem and MariaDB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment