Skip to content

Enhancement publish artifacts action#4195

Merged
rathimayur merged 9 commits into
masterfrom
Enhancement-PublishArtifactsAction
Apr 30, 2025
Merged

Enhancement publish artifacts action#4195
rathimayur merged 9 commits into
masterfrom
Enhancement-PublishArtifactsAction

Conversation

@rathimayur

@rathimayur rathimayur commented Apr 30, 2025

Copy link
Copy Markdown
Contributor

Thank you for your contribution.
Before submitting this PR, please make sure:

  • PR description and commit message should describe the changes done in this PR
  • Verify the PR is pointing to correct branch i.e. Release or Beta branch if the code fix is for specific release , else point it to master
  • Latest Code from master or specific release branch is merged to your branch
  • No unwanted\commented\junk code is included
  • No new warning upon build solution
  • Code Summary\Comments are added to my code which explains what my code is doing
  • Existing unit test cases are passed
  • New Unit tests are added for your development
  • Sanity Tests are successfully executed for New and Existing Functionality
  • Verify that changes are compatible with all relevant browsers and platforms.
  • After creating pull request there should not be any conflicts
  • Resolve all Codacy comments
  • Builds and checks are passed before PR is sent for review
  • Resolve code review comments
  • Update the Help Library document to match any feature changes

Summary by CodeRabbit

  • New Features

    • Introduced a new action type for publishing artifacts, allowing users to upload and register artifact files for reporting.
    • Added a dedicated UI page for editing publish artifact actions.
    • Enhanced the input values grid for artifact publishing with a specialized layout and a "Browse" button for selecting files.
  • Bug Fixes

    • Improved handling of button events and grid visibility for artifact publishing actions to ensure correct UI behavior.
    • Fixed file extension extraction to prevent errors when artifact paths have no extension.

@coderabbitai

coderabbitai Bot commented Apr 30, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update introduces a new action type, ActPublishArtifacts, for handling artifact publishing within the application. The implementation includes a new action class, associated UI edit pages, and tailored logic for parameter handling and user interface presentation. The input values grid for this action type is customized to allow file browsing and uses a different parameter naming convention. The UI adapts dynamically based on the selected action, and a new browse button is added for file selection. The changes also ensure correct artifact registration and error handling during execution.

Changes

File(s) Change Summary
Ginger/Ginger/Actions/ActionEditPage.xaml Added a new DataTemplate resource "GridInputValuesBrowseBtnTemplate" containing a "Browse" button with a click event handler and enabled state bound to "IsBrowseNeeded".
Ginger/Ginger/Actions/ActionEditPage.xaml.cs Enhanced support for ActPublishArtifacts by customizing input value parameter naming, modifying input values grid to include a browse button column, adjusting grid title and button visibility, adding a browse button click handler, and updating UI behavior based on action type. Added new private methods for unique parameter naming and grid view definitions.
Ginger/Ginger/Actions/ActionEditPages/ActPublishArtifactsEditPage.xaml Added a new placeholder XAML page ActPublishArtifactsEditPage with standard WPF and custom namespace references, containing an empty root Grid for future UI content.
Ginger/Ginger/Actions/ActionEditPages/ActPublishArtifactsEditPage.xaml.cs Added a new code-behind class ActPublishArtifactsEditPage with a constructor accepting an ActPublishArtifacts instance and initializing UI components.
Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs Introduced the ActPublishArtifacts action class inheriting from ActWithoutDriver. Implements validation of input file paths, file existence and size checks, artifact registration for reporting, and provides action metadata and user guidance.
Ginger/Ginger/Actions/UserControls/UCArtifact.xaml.cs Modified IntiArtifact method to safely extract and normalize file extensions by checking for empty extensions before converting to lowercase and removing the leading dot, preventing potential errors when no extension exists.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ActionEditPage
    participant ActPublishArtifacts
    participant FileDialog

    User->>ActionEditPage: Selects "Publish Artifacts" action
    ActionEditPage->>ActionEditPage: Display customized input values grid
    User->>ActionEditPage: Clicks "Browse" button
    ActionEditPage->>FileDialog: Open file dialog
    FileDialog-->>ActionEditPage: Returns selected file path
    ActionEditPage->>ActionEditPage: Set input value to selected file path
    User->>ActPublishArtifacts: Executes action
    ActPublishArtifacts->>ActPublishArtifacts: Validate file paths and register artifacts
Loading

Poem

