Add MergeRequestsFinder and DeploymentsInformation
What does this MR do and why?
This MR adds two new classes to the rollback tools that provide functionality to retrieve merge requests between two SHAs using deployment data. This is the first part of a three-part implementation to enhance rollback safety by detecting security patches and incident fixes that would be removed during a rollback.
Implementation details
New Classes Added:
ReleaseTools::Rollback::DeploymentsInformation - Data retrieval class:
- Static methods for fetching security and canonical deployments
- Filters deployments between two SHAs with proper boundary logic
- Handles canonical SHA intersection for auto-deploy scenarios
- Structured logging with JSON-friendly key-value pairs
ReleaseTools::Rollback::MergeRequestsFinder - Main orchestrator:
- Coordinates deployment data retrieval and MR collection
- Handles both security and canonical repositories
- Graceful error handling with detailed logging and empty result fallbacks
- Proper MR deduplication across repositories
Architecture Benefits:
- Single Responsibility: Each class has one clear purpose
- Reusable Components: DeploymentsInformation can be used independently
- Clean APIs: Keyword arguments and structured return values
- Comprehensive Error Handling: Continues processing when one repository fails
Testing Strategy:
- 20 comprehensive unit tests across both classes
- DeploymentsInformation: 9 tests covering core filtering logic and edge cases
- MergeRequestsFinder: 11 tests covering orchestration and error scenarios
- Proper mocking: External dependencies mocked, no real API calls in tests
- Edge case coverage: Adjacent deployments, missing SHAs, API failures
Usage:
# Main entry point
finder = MergeRequestsFinder.new('production', 'from_sha', 'to_sha')
merge_requests = finder.execute
# Or use deployment data independently
deployments = DeploymentsInformation.security_deployments(
environment: 'production',
from_sha: 'abc123',
to_sha: 'def456'
)
- Updates
lib/release_tools.rbto include the new classes.
Related Issue: gitlab-com/gl-infra/delivery#20923 (closed)
Author Check-list
-
Has documentation been updated?
Edited by Maina Ng'ang'a