Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup backend endpoints #14418

Merged
merged 14 commits into from
Jan 20, 2025
Merged

Conversation

Konrad-Simso
Copy link
Contributor

@Konrad-Simso Konrad-Simso commented Jan 14, 2025

Description

Remove unused endpoints and respective tests.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

Based on the comprehensive summary of changes, here are the high-level release notes:

  • Removed Features

    • Removed Kubernetes deployments management functionality
    • Eliminated language and text resource management endpoints
    • Removed process modeling template retrieval and saving capabilities
    • Discontinued repository-level operations like branch and commit management
  • API Changes

    • Significant reduction in backend controller and service methods
    • Removed several HTTP endpoints related to text, language, and repository operations
    • Simplified API surface by eliminating specific management functionalities
  • Testing Impact

    • Corresponding unit and integration tests for removed features have been deleted
    • Reduced test coverage for previously existing endpoints and services

These changes suggest a significant refactoring of the application's backend, focusing on streamlining and potentially removing certain management capabilities.

Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

📝 Walkthrough

Walkthrough

The pull request involves a significant reduction in functionality across multiple components of the backend Designer application. Several controllers, services, interfaces, and test classes have been removed, primarily related to Kubernetes deployments, languages, process modeling, repository management, text keys, and texts. The changes suggest a strategic simplification of the application's architecture, removing endpoints and services that may no longer be required or have been replaced by alternative implementations.

Changes

File Path Change Summary
backend/src/Designer/Controllers/ Removed controllers for Kubernetes Deployments, Languages, Process Modeling, Repository, Text Keys, and Texts
backend/src/Designer/Infrastructure/GitRepository/ Removed method GetLanguageFiles from AltinnGitRepository
backend/src/Designer/Infrastructure/ServiceRegistration.cs Removed registration for ILanguagesService
backend/src/Designer/Services/Implementation/ Deleted implementation classes for Languages, Process Modeling, Source Control Logging Decorator, Texts Service; removed methods from GiteaAPIWrapper
backend/src/Designer/Services/Interfaces/ Removed interfaces for Gitea, Languages, Process Modeling, Source Control, and Texts Service
backend/tests/Designer.Tests/ Deleted multiple test classes and methods related to removed controllers and services
frontend/packages/shared/src/api/paths.js Added HTTP method annotations to various API path functions

Possibly related PRs

Suggested labels

kind/bug, area/ui-editor, added-to-sprint, team/studio-domain2, skip-manual-testing

Suggested reviewers

  • Jondyr
  • github-actions

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 216b568 and 0ec2b35.

📒 Files selected for processing (3)
  • backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs (0 hunks)
  • backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs (0 hunks)
  • frontend/packages/shared/src/api/paths.js (4 hunks)
💤 Files with no reviewable changes (2)
  • backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs
  • backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/packages/shared/src/api/paths.js
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Run dotnet build and test (macos-latest)
  • GitHub Check: Run dotnet build and test (windows-latest)
  • GitHub Check: Analyze
  • GitHub Check: Run integration tests against actual gitea and db
  • GitHub Check: Validate PR title to be semantic
  • GitHub Check: Run dotnet build and test (ubuntu-latest)
  • GitHub Check: Testing
  • GitHub Check: CodeQL
  • GitHub Check: Typechecking and linting

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added area/text-editor Area: Related to creating, translating and editing texts. area/app-deploy Area: Related to deploying apps from Altinn Studio to Altinn Apps. solution/studio/designer Issues related to the Altinn Studio Designer solution. quality/testing Tests that are missing, needs to be created or could be improved. backend labels Jan 14, 2025
@Konrad-Simso Konrad-Simso linked an issue Jan 14, 2025 that may be closed by this pull request
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.68%. Comparing base (6795c45) to head (0ec2b35).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14418      +/-   ##
==========================================
- Coverage   95.68%   95.68%   -0.01%     
==========================================
  Files        1891     1891              
  Lines       24583    24574       -9     
  Branches     2823     2823              
==========================================
- Hits        23523    23514       -9     
  Misses        799      799              
  Partials      261      261              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Konrad-Simso Konrad-Simso marked this pull request as ready for review January 15, 2025 07:31
@Konrad-Simso Konrad-Simso added team/studio-domain1 team/studio-core skip-releasenotes Issues that do not make sense to list in our release notes skip-documentation Issues where updating documentation is not relevant labels Jan 15, 2025
@TomasEng TomasEng self-assigned this Jan 17, 2025
Copy link
Contributor