A hop, a skip, a "Browse" away,
Artifacts now find their way.
With grids that shift and buttons new,
Publishing files is easy to do!
A carrot for each tested file—
This bunny’s work is done in style.
🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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 or @coderabbitai title 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 9

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0c33962 and 6aaecdf.

📒 Files selected for processing (5)
  • Ginger/Ginger/Actions/ActionEditPage.xaml (1 hunks)
  • Ginger/Ginger/Actions/ActionEditPage.xaml.cs (6 hunks)
  • Ginger/Ginger/Actions/ActionEditPages/ActPublishArtifactsEditPage.xaml (1 hunks)
  • Ginger/Ginger/Actions/ActionEditPages/ActPublishArtifactsEditPage.xaml.cs (1 hunks)
  • Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
Ginger/Ginger/Actions/ActionEditPages/ActPublishArtifactsEditPage.xaml.cs (1)
Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs (1)
  • ActPublishArtifacts (27-83)
Ginger/Ginger/Actions/ActionEditPage.xaml.cs (3)
Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs (1)
  • ActPublishArtifacts (27-83)
Ginger/Ginger/Actions/ActionEditPages/ActPublishArtifactsEditPage.xaml.cs (2)
  • ActPublishArtifactsEditPage (40-46)
  • ActPublishArtifactsEditPage (42-45)
Ginger/Ginger/GeneralLib/General.cs (1)
  • SetupBrowseFile (146-153)
🔇 Additional comments (2)
Ginger/Ginger/Actions/ActionEditPage.xaml (2)

55-57:

Details

✅ Verification successful

Verify the IsBrowseNeeded binding property.

The IsEnabled property of the button is bound to IsBrowseNeeded, but it's not clear where this property is defined. Make sure that the binding is correctly set up and the property exists in the appropriate view model or data context.


🏁 Script executed:

#!/bin/bash
# Look for the IsBrowseNeeded property in the codebase

echo "Searching for IsBrowseNeeded property definition..."
rg "IsBrowseNeeded" --type cs

Length of output: 628


IsBrowseNeeded Binding Verified and Present

The IsBrowseNeeded property is defined in both APIModelBodyKeyValue and WebAPIKeyBodyValues (in GingerCoreCommon), and both raise OnPropertyChanged, so the binding on your Button will resolve correctly against the item in your DataTemplate. No further changes are required here.


55-57:

Details

✅ Verification successful

Ensure the GridInputValuesBrowseBtn_Click event handler is implemented.

The button click handler should be implemented in the code-behind file of ActionEditPage.xaml. Verify that this method exists and works correctly for browsing and selecting artifact files.


🏁 Script executed:

#!/bin/bash
# Look for the GridInputValuesBrowseBtn_Click method in the code-behind

echo "Searching for GridInputValuesBrowseBtn_Click method..."
rg "GridInputValuesBrowseBtn_Click" --type cs

Length of output: 295


🏁 Script executed:

#!/bin/bash
# Extract implementation of GridInputValuesBrowseBtn_Click to verify its contents
rg -A20 -n "GridInputValuesBrowseBtn_Click" Ginger/Ginger/Actions/ActionEditPage.xaml.cs

Length of output: 716


Confirmed: GridInputValuesBrowseBtn_Click is implemented and functional

The GridInputValuesBrowseBtn_Click handler is defined in Ginger/Ginger/Actions/ActionEditPage.xaml.cs (lines 2523–2536). It correctly casts the current grid item, opens a file dialog via General.SetupBrowseFile, and updates the selected file path on the item. No further action required.

Comment thread Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs
Comment thread Ginger/Ginger/Actions/ActionEditPage.xaml.cs
Comment thread Ginger/Ginger/Actions/ActionEditPage.xaml.cs
Comment thread Ginger/Ginger/Actions/ActionEditPage.xaml.cs
Comment thread Ginger/Ginger/Actions/ActionEditPage.xaml.cs
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 30, 2025
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 30, 2025
Comment thread Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs Outdated
Comment thread Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs Outdated
@Maheshkale447
Maheshkale447 enabled auto-merge April 30, 2025 11:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs (1)

71-102: 🛠️ Refactor suggestion

Set action status explicitly on success or failure.

The method currently sets error messages but doesn't explicitly set the action's status. This was mentioned in a previous review comment that hasn't been fully addressed.

