Selective Test Execution at Stripe: Fast CI for a 50M-Line Ruby Monorepo

2026-04-23

Link: https://stripe.dev/blog/selective-test-execution-at-stripe-fast-ci-for-a-50m-line-ruby-monorepo

HN Discussion: 1 points, 0 comments

Fifty million lines of Ruby in a single repository. That number alone should stop you mid-scroll. Stripe's monorepo is one of the largest Ruby codebases in existence, and running its full test suite on every commit would be a computational and financial nightmare. This post from Stripe's engineering blog details how they built a selective test execution system to keep CI fast without sacrificing confidence.

The core problem is deceptively simple: given a code change, figure out which tests actually need to run. The naive answer — run everything — doesn't scale when "everything" means millions of test cases across tens of millions of lines. The sophisticated answer requires building a dependency graph between source files and test files, then using that graph to prune the test run down to only what's affected.

This is a problem that every growing engineering organization eventually hits, but few operate at the scale where the solutions become genuinely novel. The approaches typically involve some combination of:

Ruby makes this particularly challenging. Its dynamic nature means that static analysis alone can't capture the full dependency picture. Metaprogramming, dynamic requires, and monkey-patching all create invisible links between files that only manifest at runtime. Stripe's engineers likely had to combine multiple strategies and accept carefully calibrated tradeoffs between speed and correctness.

What makes this valuable for the broader engineering community isn't just the scale — it's the transferable patterns. Teams with codebases a fraction of Stripe's size still struggle with slow CI pipelines that bottleneck developer productivity. The difference between a 5-minute and a 45-minute CI run compounds across every engineer, every commit, every day. The architectural decisions Stripe made — how they model dependencies, how they handle cache invalidation, how they measure confidence in their pruning — are applicable well beyond Ruby monorepos.

First-party engineering blogs from companies like Stripe consistently deliver some of the highest signal-to-noise content in the industry. They're writing about systems they actually built and operate, not hypotheticals.

Why it deserves more upvotes: It's a detailed, first-party account of solving one of the hardest practical problems in developer infrastructure — making CI fast at extreme scale — with lessons that apply to teams of every size.

All newsletters