@TomasEng TomasEng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Veldig fint å få ryddet bort ting som ikke er i bruk! Jeg har ingenting å utsette på dette, men foreslår at @mirkoSekulic også tar en titt for å verifisere at vi ikke fjerner noe viktig.

PS.: Ta også en kikk på konfliktene, @Konrad-Simso.

Copy link
Collaborator

@mirkoSekulic mirkoSekulic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@Konrad-Simso
Copy link
Contributor Author

Skal se på konfliktene, det handler nok om FluentAssertions

# Conflicts:
#	backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs
#	backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs
#	backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryController/RepositoryControllerGiteaIntegrationTests.cs
#	backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs (1)

Line range hint 33-47: Consider enhancing test maintainability and coverage.

The test method could benefit from the following improvements:

  1. Add cleanup logic for the test repository to prevent test data accumulation
  2. Extract the expected "data" value into a constant or test data provider
  3. Add more test cases to cover different scenarios

Consider applying these changes:

 public class ProcessModelingServiceTests : FluentTestsBase<ProcessModelingServiceTests>
 {
+    private const string EXPECTED_DATA_TASK_TYPE = "data";
+
     private readonly AltinnGitRepositoryFactory _altinnGitRepositoryFactory;
     private readonly IAppDevelopmentService _appDevelopmentService;
     public string CreatedTestRepoPath { get; set; }

     // ... constructor ...

     [Theory]
     [InlineData("ttd", "app-with-process-and-layoutsets", "testUser")]
+    [InlineData("ttd", "another-app-with-process", "testUser")] // Add more test cases
     public async Task GetTaskTypeFromProcessDefinition_GivenProcessDefinition_ReturnsTaskType(string org, string app, string developer)
     {
         string targetRepository = TestDataHelper.GenerateTestRepoName();
         CreatedTestRepoPath = await TestDataHelper.CopyRepositoryForTest(org, app, developer, targetRepository);

         IProcessModelingService processModelingService = new ProcessModelingService(_altinnGitRepositoryFactory, _appDevelopmentService);

         // Act
         string taskType = await processModelingService.GetTaskTypeFromProcessDefinition(AltinnRepoEditingContext.FromOrgRepoDeveloper(org, targetRepository, developer), "layoutSet1");

         // Assert
-        Assert.Equal("data", taskType);
+        Assert.Equal(EXPECTED_DATA_TASK_TYPE, taskType);
     }
+
+    public override void Dispose()
+    {
+        base.Dispose();
+        if (!string.IsNullOrEmpty(CreatedTestRepoPath))
+        {
+            TestDataHelper.DeleteDirectory(CreatedTestRepoPath);
+        }
+    }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39c04a4 and 216b568.

📒 Files selected for processing (7)
  • backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs (1 hunks)
  • backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs (1 hunks)
  • backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryController/RepositoryControllerGiteaIntegrationTests.cs (0 hunks)
  • backend/tests/Designer.Tests/Mocks/IGiteaMock.cs (0 hunks)
  • backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs (1 hunks)
  • backend/tests/Designer.Tests/Services/SourceControlLoggingDecoratorTests.cs (0 hunks)
  • frontend/packages/shared/src/api/paths.js (4 hunks)
💤 Files with no reviewable changes (3)
  • backend/tests/Designer.Tests/GiteaIntegrationTests/RepositoryController/RepositoryControllerGiteaIntegrationTests.cs
  • backend/tests/Designer.Tests/Mocks/IGiteaMock.cs
  • backend/tests/Designer.Tests/Services/SourceControlLoggingDecoratorTests.cs
🚧 Files skipped from review as they are similar to previous changes (2)
  • backend/tests/Designer.Tests/Controllers/ProcessModelingController/SaveProcessDefinitionFromTemplateTests.cs
  • frontend/packages/shared/src/api/paths.js
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Run dotnet build and test (macos-latest)
  • GitHub Check: Format check
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Run dotnet build and test (windows-latest)
  • GitHub Check: Analyze
  • GitHub Check: Run integration tests against actual gitea and db
  • GitHub Check: Run dotnet build and test (ubuntu-latest)
  • GitHub Check: Typechecking and linting
  • GitHub Check: Testing
  • GitHub Check: CodeQL
🔇 Additional comments (2)
backend/tests/Designer.Tests/Controllers/ProcessModelingController/GetTemplatesTests.cs (1)

1-1: Verify the safe removal of process template functionality.

The removal of this test file aligns with the PR objectives to clean up unused backend endpoints. However, let's verify that no other components depend on the removed process template functionality.

Let's check for any remaining references to the removed endpoints:

✅ Verification successful

Process template functionality safely removed

The verification confirms that the removal of the process template functionality is safe. The remaining template and process modeling references in the codebase are unrelated, belonging to different features such as data modeling and application templates.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining references to the removed process template functionality

# Check for any remaining references to GetTemplates endpoint
echo "Checking for GetTemplates endpoint references..."
rg -l "GetTemplates|SaveProcessDefinitionFromTemplate" --type cs

# Check for any remaining template-related API calls in frontend code
echo "Checking frontend code for template API calls..."
rg -l "process.*template.*api" --type ts --type js

# Check for any remaining references in configuration or documentation
echo "Checking configuration and documentation..."
rg -l "process.*template" --type json --type yaml --type md

Length of output: 492


Script:

#!/bin/bash
# Try more granular, case-insensitive searches

echo "Checking for any template-related controller files..."
fd -e cs "Template" "ProcessModel" backend/src

echo "Checking for template references in C# files..."
rg -i "template" --type cs -l

echo "Checking for process modeling references..."
rg -i "processmodel" --type cs -l

echo "Checking for API endpoint definitions..."
rg -i "api.*template|template.*api" --type cs --type ts --type js -l

echo "Checking for specific template methods..."
ast-grep --pattern 'class $_ { 
  $$$
  $_Template$_($$$) {
    $$$
  }
  $$$
}'

