Faster Pull Request Merges

Unblocking engineers by letting them merge their code 5x faster.

Neal Wu & Young Kim
6 min readintermediate
--
View Original

Overview

The article discusses strategies implemented at Ramp to accelerate the merging of pull requests, primarily by addressing the challenges posed by an extensive test suite and the complexities of database migrations. It outlines the evolution of their merging process, leading to a significant reduction in the average merge time from over an hour to just 12 minutes.

What You'll Learn

1

How to optimize pull request merging processes in a CI/CD pipeline

2

Why managing database migrations effectively is crucial for deployment speed

3

How to implement a hash-based conflict resolution strategy for migrations

Prerequisites & Requirements

  • Understanding of CI/CD practices and database migrations
  • Familiarity with GitHub Actions and Python(optional)

Key Questions Answered

How did Ramp reduce the average pull request merge time?
Ramp reduced the average pull request merge time from over an hour to just 12 minutes by allowing pull requests without database migrations to merge freely while requiring migration pull requests to be up-to-date with the master branch. This was achieved through a new file that tracks migration changes, preventing unnecessary delays.
What challenges did Ramp face with their initial pull request merging process?
Initially, Ramp's pull request merging process required all code to be up-to-date with the master branch and pass extensive tests, which took over 12 minutes to run. This led to long wait times for engineers, with some waiting up to 1-2 hours for their code to be merged and deployed.
What is the role of the migration-hash.txt file in the new merging strategy?
The migration-hash.txt file contains a hash of all migration filenames, changing whenever a new migration is added. This creates a merge conflict for pull requests that attempt to merge without being up-to-date with the latest migrations, ensuring that only compatible migrations are merged.

Key Statistics & Figures

Average pull request merge time
12 minutes
This is the time it now takes to merge pull requests after implementing the new strategies.
Previous average pull request wait time
1-2 hours
Engineers previously had to wait this long before seeing their code in production.
Test suite run time
12 minutes
The total time taken for the test suite to run, which influenced the merging process.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Backend
Python
Used for writing unit and integration tests.
Backend
Flask
Framework used for building the application.
Backend
Sqlalchemy
Used for database management and migrations.
Tools
Alembic
Used for managing database migrations.

Key Actionable Insights

1
Implement a hash-based mechanism to manage database migrations in your CI/CD pipeline.
This approach can prevent merge conflicts and streamline the deployment process, especially in teams with frequent database changes.
2
Allow pull requests without migrations to merge freely to enhance deployment speed.
This strategy can significantly reduce waiting times for engineers, enabling faster iterations and deployments.
3
Regularly review and optimize your test suite to ensure it does not become a bottleneck.
As the codebase grows, test suite durations can increase, impacting developer productivity. Keeping tests efficient is crucial.

Common Pitfalls

1
Failing to manage database migrations properly can lead to merge conflicts.
When multiple developers create migrations from the same base revision, it can result in multiple heads, causing deployment issues. Implementing a hash-based system can help mitigate this.

Related Concepts

CI/CD Best Practices
Database Migration Strategies
Pull Request Management Techniques