Enhancement publish artifacts action#4195
Conversation
WalkthroughThis update introduces a new action type, Changes
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
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 9
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 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
IsEnabledproperty of the button is bound toIsBrowseNeeded, 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 csLength of output: 628
IsBrowseNeeded Binding Verified and Present
The
IsBrowseNeededproperty is defined in bothAPIModelBodyKeyValueandWebAPIKeyBodyValues(in GingerCoreCommon), and both raiseOnPropertyChanged, so the binding on yourButtonwill 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 csLength 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.csLength of output: 716
Confirmed:
GridInputValuesBrowseBtn_Clickis implemented and functionalThe
GridInputValuesBrowseBtn_Clickhandler is defined in Ginger/Ginger/Actions/ActionEditPage.xaml.cs (lines 2523–2536). It correctly casts the current grid item, opens a file dialog viaGeneral.SetupBrowseFile, and updates the selected file path on the item. No further action required.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
Ginger/GingerCoreNET/ActionsLib/ActPublishArtifacts.cs (1)
71-102: 🛠️ Refactor suggestionSet 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; + } }
There was a problem hiding this comment.
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 suggestionSet action status based on error condition.
The
Executemethod 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
📒 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
ActionEditPageandActionUserDescriptionproperties.
68-71: Good user documentation.The
ActionUserRecommendedUseCasemethod 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
ActInputValuesis 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.
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit
New Features
Bug Fixes