Length of output: 4244

backend/tests/Designer.Tests/Services/ProcessModelingServiceTests.cs (1)

Line range hint 1-47: Verify complete removal of process definition template functionality.

The removal of GetProcessDefinitionTemplates_GivenVersion_ReturnsListOfTemplates test method should be accompanied by the removal of all related functionality. Let's verify this cleanup is complete.

✅ Verification successful

Process definition template functionality has been properly removed

The removal of the test method is consistent with the codebase state. All process definition template-related functionality has been cleaned up, and the remaining template references in the codebase are for unrelated features (resource management and app templates).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to process definition templates

# Check for any remaining references to GetProcessDefinitionTemplates
rg -l "GetProcessDefinitionTemplates"

# Check for any remaining template-related code
rg -l "ProcessDefinitionTemplate"

# Check for any remaining references to template functionality in interfaces
ast-grep --pattern 'interface IProcessModelingService {
  $$$
  GetProcessDefinitionTemplates($$$) {
    $$$
  }
  $$$
}'

Length of output: 195


Script:

#!/bin/bash
# Broader search for template-related code
rg -l "template" -g "**/*Process*.cs"

# Check for any process-related endpoints in controllers
ast-grep --pattern 'public class $_ : ControllerBase {
  $$$
  Template($$$) {
    $$$
  }
  $$$
}'

# Check process modeling service implementation
rg -A 5 "class ProcessModelingService" 

# Check for any remaining template configurations
rg -l "template" -g "**/appsettings*.json"

Length of output: 1983


Script:

#!/bin/bash
# Check template usage in ProcessModelingService
rg "template" -C 5 backend/src/Designer/Services/Implementation/ProcessModeling/ProcessModelingService.cs

# Check template config in appsettings
cat backend/src/Designer/appsettings.Development.json

# Check interface definition
cat backend/src/Designer/Services/Interfaces/IProcessModelingService.cs

Length of output: 5533

@Konrad-Simso Konrad-Simso force-pushed the chore/cleanup-backend-endpoints branch from 1c45ef0 to 216b568 Compare January 17, 2025 11:17
Copy link
Contributor

@standeren standeren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The automatic tests should be sufficient to approve this PR 💯

@standeren standeren merged commit d39bfff into main Jan 20, 2025
18 checks passed
@standeren standeren deleted the chore/cleanup-backend-endpoints branch January 20, 2025 13:38
Konrad-Simso added a commit that referenced this pull request Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/app-deploy Area: Related to deploying apps from Altinn Studio to Altinn Apps. area/text-editor Area: Related to creating, translating and editing texts. backend frontend quality/testing Tests that are missing, needs to be created or could be improved. skip-documentation Issues where updating documentation is not relevant skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-core team/studio-domain1
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Clean unused endpoints
4 participants