Skip to content

Conversation

@mertilginoglu
Copy link
Contributor

Added a method to remove environments from the local database that no longer exist in GitHub. Updated the EnvironmentService to call this new method and adjusted variable names for clarity. Added unit tests to ensure correct functionality of the environment deletion process.

Motivation

When environments are deleted from GitHub, they remain in the Helios local database. This causes inconsistencies between the GitHub repository state and the Helios database, leading to stale environment data that can confuse users and cause issues with environment synchronization.

This change ensures that when environments are synchronized from GitHub, any environments that have been deleted from GitHub are also removed from the local database, maintaining data consistency.

Description

Added environment cleanup functionality to the GitHub environment synchronization process:

  • New method removeDeletedEnvironments in GitHubEnvironmentSyncService:

    • Compares environments currently in GitHub with those stored locally for a given repository
    • Identifies and deletes local environments that no longer exist in GitHub
    • Includes comprehensive logging for deleted environments
    • Uses transactional operations to ensure data consistency
  • Updated EnvironmentService.syncRepositoryEnvironments():

    • Calls the new cleanup method after processing all GitHub environments
    • Ensures deleted environments are removed during each synchronization cycle
  • Code improvements:

    • Fixed variable naming for clarity (gitHubEnvironmentDtoSgitHubEnvironmentDtos)
    • Improved code formatting consistency
  • Comprehensive unit tests:

    • Tests deletion of single missing environment
    • Tests deletion of multiple missing environments
    • Tests that existing environments are not deleted
    • Tests edge cases (empty GitHub list, empty local list)

Testing Instructions

Prerequisites:

  • GitHub Account with admin/owner access to a repository
  • Access to a repository with GitHub environments configured
  • Ability to create and delete GitHub environments

Flow:

  1. Log in to Helios as a Developer or Admin

  2. Navigate to Settings for a repository that has GitHub environments configured

  3. Test environment synchronization with existing environments:

    • Ensure the repository has at least one environment in GitHub
    • Trigger environment synchronization (via the sync button or automatic sync)
    • Verify that all existing environments are synchronized correctly
    • Verify that no environments are deleted if they still exist in GitHub
  4. Test deletion of removed environments:

    • Note the current environments in Helios for a repository
    • Go to GitHub and delete one or more environments from the repository settings
    • Return to Helios and trigger environment synchronization
    • Verify that:
      • The deleted environments are removed from the Helios database
      • The remaining environments are still present and correctly synchronized
      • Check application logs for deletion messages
  5. Test deletion of all environments:

    • Delete all environments from a GitHub repository
    • Trigger environment synchronization in Helios
    • Verify that all environments are removed from the Helios database
  6. Test with empty repository:

    • Use a repository that has never had environments configured
    • Trigger environment synchronization
    • Verify that no errors occur and the sync completes successfully
  7. Verify logging:

    • Check application logs after synchronization
    • Verify that deletion operations are logged with appropriate information (environment name, ID, repository ID)
    • Verify that summary logs show the number of environments removed

Checklist

General

Server

  • Code is performant and follows best practices
  • I documented the Java code using JavaDoc style.

@mertilginoglu mertilginoglu requested a review from a team as a code owner November 23, 2025 23:04
@github-actions github-actions bot added bug Something isn't working application-server size:L labels Nov 23, 2025
@mertilginoglu mertilginoglu changed the title Implement environment cleanup in GitHubEnvironmentSyncService fix: implement environment cleanup in GitHubEnvironmentSyncService Nov 23, 2025
@codacy-production
Copy link

codacy-production bot commented Nov 23, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.60% (target: -1.00%) 85.71%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (742295a) 7886 2083 26.41%
Head commit (d8db989) 7982 (+96) 2156 (+73) 27.01% (+0.60%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#828) 21 18 85.71%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@mertilginoglu mertilginoglu marked this pull request as draft November 23, 2025 23:07
Added a method to remove environments from the local database that no longer exist in GitHub. Updated the EnvironmentService to call this new method and adjusted variable names for clarity. Added unit tests to ensure correct functionality of the environment deletion process.
@mertilginoglu mertilginoglu force-pushed the fix/delete-env-during-sync branch from c344796 to d8db989 Compare November 27, 2025 03:02
@mertilginoglu mertilginoglu marked this pull request as ready for review November 27, 2025 03:05
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 4, 2025
@github-actions github-actions bot removed the stale label Dec 5, 2025
@github-actions
Copy link

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

application-server bug Something isn't working size:L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants