feat: Added support to delete builds on rententionDays#1922
Merged
saikrishna321 merged 2 commits intomainfrom Oct 29, 2025
Merged
feat: Added support to delete builds on rententionDays#1922saikrishna321 merged 2 commits intomainfrom
saikrishna321 merged 2 commits intomainfrom
Conversation
Co-authored-by: SrinivasanTarget <srinivasan.sekar1990@gmail.com>
Co-authored-by: SrinivasanTarget <srinivasan.sekar1990@gmail.com>
saikrishna321
pushed a commit
that referenced
this pull request
Oct 29, 2025
## [11.2.0](v11.1.5...v11.2.0) (2025-10-29) ### Features * Added support to delete builds on rententionDays ([#1922](#1922)) ([a986350](a986350))
|
🎉 This PR is included in version 11.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds Cleanup Feature
Overview
This PR introduces a cleanup feature that allows users to permanently delete old builds and their associated data (sessions, session logs, and test event journals) based on a configurable retention period.
Features
UI Components
Backend Implementation
POST /device-farm/api/dashboard/cleanupretentionDaysin request bodyTechnical Implementation
Date Calculation Logic
The cleanup uses precise date calculations to ensure consistent behavior:
Key Points:
lt) comparison to retain builds created on the cutoff dayretentionDays=2on Oct 29:Data Deletion Process
Deletion follows proper order to respect foreign key constraints:
createdAt < retentionDateON DELETE RESTRICTconstraint)All deletions happen within a database transaction to maintain data consistency.
Logging & Debugging
Comprehensive logging includes:
Testing
Sample Data Script
Added
src/scripts/inject-sample-data.tsto generate test data with various age ranges:Usage:
npm run db:inject-sample-data # or with custom options: npm run db:inject-sample-data -- --today-builds 2 --yesterday-builds 3 --two-day-old-builds 5Testing Scenarios
retentionDays=2to verify 2-day-old builds are retainedretentionDays=0to delete all buildsFiles Changed
Frontend
dashboard-frontend/src/components/cleanup-modal/cleanup-modal.tsx- Modal componentdashboard-frontend/src/pages/Builds/index.tsx- Integration and cleanup handlerdashboard-frontend/src/api-service/index.ts- API service methodBackend
src/modules/dashboard/router.ts- Cleanup endpoint implementationsrc/scripts/inject-sample-data.ts- Sample data generation scriptpackage.json- Added npm scriptdb:inject-sample-dataAPI Response Format
Success Response:
{ "message": "Cleanup completed", "deletedBuilds": 3, "deletedSessions": 6, "deletedSessionLogs": 18, "deletedTestEventJournals": 6 }No Builds to Delete:
{ "message": "No builds older than 30 days found. All 5 build(s) are within the retention period.", "deletedBuilds": 0, "deletedSessions": 0, "deletedSessionLogs": 0, "deletedTestEventJournals": 0 }Error Handling
retentionDaysparameter (must be number >= 0)UI Improvements
Future Enhancements