Open-Source Wikis

/

Ruby on Rails

/

How to contribute

/

Tooling

rails/rails

Tooling

Build tools, linters, code generators, and CI for the Rails repo.

Test runner

The test runner is the same one Rails ships to apps. It lives in railties/lib/rails/test_unit/runner.rb and is invoked from each component's bin/test:

# tools/test.rb (full file, 17 lines)
$: << File.expand_path("test", COMPONENT_ROOT)
require "bundler/setup"
require "rails/test_unit/runner"
require "rails/test_unit/reporter"
require "rails/test_unit/line_filtering"
require "active_support"
require "active_support/test_case"

ActiveSupport::TestCase.extend Rails::LineFiltering
Rails::TestUnitReporter.app_root ||= COMPONENT_ROOT
Rails::TestUnitReporter.executable = "bin/test"

Rails::TestUnit::Runner.parse_options(ARGV)
Rails::TestUnit::Runner.run(ARGV)

Each <component>/bin/test is a one-line shim that defines COMPONENT_ROOT and requires tools/test.rb. Reusing the same runner means:

  • Line-number filtering works the same in the framework as in apps (bin/test path:42).
  • Failure output matches bin/rails test.
  • Parallel tests use the same ActiveSupport::Testing::Parallelization machinery.

RuboCop

Configuration in .rubocop.yml. Notable rules:

  • Style/FrozenStringLiteralComment is required.
  • Rails/AssertNot enforces assert_not over assert !.
  • A custom rubocop-rails plugin set is loaded for Rails-specific lint.
  • rubocop-minitest and rubocop-packaging are also active.

Run on the full repo:

bundle exec rubocop

Or on a single component:

bundle exec rubocop activerecord/
bundle exec rubocop --autocorrect-all activerecord/lib

The version is pinned in Gemfile: rubocop "1.79.2".

Markdown linting

mdl (Markdown Lint) checks every .md file in the repo. Configuration:

  • .mdlrc — top-level config (loads .mdlrc.rb).
  • .mdlrc.rb — Ruby DSL specifying which rules to enforce.

Run it via:

mdl .

The custom rules accept Rails-style examples (e.g., *Author Name* after a changelog entry) without flagging them.

ESLint

JavaScript files mostly live under actioncable/, activestorage/, and actiontext/. ESLint configuration is in eslint.config.mjs (flat config format).

yarn install
yarn run lint

Each JS-bearing component has its own package.json and rollup.config.js.

YARD / RDoc

Each component has a Rakefile task to generate docs:

cd actionview && rake rdoc

The docs at https://api.rubyonrails.org are built from these RDoc/YARD comments. The repo also runs rail_inspector.yml on CI, which sanity-checks the doc generation.

Code statistics

Rails ships its own LOC counter, used by the bin/rails stats command in apps:

  • railties/lib/rails/code_statistics.rb
  • railties/lib/rails/code_statistics_calculator.rb

These are also used by the rake stats task at the repo root to produce a per-component breakdown.

Bug report templates

guides/bug_report_templates/ contains executable scripts that boot a tiny Rails environment for reproducing bugs:

  • active_record_main.rb
  • action_controller_main.rb
  • generic_main.rb
  • executable_template.rb

Run them with ruby <template>. They self-install dependencies via inline Gemfile. See debugging for usage.

Devcontainers

.devcontainer/ provides a Docker-based development environment compatible with VS Code Dev Containers and GitHub Codespaces. It's tested in CI by:

  • .github/workflows/devcontainer-shellcheck.yml
  • .github/workflows/devcontainer-smoke-test.yml

CI workflows

.github/workflows/:

  • labeler.yml — auto-labels new PRs based on touched paths.
  • stale.yml — closes stale issues.
  • more-info-needed.yml — bot reply for issues without enough info.
  • rail_inspector.yml — sanity-checks API docs.
  • rails-new-docker.yml — runs rails new against a Docker image.
  • rails_releaser_tests.yml — tests the in-repo releaser tool.
  • release.yml — orchestrates tagged releases.
  • devcontainer-shellcheck.yml, devcontainer-smoke-test.yml — devcontainer build verification.

The full Ruby × adapter test matrix runs on Buildkite, configured outside this repo.

Releaser

The tools/releaser/ directory contains a small gem that automates publishing a Rails release:

  • Bumping every component's gem_version.rb.
  • Building each *.gemspec.
  • Tagging in git.
  • Pushing gems to RubyGems.

The releaser is invoked from release.yml and can also be run locally for dry-runs.

Other tools

  • tools/preview_unicode_emoji_versions.rb — generates the emoji table used by Action Text.
  • tools/test_common.rb — helper required by older test files.

Prism

Gemfile includes the prism parser. It's used in a few places where Rails needs to introspect Ruby source — generators, the route reloader, and the autoloader. As of Ruby 3.3 Prism ships with the standard library, so it's not always pulled from the Gemfile.

Bundler workspace

The repo is a single Bundler workspace. The top-level Gemfile uses gemspec to pull in every component's gemspec dependencies plus the dev/test extras. Inside each component's Gemfile, gemspec path: ".." is also used so component-level test runs work standalone.

For the full list of dependencies, see reference/dependencies.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Tooling – Ruby on Rails wiki | Factory