public override void Execute()
{
+   bool hasErrors = false;
    try
    {
        if (ActInputValues == null || ActInputValues.Count == 0)
        {
            Error = "No artifact files provided.";
+           hasErrors = true;
            return;
        }

        foreach (ActInputValue item in ActInputValues)
        {
            if (!System.IO.File.Exists(item.ValueForDriver))
            {
                Error += "Artifact File Path is invalid/doesn't exist/not enough permissions to access file: " + item.ValueForDriver;
+               hasErrors = true;
                continue;
            }
            if (new System.IO.FileInfo(item.ValueForDriver).Length > 5242879) // 5MB = 5242880 bytes, but somewhere the calculation is referring it as 5242879 bytes
            {
                Error += "File size greater than 5MB cannot be uploaded: " + item.ValueForDriver;
+               hasErrors = true;
                continue;
            }

            Act.AddArtifactToAction(Path.GetFileName(item.ValueForDriver), this, item.ValueForDriver);
        }
    }
    catch (Exception ex)
    {
        Error += "Failed to upload artifacts: " + ex;
+       hasErrors = true;
        return;
    }
+   
+   if (hasErrors)
+   {
+       Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
+   }
+   else
+   {
+       Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed;
+   }
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e615a8 and 13824fe.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs (1 hunks)

Comment thread Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs
Comment thread Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 30, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (3)
Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs (3)

3-3: Update copyright year to the current year.

The copyright year extends to 2025, which is in the future. Update it to the current year (2024).

-Copyright © 2014-2025 European Support Limited
+Copyright © 2014-2024 European Support Limited

95-95: 🧹 Nitpick (assertive)

Improve error message to include file size information.

When a file exceeds the size limit, it would be helpful to include the actual file size in the error message for better diagnostics.

-                            Error += $"File size greater than 5MB cannot be uploaded: {item.ValueForDriver}";
+                            Error += $"File size greater than 5MB cannot be uploaded: {item.ValueForDriver} (Size: {fileSize/(1024.0*1024.0):F2} MB)";

73-113: 🛠️ Refactor suggestion

Set action status based on error condition.

The Execute method collects errors but doesn't explicitly set the action's status to failed when errors occur. This could lead to inconsistent behavior if the caller doesn't check the Error property.

public override void Execute()
{
    try
    {
+       bool hasErrors = false;
        if (ActInputValues == null || ActInputValues.Count == 0)
        {
            Error = "No artifact files provided.";
+           Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
            return;
        }

        foreach (ActInputValue item in ActInputValues)
        {
            if (!System.IO.File.Exists(item.ValueForDriver))
            {
                Error += $"Artifact File Path is invalid/doesn't exist/not enough permissions to access file: {item.ValueForDriver}";
+               hasErrors = true;
                continue;
            }
            try
            {
                var fileSize = new System.IO.FileInfo(item.ValueForDriver).Length;
                if (fileSize > MaxUploadSizeBytes)
                {
                    Error += $"File size greater than 5MB cannot be uploaded: {item.ValueForDriver}";
+                   hasErrors = true;
                    continue;
                }
            }
            catch (Exception ex)
            {
                Error += $"Failed to check file size for {item.ValueForDriver}: {ex.Message}";
+               hasErrors = true;
                continue;
            }

            Act.AddArtifactToAction(Path.GetFileName(item.ValueForDriver), this, item.ValueForDriver);
        }
+       
+       if (hasErrors)
+       {
+           Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
+       }
+       else
+       {
+           Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed;
+       }
    }
    catch (Exception ex)
    {
        Error += $"Failed to upload artifacts: {ex.Message}";
+       Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
        return;
    }
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 13824fe and 372b76d.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs (1 hunks)
🔇 Additional comments (5)
Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs (5)

48-50: Good job with the object and value configurations!

The action correctly specifies that it doesn't need object locator configurations but does need value configurations, which aligns with its purpose of handling file paths as inputs.


64-66: Good descriptive action metadata.

The action provides clear and helpful metadata about its purpose and usage through the ActionEditPage and ActionUserDescription properties.


68-71: Good user documentation.

The ActionUserRecommendedUseCase method provides helpful guidance to users about when and how to use this action.


77-81: Good defensive programming with null check.

The null check for ActInputValues is a good practice to prevent potential NullReferenceException.


90-103: Good error handling for file size check.

The code properly wraps the file size check in a try-catch block to handle potential exceptions when checking file information.

Comment thread Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs
Comment thread Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs
@rathimayur
rathimayur merged commit a500326 into master Apr 30, 2025
@rathimayur
rathimayur deleted the Enhancement-PublishArtifactsAction branch April 30, 2025 16:58
@coderabbitai coderabbitai Bot mentioned this pull request Jun 17, 2025
15 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Dec 23, 2025
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants