From b942dbd9b5182d1023b3a4e8c4bd6d19b7b5798e Mon Sep 17 00:00:00 2001 From: khari thomas Date: Tue, 15 Oct 2024 14:18:39 -0500 Subject: [PATCH 01/29] add config support for scroll alignment --- .../ActUIElementEditPage.xaml.cs | 3 ++ .../UIElementScrollToOptionsPage.xaml | 24 ++++++++++ .../UIElementScrollToOptionsPage.xaml.cs | 46 +++++++++++++++++++ .../Actions/UI Element/ActUIElement.cs | 3 ++ .../Web/Selenium/SeleniumDriver.cs | 4 +- 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml create mode 100644 Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/ActUIElementEditPage.xaml.cs b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/ActUIElementEditPage.xaml.cs index b790f94208..57e03a36db 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/ActUIElementEditPage.xaml.cs +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/ActUIElementEditPage.xaml.cs @@ -276,6 +276,9 @@ private Page GetControlSpecificPageContent() pageContent = new UIElementXYCoordinatePage(mAction); break; + case eElementAction.ScrollToElement: + pageContent = new UIElementScrollToOptionsPage(mAction); + break; case eElementAction.DoubleClick: case eElementAction.WinClick: diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml new file mode 100644 index 0000000000..6f3bc5a204 --- /dev/null +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs new file mode 100644 index 0000000000..a308e9af45 --- /dev/null +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs @@ -0,0 +1,46 @@ +using GingerCore.Actions.Common; +using GingerCore.GeneralLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Controls; + +namespace Ginger.Actions._Common.ActUIElementLib +{ + /// + /// Interaction logic for UIElementScrollToOptionsPage.xaml + /// + public partial class UIElementScrollToOptionsPage : Page + { + private readonly ActUIElement _action; + + private enum eScrollAlignment + { + Start, + Center, + End, + Nearest + } + + public UIElementScrollToOptionsPage(ActUIElement action) + { + InitializeComponent(); + + _action = action; + + // Generate list of options from Enum + List _scrollPositions = Enum.GetValues(typeof(eScrollAlignment)) + .Cast() + .Select(pos => new ComboItem() + { + text = pos.ToString(), + Value = (int)pos + }) + .Cast() + .ToList(); + + // Bind alignment options with combo box + scrollAlignmentComboBox.Init(_action.GetOrCreateInputParam(ActUIElement.Fields.ScrollAlignment, eScrollAlignment.Start.ToString()), _scrollPositions, false); + } + } +} diff --git a/Ginger/GingerCoreCommon/Actions/UI Element/ActUIElement.cs b/Ginger/GingerCoreCommon/Actions/UI Element/ActUIElement.cs index 395a81a4ab..2c236d72bf 100644 --- a/Ginger/GingerCoreCommon/Actions/UI Element/ActUIElement.cs +++ b/Ginger/GingerCoreCommon/Actions/UI Element/ActUIElement.cs @@ -141,6 +141,9 @@ public override List Platforms //used for SelectandValidate public static string SubElementLocateBy = "SubElementLocateBy"; public static string SubElementLocatorValue = "SubElementLocatorValue"; + + // use for ScrollToElement + public static string ScrollAlignment = "ScrollAlignment"; } // Fields Helper for specific action, will create AIV with param name based on enum diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs index d08ddefd29..aa32377cc0 100644 --- a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs @@ -8998,7 +8998,9 @@ public void HandleActUIElement(ActUIElement act) case ActUIElement.eElementAction.ScrollToElement: try { - ((IJavaScriptExecutor)Driver).ExecuteScript("arguments[0].scrollIntoView(true);", e); + string scrollAlignment = act.GetInputParamCalculatedValue(ActUIElement.Fields.ScrollAlignment).ToLower(); + string command = $"arguments[0].scrollIntoView({{ block: '{scrollAlignment}' }});"; + ((IJavaScriptExecutor)Driver).ExecuteScript(command, e); } catch (Exception) { From 24aeed7698307afc130ee86cfee6464b1b00a570 Mon Sep 17 00:00:00 2001 From: khari thomas Date: Tue, 15 Oct 2024 14:19:33 -0500 Subject: [PATCH 02/29] fix misc. misspelling --- .../ActUIElementLib/UIElementXYCoordinatePage.xaml.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementXYCoordinatePage.xaml.cs b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementXYCoordinatePage.xaml.cs index e1c5914702..807c63b418 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementXYCoordinatePage.xaml.cs +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementXYCoordinatePage.xaml.cs @@ -41,9 +41,9 @@ public UIElementXYCoordinatePage(ActUIElement Act) if (mAct.ElementData != null) { string[] spliter = new string[] { "," }; - string[] cordinations = Convert.ToString(mAct.ElementData).Split(spliter, StringSplitOptions.RemoveEmptyEntries); - mAct.AddOrUpdateInputParamValue("XCoordinate", cordinations[0]); - mAct.AddOrUpdateInputParamValue("YCoordinate", cordinations[1]); + string[] coordinates = Convert.ToString(mAct.ElementData).Split(spliter, StringSplitOptions.RemoveEmptyEntries); + mAct.AddOrUpdateInputParamValue("XCoordinate", coordinates[0]); + mAct.AddOrUpdateInputParamValue("YCoordinate", coordinates[1]); } if (mAct.ElementAction == ActUIElement.eElementAction.SendKeysXY) From fc1d7dfca4e35e9004376ad42f8d89e322aee16b Mon Sep 17 00:00:00 2001 From: khari thomas Date: Wed, 16 Oct 2024 10:59:36 -0500 Subject: [PATCH 03/29] add logic to restore scroll position --- .../Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs index a23c0827f6..e2aeca24ed 100644 --- a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs @@ -26,6 +26,9 @@ public static class ChromeDriverEx { public static Screenshot GetFullPageScreenshot(this ChromiumDriver driver) { + // Capture the original scroll position + var originalScrollPosition = driver.ExecuteScript("return { x: window.pageXOffset, y: window.pageYOffset };"); + //Dictionary will contain the parameters needed to get the full page screen shot Dictionary metrics = new Dictionary { @@ -57,6 +60,9 @@ public static Screenshot GetFullPageScreenshot(this ChromiumDriver driver) //This command will return your browser back to a normal, usable form if you need to do anything else with it. driver.ExecuteCdpCommand("Emulation.clearDeviceMetricsOverride", []); + // Restore the original scroll position + driver.ExecuteScript($"window.scrollTo({{ top: {((IDictionary)originalScrollPosition)["y"]}, left: {((IDictionary)originalScrollPosition)["x"]} }});"); + return screenshot; } } From 2b2c3178be88e220c95a52e1e5c8ef6864585da2 Mon Sep 17 00:00:00 2001 From: khari thomas Date: Wed, 16 Oct 2024 11:02:57 -0500 Subject: [PATCH 04/29] code refactor --- .../Web/Selenium/ChromeDriverEx.cs | 41 ++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs index e2aeca24ed..48613f00a2 100644 --- a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs @@ -27,41 +27,26 @@ public static class ChromeDriverEx public static Screenshot GetFullPageScreenshot(this ChromiumDriver driver) { // Capture the original scroll position - var originalScrollPosition = driver.ExecuteScript("return { x: window.pageXOffset, y: window.pageYOffset };"); + Dictionary originalScrollPosition = (Dictionary)driver.ExecuteScript("return { x: window.pageXOffset, y: window.pageYOffset };"); - //Dictionary will contain the parameters needed to get the full page screen shot + // Capture page dimensions and device metrics Dictionary metrics = new Dictionary { - ["width"] = driver.ExecuteScript("return Math.max(window.innerWidth,document.body.scrollWidth,document.documentElement.scrollWidth)"), - ["height"] = driver.ExecuteScript("return Math.max(window.innerHeight,document.body.scrollHeight,document.documentElement.scrollHeight)") + ["width"] = driver.ExecuteScript("return Math.max(window.innerWidth, document.body.scrollWidth, document.documentElement.scrollWidth)"), + ["height"] = driver.ExecuteScript("return Math.max(window.innerHeight, document.body.scrollHeight, document.documentElement.scrollHeight)"), + ["deviceScaleFactor"] = Convert.ToDouble(driver.ExecuteScript("return window.devicePixelRatio") ?? 1), + ["mobile"] = driver.ExecuteScript("return typeof window.orientation !== 'undefined'") }; - object devicePixelRatio = driver.ExecuteScript("return window.devicePixelRatio"); - if (devicePixelRatio != null) - { - double doubleValue = 0; - if (double.TryParse(devicePixelRatio.ToString(), out doubleValue)) - { - metrics["deviceScaleFactor"] = doubleValue; - } - else - { - long longValue = 0; - if (long.TryParse(devicePixelRatio.ToString(), out longValue)) - { - metrics["deviceScaleFactor"] = longValue; - } - } - } - metrics["mobile"] = driver.ExecuteScript("return typeof window.orientation !== 'undefined'"); - //Execute the emulation Chrome Command to change browser to a custom device that is the size of the entire page + + // Execute the emulation Chrome command to change browser to a custom device that is the size of the entire page driver.ExecuteCdpCommand("Emulation.setDeviceMetricsOverride", metrics); - //You can then just screenshot it as it thinks everything is visible + + // Take screenshot as everything is now visible Screenshot screenshot = driver.GetScreenshot(); - //This command will return your browser back to a normal, usable form if you need to do anything else with it. - driver.ExecuteCdpCommand("Emulation.clearDeviceMetricsOverride", []); - // Restore the original scroll position - driver.ExecuteScript($"window.scrollTo({{ top: {((IDictionary)originalScrollPosition)["y"]}, left: {((IDictionary)originalScrollPosition)["x"]} }});"); + // Reset the device metrics and scroll position to original state + driver.ExecuteCdpCommand("Emulation.clearDeviceMetricsOverride", new Dictionary()); + driver.ExecuteScript($"window.scrollTo({{ top: {originalScrollPosition["y"]}, left: {originalScrollPosition["x"]}, behavior: 'instant' }});"); return screenshot; } From 915e2e2659b5cd29b41ad53fe28c055d90519e64 Mon Sep 17 00:00:00 2001 From: khari thomas Date: Wed, 16 Oct 2024 11:22:39 -0500 Subject: [PATCH 05/29] fix re-initialization bug --- .../UIElementScrollToOptionsPage.xaml.cs | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs index a308e9af45..7d515ed931 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs @@ -1,8 +1,5 @@ using GingerCore.Actions.Common; -using GingerCore.GeneralLib; -using System; using System.Collections.Generic; -using System.Linq; using System.Windows.Controls; namespace Ginger.Actions._Common.ActUIElementLib @@ -12,9 +9,7 @@ namespace Ginger.Actions._Common.ActUIElementLib /// public partial class UIElementScrollToOptionsPage : Page { - private readonly ActUIElement _action; - - private enum eScrollAlignment + public enum eScrollAlignment { Start, Center, @@ -26,21 +21,14 @@ public UIElementScrollToOptionsPage(ActUIElement action) { InitializeComponent(); - _action = action; - - // Generate list of options from Enum - List _scrollPositions = Enum.GetValues(typeof(eScrollAlignment)) - .Cast() - .Select(pos => new ComboItem() - { - text = pos.ToString(), - Value = (int)pos - }) - .Cast() - .ToList(); + List scrollPositions = [ + eScrollAlignment.Start, + eScrollAlignment.Center, + eScrollAlignment.End, + eScrollAlignment.Nearest, + ]; - // Bind alignment options with combo box - scrollAlignmentComboBox.Init(_action.GetOrCreateInputParam(ActUIElement.Fields.ScrollAlignment, eScrollAlignment.Start.ToString()), _scrollPositions, false); + scrollAlignmentComboBox.Init(action.GetOrCreateInputParam(ActUIElement.Fields.ScrollAlignment), scrollPositions, false); } } } From 1ec8f48132dfbf513d3736183a11acd7f2a26003 Mon Sep 17 00:00:00 2001 From: khari thomas Date: Wed, 16 Oct 2024 11:24:02 -0500 Subject: [PATCH 06/29] rename class --- .../ActUIElementLib/ActUIElementEditPage.xaml.cs | 2 +- .../ActUIElementLib/UIElementScrollToOptionsPage.xaml | 2 +- .../ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/ActUIElementEditPage.xaml.cs b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/ActUIElementEditPage.xaml.cs index 57e03a36db..775d3944de 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/ActUIElementEditPage.xaml.cs +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/ActUIElementEditPage.xaml.cs @@ -277,7 +277,7 @@ private Page GetControlSpecificPageContent() break; case eElementAction.ScrollToElement: - pageContent = new UIElementScrollToOptionsPage(mAction); + pageContent = new UIElementScrollToElementOptionsPage(mAction); break; case eElementAction.DoubleClick: diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml index 6f3bc5a204..ef341e06ab 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml @@ -1,5 +1,5 @@  /// Interaction logic for UIElementScrollToOptionsPage.xaml /// - public partial class UIElementScrollToOptionsPage : Page + public partial class UIElementScrollToElementOptionsPage : Page { public enum eScrollAlignment { @@ -17,7 +17,7 @@ public enum eScrollAlignment Nearest } - public UIElementScrollToOptionsPage(ActUIElement action) + public UIElementScrollToElementOptionsPage(ActUIElement action) { InitializeComponent(); From a146c9f9d3e018e286c62125bca8588ab327c943 Mon Sep 17 00:00:00 2001 From: khari thomas Date: Wed, 16 Oct 2024 11:25:27 -0500 Subject: [PATCH 07/29] minor code refactor --- .../ActUIElementLib/UIElementScrollToOptionsPage.xaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml index ef341e06ab..5939892cdb 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml @@ -13,7 +13,6 @@ - From 825f96230191d4a5b5a5714fa7868c604a8cddc9 Mon Sep 17 00:00:00 2001 From: Gokul Bothe <96767038+GokulBothe99@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:39:16 +0530 Subject: [PATCH 08/29] Dynamic execution for browser --- Ginger/Ginger/App.xaml.cs | 25 +++++++++++++-- .../GingerCoreNET/RunLib/CLILib/DoOptions.cs | 32 ++++++++++++++++++- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/Ginger/Ginger/App.xaml.cs b/Ginger/Ginger/App.xaml.cs index 3a6bb77fe2..5525844f67 100644 --- a/Ginger/Ginger/App.xaml.cs +++ b/Ginger/Ginger/App.xaml.cs @@ -33,6 +33,7 @@ limitations under the License. using GingerWPF.WorkSpaceLib; using System; using System.Collections.Generic; +using System.IO; using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows; @@ -256,6 +257,11 @@ private async void Application_Startup(object sender, StartupEventArgs e) { InitLogging(); + if (e.Args.Length != 0) + { + EditCommandlineArguments(e.Args); + } + bool startGrid = ShouldStartGrid(e.Args); WorkSpace.Init(new WorkSpaceEventHandler(), startGrid); @@ -280,10 +286,23 @@ private async void Application_Startup(object sender, StartupEventArgs e) await RunNewCLI(parserResult); } } - catch (Exception ex) { + catch (Exception ex) + { Reporter.ToLog(eLogLevel.ERROR, "Unhandled exception in Application_Startup", ex); } + } + private void EditCommandlineArguments(string[] args) + { + for (int i = 0; i < args.Length; i++) + { + args[i] = System.Web.HttpUtility.UrlDecode(args[i]); + args[i] = args[i].Replace("gingercli://", "", StringComparison.OrdinalIgnoreCase); + } + if (args.Length > 0 && args[args.Length - 1].EndsWith("/")) + { + args[args.Length - 1] = args[args.Length - 1].TrimEnd('/'); + } } /// @@ -385,7 +404,7 @@ private void ProcessGingerUIStartup(DoOptions doOptions) StartGingerUI(); - if (doOptions != null && !string.IsNullOrWhiteSpace(doOptions.Solution)) + if (doOptions != null && !string.IsNullOrWhiteSpace(doOptions.Solution) && Directory.Exists(doOptions.Solution)) { DoOptionsHandler.Run(doOptions); } @@ -440,7 +459,7 @@ private async Task RunNewCLI(ParserResult parserResult) { System.Windows.Application.Current.Shutdown(Environment.ExitCode); } - + } public void StartGingerUI() diff --git a/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs b/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs index c995ec9242..86ad8f4aa4 100644 --- a/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs +++ b/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs @@ -17,6 +17,9 @@ limitations under the License. #endregion using CommandLine; +using System; +using System.IO; +using System.Web; namespace Amdocs.Ginger.CoreNET.RunLib.CLILib { @@ -35,8 +38,35 @@ public enum DoOperation [Option('o', "operation", Required = true, HelpText = "Select operation to run on solution")] public DoOperation Operation { get; set; } + private string _solution; + [Option('s', "solution", Required = true, HelpText = "Set solution folder")] - public string Solution { get; set; } + public string Solution + { + get => _solution; + set + { + string lowerValue = value.ToLowerInvariant(); + + if (lowerValue.Contains("ginger://")) + { + value = HttpUtility.UrlDecode(value.Replace("ginger://", "", StringComparison.OrdinalIgnoreCase)); + } + + if (value.EndsWith("/")) + { + value = value.TrimEnd('/'); + } + + if (value.Contains("Ginger.Solution.xml")) + { + value = Path.GetDirectoryName(value)?.Trim() ?? string.Empty; + + } + _solution = value; + } + } + } From e5744aa45d8bcad36fbda5ae7f7da206e1e7ede5 Mon Sep 17 00:00:00 2001 From: Gokul Bothe <96767038+GokulBothe99@users.noreply.github.com> Date: Fri, 18 Oct 2024 23:15:42 +0530 Subject: [PATCH 09/29] Added dynamic execution from browser --- Ginger/Ginger/App.xaml.cs | 49 +++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/Ginger/Ginger/App.xaml.cs b/Ginger/Ginger/App.xaml.cs index 5525844f67..2af4aeb2d4 100644 --- a/Ginger/Ginger/App.xaml.cs +++ b/Ginger/Ginger/App.xaml.cs @@ -34,7 +34,9 @@ limitations under the License. using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Runtime.InteropServices; +using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; @@ -257,11 +259,6 @@ private async void Application_Startup(object sender, StartupEventArgs e) { InitLogging(); - if (e.Args.Length != 0) - { - EditCommandlineArguments(e.Args); - } - bool startGrid = ShouldStartGrid(e.Args); WorkSpace.Init(new WorkSpaceEventHandler(), startGrid); @@ -291,6 +288,19 @@ private async void Application_Startup(object sender, StartupEventArgs e) Reporter.ToLog(eLogLevel.ERROR, "Unhandled exception in Application_Startup", ex); } } + static List SplitWithPaths(string input) + { + var pattern = @"[^\s""']+|""([^""]*)""|'([^']*)'"; + var matches = Regex.Matches(input, pattern); + var results = new List(); + + foreach (Match match in matches) + { + results.Add(match.Value.Trim()); + } + + return results; + } private void EditCommandlineArguments(string[] args) { for (int i = 0; i < args.Length; i++) @@ -323,7 +333,6 @@ private bool ShouldStartGrid(string[] args) { return args.Length == 0; } - /// /// Parses command-line arguments and returns the result. /// If no arguments are provided, returns null. @@ -332,8 +341,30 @@ private bool ShouldStartGrid(string[] args) /// ParserResult containing parsed arguments or null. private ParserResult ParseCommandLineArguments(string[] args) { + string[] arguments; + if (args.Length == 1 && System.Web.HttpUtility.UrlDecode(args[0]).Equals("ginger:///", StringComparison.OrdinalIgnoreCase)) + { + return null; + } + if (args.Length==1) + { + string input = args[0]; + input = System.Web.HttpUtility.UrlDecode(input); + if (input.StartsWith("ginger://")) + { + input = input.Substring("ginger://".Length); + } + List resultList = SplitWithPaths(input).Select(s => s.Trim('\"')).ToList(); + arguments = resultList.ToArray(); + } + else + { + arguments = args; + } + EditCommandlineArguments(arguments); + cliProcessor = new CLIProcessor(); - return args.Length != 0 ? cliProcessor.ParseArguments(args) : null; + return arguments.Length != 0 ? cliProcessor.ParseArguments(arguments) : null; } /// @@ -360,6 +391,10 @@ private DoOptions ExtractDoOptions(ParserResult parserResult) /// True if the application is in execution mode, otherwise false. private bool IsExecutionMode(string[] args, DoOptions doOptions) { + if (args.Length == 1 && System.Web.HttpUtility.UrlDecode(args[0]).Equals("ginger:///", StringComparison.OrdinalIgnoreCase)) + { + return false; + } return args.Length != 0 && doOptions == null; } From fd124ab8ecb0c3779f1c4ed70aaafcf30bda2037 Mon Sep 17 00:00:00 2001 From: Gokul Bothe <96767038+GokulBothe99@users.noreply.github.com> Date: Mon, 21 Oct 2024 12:36:23 +0530 Subject: [PATCH 10/29] suggested changes --- Ginger/Ginger/App.xaml.cs | 12 ++++++------ Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Ginger/Ginger/App.xaml.cs b/Ginger/Ginger/App.xaml.cs index 2af4aeb2d4..7a99e01a2b 100644 --- a/Ginger/Ginger/App.xaml.cs +++ b/Ginger/Ginger/App.xaml.cs @@ -305,7 +305,7 @@ private void EditCommandlineArguments(string[] args) { for (int i = 0; i < args.Length; i++) { - args[i] = System.Web.HttpUtility.UrlDecode(args[i]); + // args[i] = System.Web.HttpUtility.UrlDecode(args[i]); args[i] = args[i].Replace("gingercli://", "", StringComparison.OrdinalIgnoreCase); } @@ -333,12 +333,12 @@ private bool ShouldStartGrid(string[] args) { return args.Length == 0; } + /// - /// Parses command-line arguments and returns the result. - /// If no arguments are provided, returns null. + /// Parses the command line arguments and returns the parsed result. /// - /// Command-line arguments. - /// ParserResult containing parsed arguments or null. + /// The command line arguments. + /// The parsed result of the command line arguments. private ParserResult ParseCommandLineArguments(string[] args) { string[] arguments; @@ -346,7 +346,7 @@ private ParserResult ParseCommandLineArguments(string[] args) { return null; } - if (args.Length==1) + if (args.Length == 1) { string input = args[0]; input = System.Web.HttpUtility.UrlDecode(input); diff --git a/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs b/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs index 86ad8f4aa4..43bbe78df6 100644 --- a/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs +++ b/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs @@ -19,7 +19,7 @@ limitations under the License. using CommandLine; using System; using System.IO; -using System.Web; +using System.Net; namespace Amdocs.Ginger.CoreNET.RunLib.CLILib { @@ -50,7 +50,7 @@ public string Solution if (lowerValue.Contains("ginger://")) { - value = HttpUtility.UrlDecode(value.Replace("ginger://", "", StringComparison.OrdinalIgnoreCase)); + value = WebUtility.UrlDecode(value.Replace("ginger://", "", StringComparison.OrdinalIgnoreCase)); } if (value.EndsWith("/")) @@ -58,7 +58,7 @@ public string Solution value = value.TrimEnd('/'); } - if (value.Contains("Ginger.Solution.xml")) + if (value.IndexOf("Ginger.Solution.xml", StringComparison.OrdinalIgnoreCase) >= 0) { value = Path.GetDirectoryName(value)?.Trim() ?? string.Empty; From 5779dc0fd2d91964f1414d86eab6f0df6f42f78f Mon Sep 17 00:00:00 2001 From: Gokul Bothe <96767038+GokulBothe99@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:32:52 +0530 Subject: [PATCH 11/29] changes --- Ginger/Ginger/App.xaml.cs | 5 ++--- Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs | 8 +++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Ginger/Ginger/App.xaml.cs b/Ginger/Ginger/App.xaml.cs index 7a99e01a2b..31a97db39d 100644 --- a/Ginger/Ginger/App.xaml.cs +++ b/Ginger/Ginger/App.xaml.cs @@ -305,7 +305,6 @@ private void EditCommandlineArguments(string[] args) { for (int i = 0; i < args.Length; i++) { - // args[i] = System.Web.HttpUtility.UrlDecode(args[i]); args[i] = args[i].Replace("gingercli://", "", StringComparison.OrdinalIgnoreCase); } @@ -354,14 +353,14 @@ private ParserResult ParseCommandLineArguments(string[] args) { input = input.Substring("ginger://".Length); } - List resultList = SplitWithPaths(input).Select(s => s.Trim('\"')).ToList(); + List resultList = SplitWithPaths(input).Select(s => s.Trim('\"', '\'')).ToList(); arguments = resultList.ToArray(); } else { arguments = args; } - EditCommandlineArguments(arguments); + // EditCommandlineArguments(arguments); cliProcessor = new CLIProcessor(); return arguments.Length != 0 ? cliProcessor.ParseArguments(arguments) : null; diff --git a/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs b/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs index 43bbe78df6..ae7a0e09d3 100644 --- a/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs +++ b/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs @@ -46,9 +46,11 @@ public string Solution get => _solution; set { - string lowerValue = value.ToLowerInvariant(); - - if (lowerValue.Contains("ginger://")) + if (string.IsNullOrWhiteSpace(value)) + { + return; + } + if (value.IndexOf("ginger://", StringComparison.OrdinalIgnoreCase) >= 0) { value = WebUtility.UrlDecode(value.Replace("ginger://", "", StringComparison.OrdinalIgnoreCase)); } From ad3798630d81830aaade6ee692e834582630f7c4 Mon Sep 17 00:00:00 2001 From: Gokul Bothe <96767038+GokulBothe99@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:33:55 +0530 Subject: [PATCH 12/29] changes --- Ginger/Ginger/App.xaml.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Ginger/Ginger/App.xaml.cs b/Ginger/Ginger/App.xaml.cs index 31a97db39d..d97c87a83f 100644 --- a/Ginger/Ginger/App.xaml.cs +++ b/Ginger/Ginger/App.xaml.cs @@ -301,18 +301,7 @@ static List SplitWithPaths(string input) return results; } - private void EditCommandlineArguments(string[] args) - { - for (int i = 0; i < args.Length; i++) - { - args[i] = args[i].Replace("gingercli://", "", StringComparison.OrdinalIgnoreCase); - } - if (args.Length > 0 && args[args.Length - 1].EndsWith("/")) - { - args[args.Length - 1] = args[args.Length - 1].TrimEnd('/'); - } - } /// /// Initializes the logging mechanism for the application using log4net. @@ -360,7 +349,7 @@ private ParserResult ParseCommandLineArguments(string[] args) { arguments = args; } - // EditCommandlineArguments(arguments); + cliProcessor = new CLIProcessor(); return arguments.Length != 0 ? cliProcessor.ParseArguments(arguments) : null; From 899b662431e22d23397f9b4a1c910bb5f429ec58 Mon Sep 17 00:00:00 2001 From: Gokul Bothe <96767038+GokulBothe99@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:42:00 +0530 Subject: [PATCH 13/29] code enhancement --- Ginger/Ginger/App.xaml.cs | 27 ++++++++----------- Ginger/Ginger/GeneralLib/General.cs | 21 +++++++++++++++ .../GingerCoreNET/RunLib/CLILib/DoOptions.cs | 10 ------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/Ginger/Ginger/App.xaml.cs b/Ginger/Ginger/App.xaml.cs index d97c87a83f..6a814c09d6 100644 --- a/Ginger/Ginger/App.xaml.cs +++ b/Ginger/Ginger/App.xaml.cs @@ -288,20 +288,7 @@ private async void Application_Startup(object sender, StartupEventArgs e) Reporter.ToLog(eLogLevel.ERROR, "Unhandled exception in Application_Startup", ex); } } - static List SplitWithPaths(string input) - { - var pattern = @"[^\s""']+|""([^""]*)""|'([^']*)'"; - var matches = Regex.Matches(input, pattern); - var results = new List(); - - foreach (Match match in matches) - { - results.Add(match.Value.Trim()); - } - - return results; - } - + /// /// Initializes the logging mechanism for the application using log4net. @@ -330,6 +317,7 @@ private bool ShouldStartGrid(string[] args) private ParserResult ParseCommandLineArguments(string[] args) { string[] arguments; + //Added this codition if only user want to launch Ginger without any solution from browser. if (args.Length == 1 && System.Web.HttpUtility.UrlDecode(args[0]).Equals("ginger:///", StringComparison.OrdinalIgnoreCase)) { return null; @@ -342,7 +330,7 @@ private ParserResult ParseCommandLineArguments(string[] args) { input = input.Substring("ginger://".Length); } - List resultList = SplitWithPaths(input).Select(s => s.Trim('\"', '\'')).ToList(); + List resultList = General.SplitWithPaths(input).Select(s => s.Trim('\"', '\'')).ToList(); arguments = resultList.ToArray(); } else @@ -465,6 +453,11 @@ public static void ShowConsoleWindow() ShowWindow(handle, SW_SHOW); } + /// + /// Runs the new CLI process with the provided parsed arguments. + /// + /// The parsed result of the command line arguments. + /// A task representing the asynchronous operation. private async Task RunNewCLI(ParserResult parserResult) { try @@ -482,9 +475,11 @@ private async Task RunNewCLI(ParserResult parserResult) { System.Windows.Application.Current.Shutdown(Environment.ExitCode); } - } + /// + /// Starts the Ginger UI. Initializes dictionaries and the main window. + /// public void StartGingerUI() { if (WorkSpace.Instance.RunningFromUnitTest) diff --git a/Ginger/Ginger/GeneralLib/General.cs b/Ginger/Ginger/GeneralLib/General.cs index 2f178a57db..42a120b2b0 100644 --- a/Ginger/Ginger/GeneralLib/General.cs +++ b/Ginger/Ginger/GeneralLib/General.cs @@ -21,12 +21,14 @@ limitations under the License. using Amdocs.Ginger.Repository; using Ginger.Help; using System; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Security.Principal; +using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; using System.Windows.Forms; @@ -663,5 +665,24 @@ public static string EscapeAccessKey(string s) return s.Replace("_", "__"); } + + /// + /// Splits the input string into a list of strings, preserving paths enclosed in quotes. + /// + /// The input string to split. + /// A list of strings split from the input. + public static List SplitWithPaths(string input) + { + var pattern = @"[^\s""']+|""([^""]*)""|'([^']*)'"; + var matches = Regex.Matches(input, pattern); + var results = new List(); + + foreach (Match match in matches) + { + results.Add(match.Value.Trim()); + } + + return results; + } } } diff --git a/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs b/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs index ae7a0e09d3..21c8095184 100644 --- a/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs +++ b/Ginger/GingerCoreNET/RunLib/CLILib/DoOptions.cs @@ -50,16 +50,6 @@ public string Solution { return; } - if (value.IndexOf("ginger://", StringComparison.OrdinalIgnoreCase) >= 0) - { - value = WebUtility.UrlDecode(value.Replace("ginger://", "", StringComparison.OrdinalIgnoreCase)); - } - - if (value.EndsWith("/")) - { - value = value.TrimEnd('/'); - } - if (value.IndexOf("Ginger.Solution.xml", StringComparison.OrdinalIgnoreCase) >= 0) { value = Path.GetDirectoryName(value)?.Trim() ?? string.Empty; From 13b36821739b1a62f85131e8803cdcb706c7ea0d Mon Sep 17 00:00:00 2001 From: Gokul Bothe <96767038+GokulBothe99@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:19:50 +0530 Subject: [PATCH 14/29] handled comment --- Ginger/Ginger/App.xaml.cs | 12 ++++++++++-- Ginger/Ginger/GeneralLib/General.cs | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Ginger/Ginger/App.xaml.cs b/Ginger/Ginger/App.xaml.cs index 6a814c09d6..9fbc2513f7 100644 --- a/Ginger/Ginger/App.xaml.cs +++ b/Ginger/Ginger/App.xaml.cs @@ -415,9 +415,17 @@ private void ProcessGingerUIStartup(DoOptions doOptions) StartGingerUI(); - if (doOptions != null && !string.IsNullOrWhiteSpace(doOptions.Solution) && Directory.Exists(doOptions.Solution)) + if (doOptions != null && !string.IsNullOrWhiteSpace(doOptions.Solution)) { - DoOptionsHandler.Run(doOptions); + if(Directory.Exists(doOptions.Solution)) + { + DoOptionsHandler.Run(doOptions); + } + else + { + Reporter.ToLog(eLogLevel.ERROR, "The specified solution folder path does not exist. Please check the path and try again."); + } + } } finally diff --git a/Ginger/Ginger/GeneralLib/General.cs b/Ginger/Ginger/GeneralLib/General.cs index 42a120b2b0..3151fb916f 100644 --- a/Ginger/Ginger/GeneralLib/General.cs +++ b/Ginger/Ginger/GeneralLib/General.cs @@ -671,8 +671,12 @@ public static string EscapeAccessKey(string s) /// /// The input string to split. /// A list of strings split from the input. - public static List SplitWithPaths(string input) + public static List SplitWithPaths(string input) { + if (string.IsNullOrWhiteSpace(input)) + { + return new List(); + } var pattern = @"[^\s""']+|""([^""]*)""|'([^']*)'"; var matches = Regex.Matches(input, pattern); var results = new List(); From 0c94c20d1fdcfe8f03b80c715eb8ec9ade2e4b0d Mon Sep 17 00:00:00 2001 From: Gokul Bothe <96767038+GokulBothe99@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:25:28 +0530 Subject: [PATCH 15/29] variable name chnages --- Ginger/Ginger/GeneralLib/General.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ginger/Ginger/GeneralLib/General.cs b/Ginger/Ginger/GeneralLib/General.cs index 3151fb916f..e9ef940c3a 100644 --- a/Ginger/Ginger/GeneralLib/General.cs +++ b/Ginger/Ginger/GeneralLib/General.cs @@ -675,11 +675,11 @@ public static List SplitWithPaths(string input) { if (string.IsNullOrWhiteSpace(input)) { - return new List(); + return []; } var pattern = @"[^\s""']+|""([^""]*)""|'([^']*)'"; var matches = Regex.Matches(input, pattern); - var results = new List(); + List results = []; foreach (Match match in matches) { From ada9da2d2be91e23d73d21f1705c855ceb337964 Mon Sep 17 00:00:00 2001 From: Nadeem Jazmawe Date: Sun, 27 Oct 2024 14:46:58 +0200 Subject: [PATCH 16/29] Remove unused Azure Pipelines configuration files --- azure-linux-pipeline.yml | 103 ------------------------ azure-pipelines-3.yml | 51 ------------ azure-pipelines.yml | 165 --------------------------------------- 3 files changed, 319 deletions(-) delete mode 100644 azure-linux-pipeline.yml delete mode 100644 azure-pipelines-3.yml delete mode 100644 azure-pipelines.yml diff --git a/azure-linux-pipeline.yml b/azure-linux-pipeline.yml deleted file mode 100644 index 189ff3abad..0000000000 --- a/azure-linux-pipeline.yml +++ /dev/null @@ -1,103 +0,0 @@ -trigger: -- master -pr: [master, Features/Linux-Migration, Releases/*, Releases/*/* ] - -jobs: - -# ------------------------------------------------------------------------------------------------------ -# Request latest Ubunto/Linux -# ------------------------------------------------------------------------------------------------------ -- job: Linux - pool: - vmImage: 'ubuntu-latest' - -# ------------------------------------------------------------------------------------------------------ -# Job Variables -# ------------------------------------------------------------------------------------------------------ - variables: - solution: '**/*.sln' # = /home/vsts/work/1/s/Ginger - buildConfiguration: 'Release' - # artifactsFolder: 'D:\a\1\a' - - steps: - -# ------------------------------------------------------------------------------------------------------ -# installs version 8.0.100 latest -# ------------------------------------------------------------------------------------------------------ - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk 8.0.100' - inputs: - packageType: sdk - version: 8.0.100 - installationPath: $(Agent.ToolsDirectory)/dotnet - - -# ------------------------------------------------------------------------------------------------------ -# start Testing -# ------------------------------------------------------------------------------------------------------ - - script: dotnet test Ginger/GingerUtilsTest --configuration $(buildConfiguration) --logger trx --verbosity=normal - displayName: 'Testing GingerUtilsTest' - - - script: dotnet test Ginger/GingerCoreCommonTest --configuration $(buildConfiguration) --logger trx --verbosity=normal - displayName: 'Testing GingerCoreCommonTest' - - # for GingerCoreNET we use run setting to limit to have one worker thread due to workspace limitation - - script: dotnet test Ginger/GingerCoreNETUnitTest --configuration $(buildConfiguration) --logger trx --verbosity=normal - displayName: 'Testing GingerCoreNETUnitTest' - - - script: dotnet test Ginger/GingerPluginCoreTest --configuration $(buildConfiguration) --logger trx --verbosity=normal - displayName: 'Testing GingerPluginCoreTest' - - - script: dotnet test Ginger/GingerConsoleTest --configuration $(buildConfiguration) --logger trx --verbosity=normal - displayName: 'Testing GingerConsoleTest' - - - script: dotnet test Ginger/GingerAutoPilotTest --configuration $(buildConfiguration) --logger trx --verbosity=normal - displayName: 'Testing GingerAutoPilotTest' - -# ------------------------------------------------------------------------------------------------------ -# Publish GingerRuntime -# ------------------------------------------------------------------------------------------------------ - - script: dotnet publish Ginger/GingerRuntime -c Release - displayName: 'Publish GingerRuntime' - - -# ------------------------------------------------------------------------------------------------------ -# Publish Test Results -# ------------------------------------------------------------------------------------------------------ - - - task: PublishTestResults@2 - displayName: Publish test result - condition: succeededOrFailed() - inputs: - testRunner: VSTest - testResultsFiles: '**/*.trx' - -# ------------------------------------------------------------------------------------------------------ -# Run Standalone CLI Test -# ------------------------------------------------------------------------------------------------------ - - - task: PowerShell@2 - displayName: Run Standalone CLI Test - inputs: - filePath: CLITests.ps1 - condition: succeededOrFailed() - - -# ------------------------------------------------------------------------------------------------------ -# Package Test Artifacts -# ------------------------------------------------------------------------------------------------------ -# -# - task: PowerShell@2 -# displayName: Package test artifacts -# inputs: -# filePath: PackageTestArtifacts.ps1 -# condition: succeededOrFailed() - - - -# ------------------------------------------------------------------------------------------------------ -# Publish Test Artifacts -# ------------------------------------------------------------------------------------------------------ - - - task: PublishBuildArtifacts@1 - condition: succeededOrFailed() diff --git a/azure-pipelines-3.yml b/azure-pipelines-3.yml deleted file mode 100644 index 3bafe6cf12..0000000000 --- a/azure-pipelines-3.yml +++ /dev/null @@ -1,51 +0,0 @@ -trigger: -- master -pr: [master, Features/Linux-Migration, Releases/*, Releases/*/* ] - -pool: - vmImage: 'macOS-latest' - -variables: - solution: '**/*.sln' - buildPlatform: 'Any CPU' - buildConfiguration: 'Release' - -steps: -- task: UseDotNet@2 - inputs: - packageType: 'sdk' - version: '8.0.100' - -- script: dotnet test Ginger/GingerUtilsTest --configuration $(buildConfiguration) --logger trx - displayName: 'Testing GingerUtilsTest' - -- script: dotnet test Ginger/GingerCoreCommonTest --configuration $(buildConfiguration) --logger trx - displayName: 'Testing GingerCoreCommonTest' - -- script: dotnet test Ginger/GingerCoreNETUnitTest --configuration $(buildConfiguration) --logger trx - displayName: 'Testing GingerCoreNETUnitTest' - -- script: dotnet test Ginger/GingerPluginCoreTest --configuration $(buildConfiguration) --logger trx - displayName: 'Testing GingerPluginCoreTest' - -- script: dotnet test Ginger/GingerConsoleTest --configuration $(buildConfiguration) --logger trx - displayName: 'Testing GingerConsoleTest' - -- script: dotnet test Ginger/GingerAutoPilotTest --configuration $(buildConfiguration) --logger trx - displayName: 'Testing GingerAutoPilotTest' - - -- task: PublishTestResults@2 - displayName: Publish test result - condition: succeededOrFailed() - inputs: - testRunner: VSTest - testResultsFiles: '**/*.trx' - - -# ------------------------------------------------------------------------------------------------------ -# Publish Test Artifacts -# ------------------------------------------------------------------------------------------------------ - -#- task: PublishBuildArtifacts@1 -# condition: succeededOrFailed() diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index f2856e3130..0000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,165 +0,0 @@ -# .NET -trigger: -- master -pr: [master, Features/Linux-Migration, Releases/*, Releases/*/* ] - -jobs: - -# ------------------------------------------------------------------------------------------------------ -# Request Windows VM Windows windows-2022 with Visual Studio 2022 - set Ginger solution -# ------------------------------------------------------------------------------------------------------ - -- job: Windows - pool: - vmImage: 'windows-2022' #Visual Studio 2022 Preview on Windows Server 2019 - workspace: - clean: outputs - -# ------------------------------------------------------------------------------------------------------ -# Job Variables -# ------------------------------------------------------------------------------------------------------ - variables: - solution: '**/*.sln' # = D:\a\1\s\Ginger\Ginger.sln - buildPlatform: 'Any CPU' - buildConfiguration: 'Release' - solutionDirectory: 'Ginger-Automation/Ginger' - testDLLs: | - **\GingerUtilsTest\bin\$(buildConfiguration)\net8.0\GingerUtilsTest.dll - **\GingerCoreCommonTest\bin\$(buildConfiguration)\net8.0\GingerCoreCommonTest.dll - **\GingerCoreNETUnitTest\bin\$(buildConfiguration)\net8.0\GingerCoreNETUnitTest.dll - **\GingerConsoleTest\bin\$(buildConfiguration)\net8.0\GingerConsoleTest.dll - **\GingerAutoPilotTest\bin\$(buildConfiguration)\net8.0\GingerAutoPilotTest.dll - **\GingerPluginCoreTest\bin\$(buildConfiguration)\net8.0\GingerPluginCoreTest.dll - - artifactsFolder: 'D:\a\1\a' - - -# ------------------------------------------------------------------------------------------------------ -# Steps task -# ------------------------------------------------------------------------------------------------------ - steps: -# ------------------------------------------------------------------------------------------------------ -# Install .Net core SDK 8.0.100 -# ------------------------------------------------------------------------------------------------------ - - - task: UseDotNet@2 - inputs: - packageType: 'sdk' - version: '8.0.100' -# ------------------------------------------------------------------------------------------------------ -# Install Nuget tool -# ------------------------------------------------------------------------------------------------------ - - task: NuGetToolInstaller@1 - displayName: NuGet Tool Installer - -# ------------------------------------------------------------------------------------------------------ -# Restore Ginger solution NuGet packages -# ------------------------------------------------------------------------------------------------------ - - task: NuGetCommand@2 - inputs: - command: restore - restoreSolution: '$(solution)' - displayName: Restore Ginger Solution Nuget Packages - - - task: PowerShell@2 - inputs: - targetType: 'inline' - script: | - Write-Output "Build Reason = $(Build.Reason)" - $sldomain="amdocs.sealights.co" - $slagenttoken= "$(SLAGENTTOKEN)" - $APP_NAME='Ginger' - $APP_NAMESPACE='Amdocs.*,ginger.*' - Write-Output "Token $($SLAGENTTOKEN.SubString($SLAGENTTOKEN.Length-5))" - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Write-Output "Download the Sealights DotNet agent version set in settings..." - $agentversion = ((iwr -Uri https://$($sldomain)/api/v2/agents/dotnet/recommended -Headers @{'Accept' = 'application/json'; 'Authorization' = "Bearer $($slagenttoken)"}).Content | ConvertFrom-Json | Select-Object agent).agent.version - iwr -OutFile sealights-dotnet-agent.zip -Uri http://agents.sealights.co/SL.DotNet/SL.DotNet-$($agentversion).zip - Expand-Archive .\sealights-dotnet-agent.zip -DestinationPath SL.DotNet -Force - Write-Output "Sealights agent version used is:$(Get-Content .\SL.DotNet\version.txt)" - #Retrieve the same name of target branch as reported in Sealights Dashboard by removing the uncecessary prefix - $PR_NUMBER="$(system.pullRequest.pullRequestNumber)" - $REPO_URL="$(System.PullRequest.SourceRepositoryURI)" - $PR_TARGET_BRANCH="Releases/" + "$(System.PullRequest.TargetBranch)".Replace("refs/heads/","") - #Retrieve the last Commit Hash from the PR branch and not the one from the ADO local Merge (via git log history) - $PR_LAST_COMMIT=$(git log -2 --format=%H).Split(" ")[1] - Write-Output "`n*** Create PR BSID ***" - .\SL.DotNet\x64\SL.DotNet.exe prConfig --appName $APP_NAME --pullRequestNumber $PR_NUMBER --targetBranch $PR_TARGET_BRANCH --latestCommit $PR_LAST_COMMIT --repositoryUrl $REPO_URL --includeNamespace $APP_NAMESPACE --buildSessionIdFile $(Build.ArtifactStagingDirectory)\SealightsBuildSessionId.txt --token $($slagenttoken) --logEnabled true --logAppendConsole true --ignoreCertificateErrors true - Write-Output "`n*** Prepare for MSBuild ***" - .\SL.DotNet\x64\SL.DotNet.exe prepareForMsBuild --buildSessionIdFile $(Build.ArtifactStagingDirectory)\SealightsBuildSessionId.txt --workspacePath $(Build.Repository.LocalPath)\Ginger --baseDir $(Build.Repository.LocalPath) --ignoreGeneratedCode true --debugMode true --logEnabled true --logAppendConsole true --ignoreCertificateErrors true --token $($slagenttoken) --scm git --scmProvider vsts - displayName: Prepare for PR Build - continueOnError: true -# ------------------------------------------------------------------------------------------------------ -# Build Ginger Solution -# ------------------------------------------------------------------------------------------------------ - - task: VSBuild@1 - inputs: - solution: '$(solution)' # = D:\a\1\s\Ginger\Ginger.sln - # platform: 'x86' - # clean: true - configuration: '$(buildConfiguration)' - msbuildArgs: /NoLogo /m - # /TargetFrameworkVersion /TargetCompactFramework - # msbuildArchitecture: 'x86' # Optional. Options: x86, x64 - # TreatWarningsAsErrors / NoWarn -- do not allow warnings - do it later when we have zero warnings - displayName: Build Ginger solution - - - task: StartTestExecution@2 - inputs: - testStage: 'Unit Tests' - profilerArchitecture: 'x86' - sealightsToken: "$(SLAGENTTOKEN)" - SealightsBuildSessionId : $(Build.ArtifactStagingDirectory)\SealightsBuildSessionId.txt -# ------------------------------------------------------------------------------------------------------ -# Run Unit Test for .NET Core test DLLs -# ------------------------------------------------------------------------------------------------------ - - - task: VSTest@2 - displayName: 'Run tests for Ginger .Net Core *Test DLLs' - inputs: - testAssemblyVer2: $(testDLLs) - runInParallel: True - codeCoverageEnabled: True - - - - -# ------------------------------------------------------------------------------------------------------ -# Run .Net Framework tests using powershell and publish the results -# ------------------------------------------------------------------------------------------------------ - - - task: PowerShell@2 - displayName: Run tests for Ginger .NetFramework *Test Dlls - inputs: - filePath: TestDotNetFramework.ps1 - - - - task: PublishTestResults@2 - displayName: Publish .Net Framework test result - condition: succeededOrFailed() - inputs: - testResultsFormat: VSTest - testResultsFiles: '**/DotNetFramework/*.trx' - - - task: EndTestExecution@2 - inputs: - sealightsToken: "$(SLAGENTTOKEN)" - SealightsBuildSessionId : $(Build.ArtifactStagingDirectory)\SealightsBuildSessionId.txt -# ------------------------------------------------------------------------------------------------------ -# Package Ginger EXE -# ------------------------------------------------------------------------------------------------------ -# -# - task: PowerShell@2 -# displayName: Package Ginger EXE -# inputs: -# filePath: PackageGingerEXE.ps1 -# condition: succeededOrFailed() -# - - -# ------------------------------------------------------------------------------------------------------ -# PublishBuildArtifacts -# ------------------------------------------------------------------------------------------------------ - -# - task: PublishBuildArtifacts@1 -# condition: succeededOrFailed() From e238238d190f56a67ac43c96da9c478efda0a218 Mon Sep 17 00:00:00 2001 From: Nadeem Jazmawe Date: Sun, 27 Oct 2024 15:41:22 +0200 Subject: [PATCH 17/29] Refactor GitHub Actions workflow for CD --- .github/workflows/CD.yml | 93 +++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 29 deletions(-) diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index 06dbb094d2..f6788a095c 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -1,36 +1,71 @@ +# This GitHub Actions workflow is named "CD" and is triggered manually via the `workflow_dispatch` event. +# It accepts the following inputs: +# - major: Year (number, required, default: '24') +# - minor: Release (number, required, default: '4') +# - build: Beta (number, required, default: '0') +# - revision: Alpha (number, required, default: '0') +# - SSLCert: Add Certificate (choice, required, default: 'No', options: ['Yes', 'No']) +# +# The workflow consists of the following jobs: +# 1. Create-version-Number: +# - Runs on `ubuntu-latest`. +# - Generates version numbers and tags based on the input values. +# - Outputs `version_number` and `version_tag`. +# - Caches the generated version text file. +# +# 2. CI: +# - Depends on the `Create-version-Number` job. +# - Uses the `.github/workflows/CI.yml` workflow. +# - Inherits secrets. +# +# 3. Release: +# - Depends on the `CI` job. +# - Uses the `.github/workflows/Release.yml` workflow. +# - Inherits secrets. +# +# 4. Deploy: +# - Depends on the `Release` job. +# - Uses the `.github/workflows/Deploy.yml` workflow. +# +# 5. Docker: +# - Depends on the `CI` job. +# - Uses the `.github/workflows/Docker.yml` workflow. +# - Inherits secrets. + name: CD on: + # Trigger the workflow manually with the `workflow_dispatch` event workflow_dispatch: - inputs: - major: - description: Year - type: number - required: true - default: '24' - minor: - description: Release - type: number - required: true - default: '4' - build: - description: Beta - type: number - required: true - default: '0' - revision: - description: Alpha - type: number - required: true - default: '0' - SSLCert: - description: "Add Certificate" - type: choice - required: true - default: 'No' - options: - - 'Yes' - - 'No' + inputs: + major: + description: Year # The year of the release, e.g., 24 for 2024 + type: number + required: true + default: '24' + minor: + description: Release # The minor version of the release, e.g., 4 for the fourth release of the year + type: number + required: true + default: '4' + build: + description: Beta # The build number, typically used for beta versions + type: number + required: true + default: '0' + revision: + description: Alpha # The revision number, typically used for alpha versions + type: number + required: true + default: '0' + SSLCert: + description: "Add Certificate" # Option to add an SSL certificate + type: choice + required: true + default: 'No' + options: + - 'Yes' # Add SSL certificate + - 'No' # Do not add SSL certificate jobs: Create-version-Number: runs-on: ubuntu-latest From 36fcd54ed304f2a32cef9c1d080abcec571e5677 Mon Sep 17 00:00:00 2001 From: Nadeem Jazmawe Date: Sun, 27 Oct 2024 16:35:07 +0200 Subject: [PATCH 18/29] Refactor GitHub Actions workflow for CD --- .github/workflows/CI-2.yml | 2 +- .github/workflows/GingerBuild-2.yml | 104 ---------------------------- .github/workflows/GingerBuild.yml | 36 ++++++---- 3 files changed, 24 insertions(+), 118 deletions(-) delete mode 100644 .github/workflows/GingerBuild-2.yml diff --git a/.github/workflows/CI-2.yml b/.github/workflows/CI-2.yml index ad7b6fea86..af0535899a 100644 --- a/.github/workflows/CI-2.yml +++ b/.github/workflows/CI-2.yml @@ -21,7 +21,7 @@ jobs: Build: name: Build Stage # needs: Codacy - uses: ./.github/workflows/GingerBuild-2.yml + uses: ./.github/workflows/GingerBuild.yml Test: name: Test Stage diff --git a/.github/workflows/GingerBuild-2.yml b/.github/workflows/GingerBuild-2.yml deleted file mode 100644 index 1c443627d7..0000000000 --- a/.github/workflows/GingerBuild-2.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: Ginger_Builder - -on: - workflow_call: - -jobs: - build: - runs-on: windows-latest - - env: - BUILD_CONFIGURATION: Release - - steps: -# ------------------------------------------------------------------------------------------------------ -# Createin version Tag & Number variables - only for CD Job -# ------------------------------------------------------------------------------------------------------ - - name: Restore Version text file - if: ${{github.workflow == 'CD'}} - uses: actions/cache@v3.2.6 - with: - path: ./version.txt - key: cache-version-${{ github.run_number }} - enableCrossOsArchive: - true - - - name: Create variables from Artifacts file - if: ${{github.workflow == 'CD'}} - shell: bash - run: | - source version.txt - echo $TAG - echo "gingernumber=$NUMBER" >> $GITHUB_ENV - echo "gingertag=$TAG" >> $GITHUB_ENV - -# ------------------------------------------------------------------------------------------------------ -# Copy Ginger repo -# ------------------------------------------------------------------------------------------------------ - - uses: actions/checkout@v3 - -# ------------------------------------------------------------------------------------------------------ -# Update Ginger Version -# ------------------------------------------------------------------------------------------------------ - - name: 'Update Assembly' - if: ${{github.workflow == 'CD'}} - run: | - $save=((Get-Content .\Ginger\GingerCoreCommon/GingerCoreCommon.csproj) -replace '*.*.*.*','${{ env.gingernumber}}') -replace '*.*.*.*','${{ env.gingernumber}}' - echo $save > .\Ginger\GingerCoreCommon/GingerCoreCommon.csproj - $save=(Get-Content .\Ginger\GingerInstallerScript.iss) -replace '#define MyAppVersion "*.*.*.*"','#define MyAppVersion "${{ env.gingernumber}}"' - echo $save > .\Ginger\GingerInstallerScript.iss - $save=(Get-Content .\Ginger\GingerCore\Drivers\JavaDriverLib\GingerJavaAgent\agent\com\amdocs\ginger\GingerAgent.java) -replace 'public static final String GINGER_JAVA_AGENT_VERSION="*.*.*.*";','public static final String GINGER_JAVA_AGENT_VERSION="${{ env.gingernumber}}";' - echo $save > .\Ginger\GingerCore\Drivers\JavaDriverLib\GingerJavaAgent\agent\com\amdocs\ginger\GingerAgent.java - $save=(Get-Content .\Ginger\GingerInstallerScriptGithub.iss) -replace '#define MyAppVersion "*.*.*.*"','#define MyAppVersion "${{ env.gingernumber}}"' - echo $save > .\Ginger\GingerInstallerScriptGithub.iss - -# ------------------------------------------------------------------------------------------------------ -# Install .Net core SDK 8.0.100 -# ------------------------------------------------------------------------------------------------------ - - name: 'Install .NET 8' - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 8.0.100 - -# ------------------------------------------------------------------------------------------------------ -# Install Nuget tool v1.0.5 -# ------------------------------------------------------------------------------------------------------ - - name: 'Setup Nuget' - uses: Nuget/setup-nuget@v1.0.5 - -# ------------------------------------------------------------------------------------------------------ -# Restore Ginger solution NuGet packages -# ------------------------------------------------------------------------------------------------------ - - name: 'Restore nuget packages' - run: nuget restore ./Ginger/Ginger.sln - -# ------------------------------------------------------------------------------------------------------ -# Install msbild && Build Ginger Solution -# ------------------------------------------------------------------------------------------------------ - - name: 'Add msbuild to PATH' - uses: microsoft/setup-msbuild@v1.0.2 - - - name: 'Build Ginger Solution' - run: msbuild ./Ginger/Ginger.sln /p:DebugSymbols=true /p:DebugType=full /p:Configuration=$env:BUILD_CONFIGURATION - -# ------------------------------------------------------------------------------------------------------ -# Publish GingerRuntime -# ------------------------------------------------------------------------------------------------------ - - name: 'Publish GingerRuntime' - run: dotnet publish ./Ginger/GingerRuntime/GingerRuntime.csproj --runtime linux-x64 --self-contained true -c Release - -# ------------------------------------------------------------------------------------------------------ -# Upload Artifacts -# ------------------------------------------------------------------------------------------------------ - - name: Cache static site content - id: cache - uses: actions/cache@v3.2.6 - with: - path: - ./** - key: - cache-site-${{ github.run_number }} - enableCrossOsArchive: - true - - diff --git a/.github/workflows/GingerBuild.yml b/.github/workflows/GingerBuild.yml index 7f8aab65d5..1c443627d7 100644 --- a/.github/workflows/GingerBuild.yml +++ b/.github/workflows/GingerBuild.yml @@ -14,11 +14,14 @@ jobs: # ------------------------------------------------------------------------------------------------------ # Createin version Tag & Number variables - only for CD Job # ------------------------------------------------------------------------------------------------------ - - name: Download Version Artifacts - if: ${{github.workflow == 'CD'}} - uses: actions/download-artifact@v3 + - name: Restore Version text file + if: ${{github.workflow == 'CD'}} + uses: actions/cache@v3.2.6 with: - name: ginger-version + path: ./version.txt + key: cache-version-${{ github.run_number }} + enableCrossOsArchive: + true - name: Create variables from Artifacts file if: ${{github.workflow == 'CD'}} @@ -50,12 +53,12 @@ jobs: echo $save > .\Ginger\GingerInstallerScriptGithub.iss # ------------------------------------------------------------------------------------------------------ -# Install .Net core SDK 6.0.301 +# Install .Net core SDK 8.0.100 # ------------------------------------------------------------------------------------------------------ - - name: 'Install .NET Core' + - name: 'Install .NET 8' uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.x.x + dotnet-version: 8.0.100 # ------------------------------------------------------------------------------------------------------ # Install Nuget tool v1.0.5 @@ -83,12 +86,19 @@ jobs: # ------------------------------------------------------------------------------------------------------ - name: 'Publish GingerRuntime' run: dotnet publish ./Ginger/GingerRuntime/GingerRuntime.csproj --runtime linux-x64 --self-contained true -c Release - + # ------------------------------------------------------------------------------------------------------ # Upload Artifacts -# ------------------------------------------------------------------------------------------------------ - - name: 'Upload static site content' - uses: actions/upload-artifact@v3 +# ------------------------------------------------------------------------------------------------------ + - name: Cache static site content + id: cache + uses: actions/cache@v3.2.6 with: - name: ginger-artifact - path: ./ + path: + ./** + key: + cache-site-${{ github.run_number }} + enableCrossOsArchive: + true + + From 1cc30f34b646745990f7fd4197fe5b318d4ca48d Mon Sep 17 00:00:00 2001 From: Nadeem Jazmawe Date: Sun, 27 Oct 2024 17:27:38 +0200 Subject: [PATCH 19/29] Refactor GitHub Actions workflow for CD --- .github/workflows/CI-2.yml | 2 +- .github/workflows/GingerTests-2.yml | 13 -- .github/workflows/GingerTests.yml | 12 +- .github/workflows/WindowsTest-2.yml | 185 ---------------------------- .github/workflows/WindowsTest.yml | 118 +++++++++--------- 5 files changed, 67 insertions(+), 263 deletions(-) delete mode 100644 .github/workflows/GingerTests-2.yml delete mode 100644 .github/workflows/WindowsTest-2.yml diff --git a/.github/workflows/CI-2.yml b/.github/workflows/CI-2.yml index af0535899a..1b47e7447d 100644 --- a/.github/workflows/CI-2.yml +++ b/.github/workflows/CI-2.yml @@ -26,5 +26,5 @@ jobs: Test: name: Test Stage needs: Build - uses: ./.github/workflows/GingerTests-2.yml + uses: ./.github/workflows/GingerTests.yml secrets: inherit diff --git a/.github/workflows/GingerTests-2.yml b/.github/workflows/GingerTests-2.yml deleted file mode 100644 index 0f2cef45a2..0000000000 --- a/.github/workflows/GingerTests-2.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Ginger-Tests - -on: - workflow_call - -jobs: - windows: - uses: ./.github/workflows/WindowsTest-2.yml - secrets: inherit - Linux: - uses: ./.github/workflows/LinuxTest-2.yml -# MacOS: -# uses: ./.github/workflows/MacOSTest-2.yml diff --git a/.github/workflows/GingerTests.yml b/.github/workflows/GingerTests.yml index 1215874795..33c33cbf96 100644 --- a/.github/workflows/GingerTests.yml +++ b/.github/workflows/GingerTests.yml @@ -1,15 +1,13 @@ name: Ginger-Tests - + on: workflow_call - + jobs: windows: uses: ./.github/workflows/WindowsTest.yml secrets: inherit - Linux: - uses: ./.github/workflows/LinuxTest.yml - -# MacOS: -# uses: ./.github/workflows/MacOSTest.yml + uses: ./.github/workflows/LinuxTest-2.yml + MacOS: + uses: ./.github/workflows/MacOSTest-2.yml diff --git a/.github/workflows/WindowsTest-2.yml b/.github/workflows/WindowsTest-2.yml deleted file mode 100644 index eb4be322c1..0000000000 --- a/.github/workflows/WindowsTest-2.yml +++ /dev/null @@ -1,185 +0,0 @@ -name: Ginger Windows Test - -on: - workflow_dispatch: - workflow_call: - -jobs: - build: - name: Windows Test - runs-on: windows-latest - - env: - BUILD_CONFIGURATION: "Release" - SLDOMAIN: "amdocs.sealights.co" - APP_NAME: "Ginger" - APP_NAMESPACE: "Amdocs.*,ginger.*" - PR_NUMBER: ${{github.event.pull_request.number}} - PR_TARGET_BRANCH: "Releases/${{github.base_ref}}" - PR_LAST_COMMIT: ${{ github.event.pull_request.head.sha }} - REPO_URL: ${{github.repositoryUrl }} - - steps: -# ------------------------------------------------------------------------------------------------------ -# Copy Ginger repo -# ------------------------------------------------------------------------------------------------------ - - name: Code Checkout - if: ${{github.workflow == 'Ginger Windows Test'}} - uses: actions/checkout@v3 - - - - name: Restore static site content - if: ${{github.workflow != 'Ginger Windows Test'}} - uses: actions/cache@v3.2.6 - with: - path: ./** - key: cache-site-${{ github.run_number }} - enableCrossOsArchive: - true - - -# ------------------------------------------------------------------------------------------------------ -# Install .Net core SDK 8.0.100 -# ------------------------------------------------------------------------------------------------------ - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 8.0.100 - -# ------------------------------------------------------------------------------------------------------ -# Install Nuget tool v1.0.5 -# ------------------------------------------------------------------------------------------------------ - - name: Setup Nuget - uses: Nuget/setup-nuget@v1.0.5 - -# ------------------------------------------------------------------------------------------------------ -# Restore Ginger solution NuGet packages -# ------------------------------------------------------------------------------------------------------ - - name: Restore nuget packages - run: nuget restore ./Ginger/Ginger.sln - -# ------------------------------------------------------------------------------------------------------ -# SeaLight - Downloading the .NET agent files && Scanning a build using MSBuild -# --------------------------------------------------------------------------------------------------- - -# - name: Download Sealights .Net agent -# run: | -# Write-Output "Build Reason = ${{github.event_name}}" -# echo $env:SLDOMAIN -# echo $env:BUILD_CONFIGURATION -# [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -# Write-Output "Download the Sealights DotNet agent version set in settings..." -# $agentversion = ((iwr -Uri https://amdocs.sealights.co/api/v2/agents/dotnet/recommended -Headers @{'Accept' = 'application/json'; 'Authorization' = "Bearer ${{ secrets.SLT }}"}).Content | ConvertFrom-Json | Select-Object agent).agent.version -# Write-Output "*** start download ***" -# iwr -OutFile sealights-dotnet-agent.zip -Uri http://agents.sealights.co/SL.DotNet/SL.DotNet-$($agentversion).zip -# Expand-Archive .\sealights-dotnet-agent.zip -DestinationPath SL.DotNet -Force -# Write-Output "Sealights agent version used is:$(Get-Content .\SL.DotNet\version.txt)" - -# - name: Sealights - Generating a Pull Request Session ID -# id: SealightsPR -# if: ${{github.event_name == 'pull_request'}} -# run: | -# Write-Output "*** Create PR BSID ***" -# .\SL.DotNet\x64\SL.DotNet prConfig --token ${{ secrets.SLT }} --appName ${{ env.APP_NAME }} --includeNamespace ${{ env.APP_NAMESPACE }} --pullRequestNumber 25 --latestCommit a51d0f337dc7547d20dbf5fbfea1c45831249325 --targetBranch Release/master --repositoryUrl ${{ env.REPO_URL }} - -# - name: Sealights - Generating a Standard Session ID -# id: SealightsStandard -# if: ${{github.event_name != 'pull_request'}} -# run: | -# Write-Output "*** Create Standard SID ***" -# .\SL.DotNet\x64\SL.DotNet config --token ${{ secrets.SLT }} --includeNamespace ${{ env.APP_NAMESPACE }} --appName ${{ env.APP_NAME }} --branchName Release/master --buildName "Github.Nadeem.${{ github.run_number }}" - -# - name: Sealights - Prepare for MSBuild -# id: SealightsMSBuild -# if: steps.SealightsStandard.outcome == 'success' || steps.SealightsPR.outcome == 'success' -# run: | -# Write-Output "*** Prepare for MSBuild ***" -# .\SL.DotNet\x64\SL.DotNet.exe prepareForMsBuild --buildSessionIdFile buildSessionId --workspacePath .\Ginger --baseDir . --ignoreGeneratedCode true --debugMode true --logEnabled true --logAppendConsole true --ignoreCertificateErrors true --token ${{ secrets.SLT }} --scm git --scmProvider vsts - -# # ------------------------------------------------------------------------------------------------------ -# # SeaLights- Starting test stage && Starting Background test listener -# # ------------------------------------------------------------------------------------------------------ -# - name: Sealights - Starting test stage -# if: steps.SealightsMSBuild.outcome == 'success' -# run: | -# .\SL.DotNet\x64\SL.DotNet.exe startExecution --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testStage "Unit Tests" - -# - name: Sealights - Starting Background test listener -# if: steps.SealightsMSBuild.outcome == 'success' -# run: | -# .\SL.DotNet\x64\SL.DotNet.exe startBackgroundTestListener --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testListenerSessionKey ${{ github.run_number }} --testStage "Unit Tests" - -# ------------------------------------------------------------------------------------------------------ -# Install msbild && Build Ginger Solution -# ------------------------------------------------------------------------------------------------------ - - name: Add msbuild to PATH - if: ${{github.workflow == 'Ginger Windows Test'}} - uses: microsoft/setup-msbuild@v1.0.2 - - - name: Build Ginger Solution - if: ${{github.workflow == 'Ginger Windows Test'}} - run: msbuild ./Ginger/Ginger.sln /p:DebugSymbols=true /p:DebugType=full /p:Configuration=$env:BUILD_CONFIGURATION - -# ------------------------------------------------------------------------------------------------------ -# Start Testing -# ------------------------------------------------------------------------------------------------------ - - name: 'Testing GingerUtilsTest' - if: success() || failure() - run: dotnet test Ginger/GingerUtilsTest --configuration ${{ env.BUILD_CONFIGURATION }} --logger trx --results-directory D:\a\TestResults --verbosity=normal - - - name: 'Testing GingerCoreCommonTest' - if: success() || failure() - run: dotnet test Ginger/GingerCoreCommonTest --configuration ${{ env.BUILD_CONFIGURATION }} --logger trx --results-directory D:\a\TestResults --verbosity=normal - - - name: 'Testing GingerCoreNETUnitTest' - if: success() || failure() - run: dotnet test Ginger/GingerCoreNETUnitTest --configuration ${{ env.BUILD_CONFIGURATION }} --logger trx --results-directory D:\a\TestResults --verbosity=normal - - - name: 'Testing GingerPluginCoreTest' - if: success() || failure() - run: dotnet test Ginger/GingerPluginCoreTest --configuration ${{ env.BUILD_CONFIGURATION }} --logger trx --results-directory D:\a\TestResults --verbosity=normal - - - name: 'Testing GingerConsoleTest' - if: success() || failure() - run: dotnet test Ginger/GingerConsoleTest --configuration ${{ env.BUILD_CONFIGURATION }} --logger trx --results-directory D:\a\TestResults --verbosity=normal - - - name: 'Testing GingerAutoPilotTest' - if: success() || failure() - run: dotnet test Ginger/GingerAutoPilotTest --configuration ${{ env.BUILD_CONFIGURATION }} --logger trx --results-directory D:\a\TestResults --verbosity=normal - -# ------------------------------------------------------------------------------------------------------ -# Run .Net Framework tests using powershell and publish the results -# ------------------------------------------------------------------------------------------------------ - - name: Run tests for Ginger .NetFramework *Test Dlls - if: success() || failure() # run this step even if previous step failed - run: powershell -file "TestDotNetFrameworkGithub.ps1" - -# ------------------------------------------------------------------------------------------------------ -# Publish Test Results -# ------------------------------------------------------------------------------------------------------ - - name: Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() # run this step even if previous step failed - with: - name: Ginger Windows UnitTests # Name of the check run which will be created - path: "D:/a/TestResults/*.trx" # Path to test results - reporter: dotnet-trx # Format of test results - - -# ------------------------------------------------------------------------------------------------------ -# Sealight - Stop Background test listener && Ending a test stage && Upload report files -# ------------------------------------------------------------------------------------------------------ - # - name: Sealights - Stop Background test listener - # if: (success() || failure()) && steps.SealightsMSBuild.outcome == 'success' # run this step even if previous step failed - # run: | - # .\SL.DotNet\x64\SL.DotNet.exe stopBackgroundTestListener --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testListenerSessionKey ${{ github.run_number }} - # - name: Sealights - Ending test stage - # if: (success() || failure()) && steps.SealightsMSBuild.outcome == 'success' # run this step even if previous step failed - # run: | - # .\SL.DotNet\x64\SL.DotNet.exe endExecution --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testStage "Unit Tests" - - # - name: Sealights - Upload test report - # if: (success() || failure()) && steps.SealightsMSBuild.outcome == 'success' # run this step even if previous step failed - # run: | - # .\SL.DotNet\x64\SL.DotNet.exe uploadTestReport --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testStage "Unit Tests" --report "D:\\a\\TestResults" - diff --git a/.github/workflows/WindowsTest.yml b/.github/workflows/WindowsTest.yml index 8f61173c17..eb4be322c1 100644 --- a/.github/workflows/WindowsTest.yml +++ b/.github/workflows/WindowsTest.yml @@ -28,11 +28,15 @@ jobs: uses: actions/checkout@v3 - - name: Download Artifacts + - name: Restore static site content if: ${{github.workflow != 'Ginger Windows Test'}} - uses: actions/download-artifact@v3 + uses: actions/cache@v3.2.6 with: - name: ginger-artifact + path: ./** + key: cache-site-${{ github.run_number }} + enableCrossOsArchive: + true + # ------------------------------------------------------------------------------------------------------ # Install .Net core SDK 8.0.100 @@ -58,52 +62,52 @@ jobs: # SeaLight - Downloading the .NET agent files && Scanning a build using MSBuild # --------------------------------------------------------------------------------------------------- - - name: Download Sealights .Net agent - run: | - Write-Output "Build Reason = ${{github.event_name}}" - echo $env:SLDOMAIN - echo $env:BUILD_CONFIGURATION - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Write-Output "Download the Sealights DotNet agent version set in settings..." - $agentversion = ((iwr -Uri https://amdocs.sealights.co/api/v2/agents/dotnet/recommended -Headers @{'Accept' = 'application/json'; 'Authorization' = "Bearer ${{ secrets.SLT }}"}).Content | ConvertFrom-Json | Select-Object agent).agent.version - Write-Output "*** start download ***" - iwr -OutFile sealights-dotnet-agent.zip -Uri http://agents.sealights.co/SL.DotNet/SL.DotNet-$($agentversion).zip - Expand-Archive .\sealights-dotnet-agent.zip -DestinationPath SL.DotNet -Force - Write-Output "Sealights agent version used is:$(Get-Content .\SL.DotNet\version.txt)" +# - name: Download Sealights .Net agent +# run: | +# Write-Output "Build Reason = ${{github.event_name}}" +# echo $env:SLDOMAIN +# echo $env:BUILD_CONFIGURATION +# [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +# Write-Output "Download the Sealights DotNet agent version set in settings..." +# $agentversion = ((iwr -Uri https://amdocs.sealights.co/api/v2/agents/dotnet/recommended -Headers @{'Accept' = 'application/json'; 'Authorization' = "Bearer ${{ secrets.SLT }}"}).Content | ConvertFrom-Json | Select-Object agent).agent.version +# Write-Output "*** start download ***" +# iwr -OutFile sealights-dotnet-agent.zip -Uri http://agents.sealights.co/SL.DotNet/SL.DotNet-$($agentversion).zip +# Expand-Archive .\sealights-dotnet-agent.zip -DestinationPath SL.DotNet -Force +# Write-Output "Sealights agent version used is:$(Get-Content .\SL.DotNet\version.txt)" - - name: Sealights - Generating a Pull Request Session ID - id: SealightsPR - if: ${{github.event_name == 'pull_request'}} - run: | - Write-Output "*** Create PR BSID ***" - .\SL.DotNet\x64\SL.DotNet prConfig --token ${{ secrets.SLT }} --appName ${{ env.APP_NAME }} --includeNamespace ${{ env.APP_NAMESPACE }} --pullRequestNumber 25 --latestCommit a51d0f337dc7547d20dbf5fbfea1c45831249325 --targetBranch Release/master --repositoryUrl ${{ env.REPO_URL }} +# - name: Sealights - Generating a Pull Request Session ID +# id: SealightsPR +# if: ${{github.event_name == 'pull_request'}} +# run: | +# Write-Output "*** Create PR BSID ***" +# .\SL.DotNet\x64\SL.DotNet prConfig --token ${{ secrets.SLT }} --appName ${{ env.APP_NAME }} --includeNamespace ${{ env.APP_NAMESPACE }} --pullRequestNumber 25 --latestCommit a51d0f337dc7547d20dbf5fbfea1c45831249325 --targetBranch Release/master --repositoryUrl ${{ env.REPO_URL }} - - name: Sealights - Generating a Standard Session ID - id: SealightsStandard - if: ${{github.event_name != 'pull_request'}} - run: | - Write-Output "*** Create Standard SID ***" - .\SL.DotNet\x64\SL.DotNet config --token ${{ secrets.SLT }} --includeNamespace ${{ env.APP_NAMESPACE }} --appName ${{ env.APP_NAME }} --branchName Release/master --buildName "Github.Nadeem.${{ github.run_number }}" +# - name: Sealights - Generating a Standard Session ID +# id: SealightsStandard +# if: ${{github.event_name != 'pull_request'}} +# run: | +# Write-Output "*** Create Standard SID ***" +# .\SL.DotNet\x64\SL.DotNet config --token ${{ secrets.SLT }} --includeNamespace ${{ env.APP_NAMESPACE }} --appName ${{ env.APP_NAME }} --branchName Release/master --buildName "Github.Nadeem.${{ github.run_number }}" - - name: Sealights - Prepare for MSBuild - id: SealightsMSBuild - if: steps.SealightsStandard.outcome == 'success' || steps.SealightsPR.outcome == 'success' - run: | - Write-Output "*** Prepare for MSBuild ***" - .\SL.DotNet\x64\SL.DotNet.exe prepareForMsBuild --buildSessionIdFile buildSessionId --workspacePath .\Ginger --baseDir . --ignoreGeneratedCode true --debugMode true --logEnabled true --logAppendConsole true --ignoreCertificateErrors true --token ${{ secrets.SLT }} --scm git --scmProvider vsts +# - name: Sealights - Prepare for MSBuild +# id: SealightsMSBuild +# if: steps.SealightsStandard.outcome == 'success' || steps.SealightsPR.outcome == 'success' +# run: | +# Write-Output "*** Prepare for MSBuild ***" +# .\SL.DotNet\x64\SL.DotNet.exe prepareForMsBuild --buildSessionIdFile buildSessionId --workspacePath .\Ginger --baseDir . --ignoreGeneratedCode true --debugMode true --logEnabled true --logAppendConsole true --ignoreCertificateErrors true --token ${{ secrets.SLT }} --scm git --scmProvider vsts -# ------------------------------------------------------------------------------------------------------ -# SeaLights- Starting test stage && Starting Background test listener -# ------------------------------------------------------------------------------------------------------ - - name: Sealights - Starting test stage - if: steps.SealightsMSBuild.outcome == 'success' - run: | - .\SL.DotNet\x64\SL.DotNet.exe startExecution --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testStage "Unit Tests" +# # ------------------------------------------------------------------------------------------------------ +# # SeaLights- Starting test stage && Starting Background test listener +# # ------------------------------------------------------------------------------------------------------ +# - name: Sealights - Starting test stage +# if: steps.SealightsMSBuild.outcome == 'success' +# run: | +# .\SL.DotNet\x64\SL.DotNet.exe startExecution --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testStage "Unit Tests" - - name: Sealights - Starting Background test listener - if: steps.SealightsMSBuild.outcome == 'success' - run: | - .\SL.DotNet\x64\SL.DotNet.exe startBackgroundTestListener --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testListenerSessionKey ${{ github.run_number }} --testStage "Unit Tests" +# - name: Sealights - Starting Background test listener +# if: steps.SealightsMSBuild.outcome == 'success' +# run: | +# .\SL.DotNet\x64\SL.DotNet.exe startBackgroundTestListener --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testListenerSessionKey ${{ github.run_number }} --testStage "Unit Tests" # ------------------------------------------------------------------------------------------------------ # Install msbild && Build Ginger Solution @@ -165,17 +169,17 @@ jobs: # ------------------------------------------------------------------------------------------------------ # Sealight - Stop Background test listener && Ending a test stage && Upload report files # ------------------------------------------------------------------------------------------------------ - - name: Sealights - Stop Background test listener - if: (success() || failure()) && steps.SealightsMSBuild.outcome == 'success' # run this step even if previous step failed - run: | - .\SL.DotNet\x64\SL.DotNet.exe stopBackgroundTestListener --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testListenerSessionKey ${{ github.run_number }} - - name: Sealights - Ending test stage - if: (success() || failure()) && steps.SealightsMSBuild.outcome == 'success' # run this step even if previous step failed - run: | - .\SL.DotNet\x64\SL.DotNet.exe endExecution --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testStage "Unit Tests" + # - name: Sealights - Stop Background test listener + # if: (success() || failure()) && steps.SealightsMSBuild.outcome == 'success' # run this step even if previous step failed + # run: | + # .\SL.DotNet\x64\SL.DotNet.exe stopBackgroundTestListener --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testListenerSessionKey ${{ github.run_number }} + # - name: Sealights - Ending test stage + # if: (success() || failure()) && steps.SealightsMSBuild.outcome == 'success' # run this step even if previous step failed + # run: | + # .\SL.DotNet\x64\SL.DotNet.exe endExecution --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testStage "Unit Tests" - - name: Sealights - Upload test report - if: (success() || failure()) && steps.SealightsMSBuild.outcome == 'success' # run this step even if previous step failed - run: | - .\SL.DotNet\x64\SL.DotNet.exe uploadTestReport --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testStage "Unit Tests" --report "D:\\a\\TestResults" - \ No newline at end of file + # - name: Sealights - Upload test report + # if: (success() || failure()) && steps.SealightsMSBuild.outcome == 'success' # run this step even if previous step failed + # run: | + # .\SL.DotNet\x64\SL.DotNet.exe uploadTestReport --token ${{ secrets.SLT }} --buildSessionIdFile buildSessionId --logEnabled true --logAppendConsole true --testStage "Unit Tests" --report "D:\\a\\TestResults" + From 1abb8fc6ead405a0556d4d00361bdbf87b331e94 Mon Sep 17 00:00:00 2001 From: Nadeem Jazmawe Date: Sun, 27 Oct 2024 17:59:46 +0200 Subject: [PATCH 20/29] Refactor GitHub Actions workflow for CD --- .github/workflows/GingerTests.yml | 4 +- .github/workflows/LinuxBuild.yml | 92 ----------------------- .github/workflows/LinuxTest-2.yml | 95 ----------------------- .github/workflows/LinuxTest.yml | 13 ++-- .github/workflows/MacBuild.yml | 65 ---------------- .github/workflows/MacOSTest-2.yml | 71 ----------------- .github/workflows/MacOSTest.yml | 13 ++-- .github/workflows/WindowsBuild.yml | 117 ----------------------------- 8 files changed, 18 insertions(+), 452 deletions(-) delete mode 100644 .github/workflows/LinuxBuild.yml delete mode 100644 .github/workflows/LinuxTest-2.yml delete mode 100644 .github/workflows/MacBuild.yml delete mode 100644 .github/workflows/MacOSTest-2.yml delete mode 100644 .github/workflows/WindowsBuild.yml diff --git a/.github/workflows/GingerTests.yml b/.github/workflows/GingerTests.yml index 33c33cbf96..241a6ea9b2 100644 --- a/.github/workflows/GingerTests.yml +++ b/.github/workflows/GingerTests.yml @@ -8,6 +8,6 @@ jobs: uses: ./.github/workflows/WindowsTest.yml secrets: inherit Linux: - uses: ./.github/workflows/LinuxTest-2.yml + uses: ./.github/workflows/LinuxTest.yml MacOS: - uses: ./.github/workflows/MacOSTest-2.yml + uses: ./.github/workflows/MacOSTest.yml diff --git a/.github/workflows/LinuxBuild.yml b/.github/workflows/LinuxBuild.yml deleted file mode 100644 index 0f0e041162..0000000000 --- a/.github/workflows/LinuxBuild.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Ginger Linux Build - -on: - # pull_request: - # branches: - # - master - # - Features/Linux-Migration - # - Releases/* - # - Releases/*/* - - workflow_dispatch: - - -jobs: - build: - - runs-on: ubuntu-latest - - env: - BUILD_CONFIGURATION: Release - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-dotnet@v3 - with: - dotnet-version: '8.0.100' - - - - - name: 'printing file - GingerConsole.dll' - if: success() || failure() # run this step even if previous step failed - run: | - ls -alt Ginger/GingerUtilsTest -# ------------------------------------------------------------------------------------------------------ -# start Testing -# ------------------------------------------------------------------------------------------------------ - - name: Testing GingerUtilsTest - run: dotnet test Ginger/GingerUtilsTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'printing file - GingerConsole.dll' - if: success() || failure() # run this step even if previous step failed - run: | - ls -alt Ginger/GingerUtilsTest - - - name: 'Testing GingerCoreCommonTest' - run: dotnet test Ginger/GingerCoreCommonTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - # for GingerCoreNET we use run setting to limit to have one worker thread due to workspace limitation - - name: 'Testing GingerCoreNETUnitTest' - run: dotnet test Ginger/GingerCoreNETUnitTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerPluginCoreTest' - run: dotnet test Ginger/GingerPluginCoreTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerConsoleTest' - run: dotnet test Ginger/GingerConsoleTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerAutoPilotTest' - run: dotnet test Ginger/GingerAutoPilotTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - -# ------------------------------------------------------------------------------------------------------ -# Publish GingerRuntime -# ------------------------------------------------------------------------------------------------------ - - name: 'Publish GingerRuntime' - run: dotnet publish Ginger/GingerRuntime -c Release - - - -# ------------------------------------------------------------------------------------------------------ -# Publish Test Results -# ------------------------------------------------------------------------------------------------------ - - name: Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() # run this step even if previous step failed - with: - name: Ginger Linux UnitTests # Name of the check run which will be created - path: "**/*.trx" # Path to test results - reporter: dotnet-trx # Format of test results - - - -# ------------------------------------------------------------------------------------------------------ -# Run Standalone CLI Test -# ------------------------------------------------------------------------------------------------------ - - name: Run Standalone CLI Test - if: success() || failure() # run this step even if previous step failed - run: | - chmod +x CLITestsGithub.ps1 - ./CLITestsGithub.ps1 diff --git a/.github/workflows/LinuxTest-2.yml b/.github/workflows/LinuxTest-2.yml deleted file mode 100644 index dd7baf1ac6..0000000000 --- a/.github/workflows/LinuxTest-2.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Ginger Linux Test - -on: - workflow_dispatch: - workflow_call: - -jobs: - build: - name: Linux Test - runs-on: ubuntu-latest - - env: - BUILD_CONFIGURATION: Release - - steps: - -# ------------------------------------------------------------------------------------------------------ -# Copy Ginger repo -# ------------------------------------------------------------------------------------------------------ - - name: Code Checkout - if: ${{github.workflow == 'Ginger Linux Test'}} - uses: actions/checkout@v3 - - - - name: Restore static site content - if: ${{github.workflow != 'Ginger Linux Test'}} - uses: actions/cache@v3.2.6 - with: - path: ./** - key: cache-site-${{ github.run_number }} - enableCrossOsArchive: - true - -# ------------------------------------------------------------------------------------------------------ -# Install .Net core SDK 8.0.100 -# ------------------------------------------------------------------------------------------------------ - - uses: actions/setup-dotnet@v3 - with: - dotnet-version: '8.0.100' - -# ------------------------------------------------------------------------------------------------------ -# start Testing -# ------------------------------------------------------------------------------------------------------ - - name: 'Testing GingerUtilsTest' - run: dotnet test Ginger/GingerUtilsTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerCoreCommonTest' - run: dotnet test Ginger/GingerCoreCommonTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - # for GingerCoreNET we use run setting to limit to have one worker thread due to workspace limitation - - name: 'Testing GingerCoreNETUnitTest' - run: dotnet test Ginger/GingerCoreNETUnitTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerPluginCoreTest' - run: dotnet test Ginger/GingerPluginCoreTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerConsoleTest' - run: dotnet test Ginger/GingerConsoleTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerAutoPilotTest' - run: dotnet test Ginger/GingerAutoPilotTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - -# ------------------------------------------------------------------------------------------------------ -# Publish GingerRuntime -# ------------------------------------------------------------------------------------------------------ - - name: 'Publish GingerRuntime' - if: ${{github.event_name == 'Ginger Linux Test' }} - run: dotnet publish Ginger/GingerRuntime -c Release - -# ------------------------------------------------------------------------------------------------------ -# Publish Test Results -# ------------------------------------------------------------------------------------------------------ - - name: Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() # run this step even if previous step failed - with: - name: Ginger Linux UnitTests # Name of the check run which will be created - path: "**/*.trx" # Path to test results - reporter: dotnet-trx # Format of test results - -# ------------------------------------------------------------------------------------------------------ -# Run Standalone CLI Test -# ------------------------------------------------------------------------------------------------------ - - name: Run Standalone CLI Test - if: success() || failure() # run this step even if previous step failed - shell: bash - run: | - pwd - ls -alt - chmod +x CLITestsGithub.sh - sudo apt install dos2unix - dos2unix -b CLITestsGithub.sh - ./CLITestsGithub.sh - - diff --git a/.github/workflows/LinuxTest.yml b/.github/workflows/LinuxTest.yml index 9e97912e11..dd7baf1ac6 100644 --- a/.github/workflows/LinuxTest.yml +++ b/.github/workflows/LinuxTest.yml @@ -22,18 +22,21 @@ jobs: uses: actions/checkout@v3 - - name: Download Airtifacts + - name: Restore static site content if: ${{github.workflow != 'Ginger Linux Test'}} - uses: actions/download-artifact@v3 + uses: actions/cache@v3.2.6 with: - name: ginger-artifact + path: ./** + key: cache-site-${{ github.run_number }} + enableCrossOsArchive: + true # ------------------------------------------------------------------------------------------------------ -# Install .Net core SDK 6.0.301 +# Install .Net core SDK 8.0.100 # ------------------------------------------------------------------------------------------------------ - uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.x.x' + dotnet-version: '8.0.100' # ------------------------------------------------------------------------------------------------------ # start Testing diff --git a/.github/workflows/MacBuild.yml b/.github/workflows/MacBuild.yml deleted file mode 100644 index 2fd09e921e..0000000000 --- a/.github/workflows/MacBuild.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Ginger Mac Build - -on: - # pull_request: - # branches: - # - master - # - Features/Linux-Migration - # - Releases/* - # - Releases/*/* - - workflow_dispatch: - - -jobs: - build: - - runs-on: macOS-latest - - env: - BUILD_CONFIGURATION: Release - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-dotnet@v3 - with: - dotnet-version: '8.0.100' - - - -# ------------------------------------------------------------------------------------------------------ -# start Testing -# ------------------------------------------------------------------------------------------------------ - - name: Testing GingerUtilsTest - run: dotnet test Ginger/GingerUtilsTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerCoreCommonTest' - run: dotnet test Ginger/GingerCoreCommonTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerCoreNETUnitTest' - run: dotnet test Ginger/GingerCoreNETUnitTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerPluginCoreTest' - run: dotnet test Ginger/GingerPluginCoreTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerConsoleTest' - run: dotnet test Ginger/GingerConsoleTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerAutoPilotTest' - run: dotnet test Ginger/GingerAutoPilotTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - -# ------------------------------------------------------------------------------------------------------ -# Publish Test Results -# ------------------------------------------------------------------------------------------------------ - - - - name: Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() # run this step even if previous step failed - with: - name: Ginger MacOS UnitTests # Name of the check run which will be created - path: "**/*.trx" # Path to test results - reporter: dotnet-trx # Format of test results diff --git a/.github/workflows/MacOSTest-2.yml b/.github/workflows/MacOSTest-2.yml deleted file mode 100644 index 9cde25f597..0000000000 --- a/.github/workflows/MacOSTest-2.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Ginger MacOS Test - -on: - workflow_call: - workflow_dispatch: - - -jobs: - build: - name: MacOS Test - runs-on: macOS-latest - - env: - BUILD_CONFIGURATION: Release - - steps: - -# ------------------------------------------------------------------------------------------------------ -# Copy Ginger repo -# ------------------------------------------------------------------------------------------------------ - - name: Code Checkout - if: ${{github.workflow == 'Ginger MacOS Test'}} - uses: actions/checkout@v3 - - - name: Restore static site content - if: ${{github.workflow != 'Ginger MacOS Test'}} - uses: actions/cache@v3.2.6 - with: - path: ./** - key: cache-site-${{ github.run_number }} - enableCrossOsArchive: - truet - -# ------------------------------------------------------------------------------------------------------ -# Install .Net core SDK 8.0.100 -# ------------------------------------------------------------------------------------------------------ - - uses: actions/setup-dotnet@v3 - with: - dotnet-version: '8.0.100' - -# ------------------------------------------------------------------------------------------------------ -# start Testing -# ------------------------------------------------------------------------------------------------------ - - name: 'Testing GingerUtilsTest' - run: dotnet test Ginger/GingerUtilsTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerCoreCommonTest' - run: dotnet test Ginger/GingerCoreCommonTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerCoreNETUnitTest' - run: dotnet test Ginger/GingerCoreNETUnitTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerPluginCoreTest' - run: dotnet test Ginger/GingerPluginCoreTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerConsoleTest' - run: dotnet test Ginger/GingerConsoleTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - - - name: 'Testing GingerAutoPilotTest' - run: dotnet test Ginger/GingerAutoPilotTest --configuration ${BUILD_CONFIGURATION} --logger trx --verbosity=normal - -# ------------------------------------------------------------------------------------------------------ -# Publish Test Results -# ------------------------------------------------------------------------------------------------------ - - name: Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() # run this step even if previous step failed - with: - name: Ginger MacOS UnitTests # Name of the check run which will be created - path: "**/*.trx" # Path to test results - reporter: dotnet-trx # Format of test results diff --git a/.github/workflows/MacOSTest.yml b/.github/workflows/MacOSTest.yml index 152e051df9..9cde25f597 100644 --- a/.github/workflows/MacOSTest.yml +++ b/.github/workflows/MacOSTest.yml @@ -22,18 +22,21 @@ jobs: if: ${{github.workflow == 'Ginger MacOS Test'}} uses: actions/checkout@v3 - - name: Download Airtifacts + - name: Restore static site content if: ${{github.workflow != 'Ginger MacOS Test'}} - uses: actions/download-artifact@v3 + uses: actions/cache@v3.2.6 with: - name: ginger-artifact + path: ./** + key: cache-site-${{ github.run_number }} + enableCrossOsArchive: + truet # ------------------------------------------------------------------------------------------------------ -# Install .Net core SDK 6.0.301 +# Install .Net core SDK 8.0.100 # ------------------------------------------------------------------------------------------------------ - uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.x.x' + dotnet-version: '8.0.100' # ------------------------------------------------------------------------------------------------------ # start Testing diff --git a/.github/workflows/WindowsBuild.yml b/.github/workflows/WindowsBuild.yml deleted file mode 100644 index db3eec294c..0000000000 --- a/.github/workflows/WindowsBuild.yml +++ /dev/null @@ -1,117 +0,0 @@ -name: Ginger Windows Build - -on: - # pull_request: - # branches: - # - master - # - Features/Linux-Migration - # - Releases/* - # - Releases/*/* - - workflow_dispatch: - -jobs: - build: - - runs-on: windows-latest - - env: - BUILD_CONFIGURATION: Release - - steps: - - uses: actions/checkout@v3 - -# ------------------------------------------------------------------------------------------------------ -# Install .Net core SDK 8.0.100 -# ------------------------------------------------------------------------------------------------------ - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 8.0.100 - -# ------------------------------------------------------------------------------------------------------ -# Install Nuget tool v1.0.5 -# ------------------------------------------------------------------------------------------------------ - - name: Setup Nuget - uses: Nuget/setup-nuget@v1.0.5 - -# ------------------------------------------------------------------------------------------------------ -# Restore Ginger solution NuGet packages -# ------------------------------------------------------------------------------------------------------ - - name: Restore nuget packages - run: nuget restore ./Ginger/Ginger.sln - - - -# ------------------------------------------------------------------------------------------------------ -# SeaLight -# --------------------------------------------------------------------------------------------------- - - - - -# ------------------------------------------------------------------------------------------------------ -# Install msbuild && Build Ginger Solution -# ------------------------------------------------------------------------------------------------------ - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 - - - - name: Build - run: msbuild ./Ginger/Ginger.sln /p:DebugSymbols=true /p:DebugType=full /p:Configuration=Release - -# ------------------------------------------------------------------------------------------------------ -# Start Testing -# ------------------------------------------------------------------------------------------------------ - - name: Testing GingerUtilsTest - run: dotnet test Ginger/GingerUtilsTest --configuration Release --logger trx --verbosity=normal - - - name: 'Testing GingerCoreCommonTest' - if: success() || failure() - run: dotnet test Ginger/GingerCoreCommonTest --configuration Release --logger trx --verbosity=normal - - - name: 'Testing GingerCoreNETUnitTest' - if: success() || failure() - run: dotnet test Ginger/GingerCoreNETUnitTest --configuration Release --logger trx --verbosity=normal - - - name: 'Testing GingerPluginCoreTest' - if: success() || failure() - run: dotnet test Ginger/GingerPluginCoreTest --configuration Release --logger trx --verbosity=normal - - - name: 'Testing GingerConsoleTest' - if: success() || failure() - run: dotnet test Ginger/GingerConsoleTest --configuration Release --logger trx --verbosity=normal - - - name: 'Testing GingerAutoPilotTest' - if: success() || failure() - run: dotnet test Ginger/GingerAutoPilotTest --configuration Release --logger trx --verbosity=normal - -# ------------------------------------------------------------------------------------------------------ -# Run .Net Framework tests using powershell and publish the results -# ------------------------------------------------------------------------------------------------------ - - - name: Run tests for Ginger .NetFramework *Test Dlls - if: success() || failure() # run this step even if previous step failed - run: powershell -file "TestDotNetFrameworkGithub.ps1" - -# ------------------------------------------------------------------------------------------------------ -# Publish Test Results -# ------------------------------------------------------------------------------------------------------ - - name: Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() # run this step even if previous step failed - with: - name: Ginger Windows UnitTests # Name of the check run which will be created - path: "**/*.trx" # Path to test results - reporter: dotnet-trx # Format of test results - - -# ------------------------------------------------------------------------------------------------------ -# Stop Sealight -# ------------------------------------------------------------------------------------------------------ -# - task: EndTestExecution@2 -# inputs: -# sealightsToken: "$(SLAGENTTOKEN)" -# SealightsBuildSessionId : $(Build.ArtifactStagingDirectory)\SealightsBuildSessionId.txt - - From e6f7f8a83a577ec481b371c8a9b716ef9034e4aa Mon Sep 17 00:00:00 2001 From: khari thomas Date: Sun, 27 Oct 2024 21:33:21 -0500 Subject: [PATCH 21/29] remove unused value; rename field for clarity --- .../ActUIElementLib/UIElementScrollToOptionsPage.xaml | 4 ++-- .../ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs | 8 +++----- .../GingerCoreCommon/Actions/UI Element/ActUIElement.cs | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml index 5939892cdb..c5f60a5bfa 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml @@ -16,8 +16,8 @@ - diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs index a18669248e..b0f1be93ea 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml.cs @@ -13,22 +13,20 @@ public enum eScrollAlignment { Start, Center, - End, - Nearest + End } public UIElementScrollToElementOptionsPage(ActUIElement action) { InitializeComponent(); - List scrollPositions = [ + List verticalAlignments = [ eScrollAlignment.Start, eScrollAlignment.Center, eScrollAlignment.End, - eScrollAlignment.Nearest, ]; - scrollAlignmentComboBox.Init(action.GetOrCreateInputParam(ActUIElement.Fields.ScrollAlignment), scrollPositions, false); + verticalScrollAlignmentComboBox.Init(action.GetOrCreateInputParam(ActUIElement.Fields.VerticalScrollAlignment), verticalAlignments, false); } } } diff --git a/Ginger/GingerCoreCommon/Actions/UI Element/ActUIElement.cs b/Ginger/GingerCoreCommon/Actions/UI Element/ActUIElement.cs index 2c236d72bf..4fe27fdc04 100644 --- a/Ginger/GingerCoreCommon/Actions/UI Element/ActUIElement.cs +++ b/Ginger/GingerCoreCommon/Actions/UI Element/ActUIElement.cs @@ -142,8 +142,8 @@ public override List Platforms public static string SubElementLocateBy = "SubElementLocateBy"; public static string SubElementLocatorValue = "SubElementLocatorValue"; - // use for ScrollToElement - public static string ScrollAlignment = "ScrollAlignment"; + //used for ScrollToElement + public static string VerticalScrollAlignment = "VerticalScrollAlignment"; } // Fields Helper for specific action, will create AIV with param name based on enum From d64e4085e47cd9861e4a93f05aaa5c1f39e73bbf Mon Sep 17 00:00:00 2001 From: khari thomas Date: Sun, 27 Oct 2024 21:34:31 -0500 Subject: [PATCH 22/29] refactor scroll alignment logic --- .../Web/Selenium/SeleniumDriver.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs index af529c6ffa..94dd4418f0 100644 --- a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs @@ -9010,9 +9010,27 @@ public void HandleActUIElement(ActUIElement act) case ActUIElement.eElementAction.ScrollToElement: try { - string scrollAlignment = act.GetInputParamCalculatedValue(ActUIElement.Fields.ScrollAlignment).ToLower(); - string command = $"arguments[0].scrollIntoView({{ block: '{scrollAlignment}' }});"; - ((IJavaScriptExecutor)Driver).ExecuteScript(command, e); + var js = (IJavaScriptExecutor)Driver; + string command = string.Empty; + string scrollAlignment = act.GetInputParamCalculatedValue(ActUIElement.Fields.VerticalScrollAlignment).ToLower(); + + switch (scrollAlignment) + { + case "center": + long elementPosition = e.Location.Y; + long viewportHeight = (long)js.ExecuteScript("return window.innerHeight"); + long scrollPosition = elementPosition - (viewportHeight / 2); + command = $"window.scrollTo(0, {scrollPosition});"; + break; + case "end": + command = "arguments[0].scrollIntoView(false);"; + break; + case "start": + default: + command = "arguments[0].scrollIntoView(true);"; + break; + } + js.ExecuteScript(command, e); } catch (Exception) { From cbccd8c8d0ccc0f096953afc1f45eac38c6ad434 Mon Sep 17 00:00:00 2001 From: khari thomas Date: Sun, 27 Oct 2024 22:09:31 -0500 Subject: [PATCH 23/29] revert changes according to code review --- .../Web/Selenium/ChromeDriverEx.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs index 48613f00a2..ff54abcab1 100644 --- a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs @@ -34,10 +34,27 @@ public static Screenshot GetFullPageScreenshot(this ChromiumDriver driver) { ["width"] = driver.ExecuteScript("return Math.max(window.innerWidth, document.body.scrollWidth, document.documentElement.scrollWidth)"), ["height"] = driver.ExecuteScript("return Math.max(window.innerHeight, document.body.scrollHeight, document.documentElement.scrollHeight)"), - ["deviceScaleFactor"] = Convert.ToDouble(driver.ExecuteScript("return window.devicePixelRatio") ?? 1), ["mobile"] = driver.ExecuteScript("return typeof window.orientation !== 'undefined'") }; + object devicePixelRatio = driver.ExecuteScript("return window.devicePixelRatio"); + if (devicePixelRatio != null) + { + double doubleValue = 0; + if (double.TryParse(devicePixelRatio.ToString(), out doubleValue)) + { + metrics["deviceScaleFactor"] = doubleValue; + } + else + { + long longValue = 0; + if (long.TryParse(devicePixelRatio.ToString(), out longValue)) + { + metrics["deviceScaleFactor"] = longValue; + } + } + } + // Execute the emulation Chrome command to change browser to a custom device that is the size of the entire page driver.ExecuteCdpCommand("Emulation.setDeviceMetricsOverride", metrics); From f35ecdc91f36613f51fe349b0ee3be0c75972cfb Mon Sep 17 00:00:00 2001 From: amanpras Date: Mon, 28 Oct 2024 13:18:56 +0530 Subject: [PATCH 24/29] cleanup and error handler activity --- .../RunSetPageLib/RunnerItemPage.xaml.cs | 68 ++++++++++++------- .../Run/GingerExecutionEngine.cs | 17 +---- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs b/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs index 3688d9ae0c..d6ff5d0e28 100644 --- a/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs +++ b/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs @@ -21,13 +21,16 @@ limitations under the License. using Amdocs.Ginger.Common.Enums; using Amdocs.Ginger.Common.Repository.BusinessFlowLib; using Amdocs.Ginger.CoreNET.Execution; +using Amdocs.Ginger.Repository; using Amdocs.Ginger.UserControls; using Ginger.MoveToGingerWPF.Run_Set_Pages; using GingerCore; using GingerCore.Actions; using GingerCore.DataSource; using System; +using System.Collections.Generic; using System.ComponentModel; +using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -161,15 +164,6 @@ public void LoadChildRunnerItems() { foreach (Activity ac in ((BusinessFlow)ItemObject).Activities) { - if (ac.GetType() == typeof(ErrorHandler)) - { - continue;//do not show Error Handler for now - } - - if (ac.GetType() == typeof(CleanUpActivity)) - { - continue;//do not show Clean Up Activity for now - } RunnerItemPage ri = new RunnerItemPage(Runnerobj: ac, runnerItemEventHandler: _runnerItemEventHandler); this.Context.BusinessFlow = (BusinessFlow)ItemObject; @@ -190,20 +184,44 @@ public void LoadChildRunnerItems() mItemChilds.Add(ri); } } - else if (ItemObject.GetType() == typeof(Activity)) - { - foreach (GingerCore.Actions.Act act in ((Activity)ItemObject).Acts) + else if (ItemObject is Activity activity) + { + IEnumerable acts = null; + //Activity activity = null; + //if (ItemObject.GetType() == typeof(Activity)) + //{ + acts = ((Activity)ItemObject).Acts.OfType(); + activity = (Activity)ItemObject; + //} + + //if (ItemObject.GetType() == typeof(CleanUpActivity)) + //{ + // acts = ((CleanUpActivity)ItemObject).Acts.OfType(); + // activity = (CleanUpActivity)ItemObject; + //} + + //if (ItemObject.GetType() == typeof(ErrorHandler)) + //{ + // acts = ((ErrorHandler)ItemObject).Acts.OfType(); + // activity = (ErrorHandler)ItemObject; + //} + + if (acts != null) { - RunnerItemPage ri = new RunnerItemPage(Runnerobj: act, runnerItemEventHandler: _runnerItemEventHandler); - this.Context.Activity = (Activity)ItemObject; - ri.Context = this.Context; - act.Context = this.Context; - ri.xItemSeparator.Visibility = Visibility.Collapsed; - ri.ItemName = act.Description; - ri.ItemGuid = act.Guid; - ri.xViewRunnerItem.Visibility = Visibility.Visible; - ri.xDetailView.ToolTip = "Expand / Collapse Action"; - mItemChilds.Add(ri); + + foreach (GingerCore.Actions.Act act in acts) + { + RunnerItemPage ri = new RunnerItemPage(Runnerobj: act, runnerItemEventHandler: _runnerItemEventHandler); + this.Context.Activity = activity; + ri.Context = this.Context; + act.Context = this.Context; + ri.xItemSeparator.Visibility = Visibility.Collapsed; + ri.ItemName = act.Description; + ri.ItemGuid = act.Guid; + ri.xViewRunnerItem.Visibility = Visibility.Visible; + ri.xDetailView.ToolTip = "Expand / Collapse Action"; + mItemChilds.Add(ri); + } } } } @@ -224,10 +242,10 @@ public RunnerItemPage(object Runnerobj = null, bool ViewMode = false, EventHandl xRunnerItemContinue.ToolTip = "Resume Run from this " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow); xViewRunnerItem.ToolTip = "View " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow); } - else if (ItemObject.GetType() == typeof(GingerCore.Activity)) + else if (ItemObject is Activity activity) //.GetType() == typeof(GingerCore.Activity) || ItemObject.GetType() == typeof(CleanUpActivity) || ItemObject.GetType() == typeof(ErrorHandler)) { GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xStatus, StatusItem.StatusProperty, ItemObject, nameof(Activity.Status), BindingMode.OneWay); - PropertyChangedEventManager.AddHandler(source: ((Activity)ItemObject), handler: RunnerItem_ActivityPropertyChanged, propertyName: allProperties); + PropertyChangedEventManager.AddHandler(source: activity, handler: RunnerItem_ActivityPropertyChanged, propertyName: allProperties); xRunnerItemContinue.ToolTip = "Resume Run from this " + GingerDicser.GetTermResValue(eTermResKey.Activity); xViewRunnerItem.ToolTip = "View " + GingerDicser.GetTermResValue(eTermResKey.Activity); xRunnerItemMenu.Visibility = Visibility.Collapsed; @@ -235,7 +253,7 @@ public RunnerItemPage(object Runnerobj = null, bool ViewMode = false, EventHandl else { GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xStatus, StatusItem.StatusProperty, ItemObject, nameof(Act.Status), BindingMode.OneWay); - PropertyChangedEventManager.AddHandler(source: ((Act)ItemObject), handler: RunnerItem_ActionPropertyChanged, propertyName: allProperties); + PropertyChangedEventManager.AddHandler(source: ((RepositoryItemBase)ItemObject), handler: RunnerItem_ActionPropertyChanged, propertyName: allProperties); xRunnerItemContinue.ToolTip = "Resume Run from this Action"; xViewRunnerItem.ToolTip = "View Action"; xRunnerItemMenu.Visibility = Visibility.Collapsed; diff --git a/Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs b/Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs index 277848b57c..5cc2a8c61c 100644 --- a/Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs +++ b/Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs @@ -4411,21 +4411,6 @@ public void RunBusinessFlow(BusinessFlow businessFlow, bool standaloneExecution while (ExecutingActivity != null) { - if (ExecutingActivity.GetType() == typeof(ErrorHandler) || ExecutingActivity.GetType() == typeof(CleanUpActivity)) - { - if (!CurrentBusinessFlow.Activities.IsLastItem()) - { - GotoNextActivity(); - ExecutingActivity = (Activity)CurrentBusinessFlow.Activities.CurrentItem; - } - else - { - ExecutingActivity = null; - } - continue; - } - else - { ExecutingActivity.Status = eRunStatus.Running; GiveUserFeedback(); SetMappedValuesToActivityVariables(ExecutingActivity, previouslyExecutedActivities.ToArray()); @@ -4497,7 +4482,7 @@ public void RunBusinessFlow(BusinessFlow businessFlow, bool standaloneExecution } } - } + } } catch (Exception ex) From 372104fcf6b43d34440d3e0a651b14c99291d095 Mon Sep 17 00:00:00 2001 From: amanpras Date: Mon, 28 Oct 2024 14:16:56 +0530 Subject: [PATCH 25/29] comments removed from code --- .../RunSetPageLib/RunnerItemPage.xaml.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs b/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs index d6ff5d0e28..9366aa457b 100644 --- a/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs +++ b/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs @@ -187,25 +187,6 @@ public void LoadChildRunnerItems() else if (ItemObject is Activity activity) { IEnumerable acts = null; - //Activity activity = null; - //if (ItemObject.GetType() == typeof(Activity)) - //{ - acts = ((Activity)ItemObject).Acts.OfType(); - activity = (Activity)ItemObject; - //} - - //if (ItemObject.GetType() == typeof(CleanUpActivity)) - //{ - // acts = ((CleanUpActivity)ItemObject).Acts.OfType(); - // activity = (CleanUpActivity)ItemObject; - //} - - //if (ItemObject.GetType() == typeof(ErrorHandler)) - //{ - // acts = ((ErrorHandler)ItemObject).Acts.OfType(); - // activity = (ErrorHandler)ItemObject; - //} - if (acts != null) { From 90f9dc9e78d8e0d41df1b5d904aadb16c49c6013 Mon Sep 17 00:00:00 2001 From: prashelke Date: Mon, 28 Oct 2024 15:43:21 +0530 Subject: [PATCH 26/29] Shared repository Variable duplicate fix, Re run Failed fix and Edge browser profile and selenium arguments fix --- .../Repository/BusinessFlowLib/Activity.cs | 5 +---- .../Web/Selenium/SeleniumDriver.cs | 9 +++++++- .../Repository/SharedRepositoryOperations.cs | 21 +------------------ .../GingerCoreNET/RunLib/CLILib/CLIHelper.cs | 10 ++++----- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs b/Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs index c729b0a013..61274b7108 100644 --- a/Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs +++ b/Ginger/GingerCoreCommon/Repository/BusinessFlowLib/Activity.cs @@ -929,10 +929,7 @@ public static Activity CopySharedRepositoryActivity(Activity srActivity, bool or action.ParentGuid = action.Guid; oldNewActionGuidList.Add(new(action.ParentGuid, action.Guid)); } - foreach (VariableBase variable in copy.Variables) - { - variable.ParentGuid = variable.Guid; - } + foreach (FlowControl fc in copy.Acts.SelectMany(a => a.FlowControls)) { Guid targetGuid = fc.GetGuidFromValue(); diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs index 927140ad99..ddabbd3718 100644 --- a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/SeleniumDriver.cs @@ -803,12 +803,19 @@ public override void StartDriver() SetUnhandledPromptBehavior(EDOpts); if (IsUserProfileFolderPathValid()) { - EDOpts.AddAdditionalEdgeOption("user-data-dir=", UserProfileFolderPath); + EDOpts.AddArgument($"--user-data-dir={UserProfileFolderPath}"); } else { SetProxy(EDOpts); } + if (SeleniumUserArgs != null) + { + foreach (string arg in SeleniumUserArgs) + { + EDOpts.AddArgument(arg); + } + } SetCurrentPageLoadStrategy(EDOpts); driverService = EdgeDriverService.CreateDefaultService();//CreateDefaultServiceFromOptions(EDOpts); AddCustomDriverPath(driverService); diff --git a/Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs b/Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs index b83ed40d14..9c14417927 100644 --- a/Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs +++ b/Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs @@ -104,14 +104,7 @@ public Boolean UploadItemToRepository(Context context, UploadItemSelection itemT } srAction.ParentGuid = Guid.Empty; } - foreach (VariableBase srVariable in srActivity.Variables) - { - if (srVariable.ParentGuid != Guid.Empty) - { - srVariable.Guid = srVariable.ParentGuid; - } - srVariable.ParentGuid = Guid.Empty; - } + foreach (Act action in srActivity.Acts.Cast()) { foreach (FlowControl fc in action.FlowControls) @@ -135,10 +128,6 @@ public Boolean UploadItemToRepository(Context context, UploadItemSelection itemT { bfAction.ParentGuid = bfAction.Guid; } - foreach (VariableBase bfVariable in bfActivity.Variables) - { - bfVariable.ParentGuid = bfVariable.Guid; - } } } @@ -629,14 +618,6 @@ public static async Task SaveLinkedActivity(Activity LinkedActivity, string Excl } action.ParentGuid = Guid.Empty; } - foreach (VariableBase variable in sharedActivity.Variables) - { - if (variable.ParentGuid != Guid.Empty) - { - variable.Guid = variable.ParentGuid; - } - variable.ParentGuid = Guid.Empty; - } foreach (FlowControl fc in sharedActivity.Acts.SelectMany(a => a.FlowControls)) { Guid targetGuid = fc.GetGuidFromValue(); diff --git a/Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs b/Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs index 22fc3d47cb..0c1ab24fa2 100644 --- a/Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs +++ b/Ginger/GingerCoreNET/RunLib/CLILib/CLIHelper.cs @@ -351,7 +351,7 @@ private bool CheckforReRunConfig() List accountReportRunset = accountReportApiHandler.GetRunsetExecutionDataFromCentralDB((Guid)mRunSetConfig.ReRunConfigurations.ReferenceExecutionID); if (accountReportRunset != null && accountReportRunset.Count > 0) { - if (accountReportRunset.Any(x => !x.Status.Equals(eRunStatus.Failed.ToString(), StringComparison.CurrentCultureIgnoreCase))) + if (accountReportRunset.Any(x => !x.Status.Equals(AccountReport.Contracts.Enum.eExecutionStatus.Failed.ToString(), StringComparison.CurrentCultureIgnoreCase))) { Reporter.ToLog(eLogLevel.INFO, string.Format("The Runset is already Passed or In_progress for provided reference execution id: {0}", mRunSetConfig.ReRunConfigurations.ReferenceExecutionID)); Result = false; @@ -368,9 +368,9 @@ private bool CheckforReRunConfig() List accountReportRunnerList = accountReportApiHandler.GetRunnerExecutionDataFromCentralDB((Guid)mRunSetConfig.ReRunConfigurations.ReferenceExecutionID); if (accountReportRunnerList != null) { - if (accountReportRunnerList.Any(x => x.RunStatus.Equals(eRunStatus.Failed))) + if (accountReportRunnerList.Any(x => x.RunStatus.Equals(AccountReport.Contracts.Enum.eExecutionStatus.Failed))) { - var FailedRunnerGuidList = accountReportRunnerList.Where(x => x.RunStatus.Equals(eRunStatus.Failed)).Select(x => x.EntityId); + var FailedRunnerGuidList = accountReportRunnerList.Where(x => x.RunStatus.Equals(AccountReport.Contracts.Enum.eExecutionStatus.Failed)).Select(x => x.EntityId); foreach (GingerRunner runner in mRunsetExecutor.RunSetConfig.GingerRunners) { if (!FailedRunnerGuidList.Contains(runner.Guid)) @@ -396,10 +396,10 @@ private bool CheckforReRunConfig() List accountReportBusinessFlows = accountReportApiHandler.GetBusinessflowExecutionDataFromCentralDB((Guid)mRunSetConfig.ReRunConfigurations.ReferenceExecutionID); if (accountReportBusinessFlows != null && accountReportBusinessFlows.Count > 0) { - if (accountReportBusinessFlows.Any(x => x.RunStatus.Equals(eRunStatus.Failed))) + if (accountReportBusinessFlows.Any(x => x.RunStatus.Equals(AccountReport.Contracts.Enum.eExecutionStatus.Failed))) { - var FailedBFGuidList = accountReportBusinessFlows.Where(x => x.RunStatus.Equals(eRunStatus.Failed)).Select(x => x.InstanceGUID); + var FailedBFGuidList = accountReportBusinessFlows.Where(x => x.RunStatus.Equals(AccountReport.Contracts.Enum.eExecutionStatus.Failed)).Select(x => x.InstanceGUID); foreach (GingerRunner runner in mRunsetExecutor.RunSetConfig.GingerRunners) { foreach (BusinessFlowRun business in runner.BusinessFlowsRunList) From a5d6662f5fe420f808a20de370d5a51f1f645892 Mon Sep 17 00:00:00 2001 From: AMAN PRASAD <44187990+AmanPrasad43@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:47:08 +0530 Subject: [PATCH 27/29] Update RunnerItemPage.xaml.cs --- Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs b/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs index 9366aa457b..fa747495ad 100644 --- a/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs +++ b/Ginger/Ginger/RunSetPageLib/RunnerItemPage.xaml.cs @@ -223,7 +223,7 @@ public RunnerItemPage(object Runnerobj = null, bool ViewMode = false, EventHandl xRunnerItemContinue.ToolTip = "Resume Run from this " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow); xViewRunnerItem.ToolTip = "View " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow); } - else if (ItemObject is Activity activity) //.GetType() == typeof(GingerCore.Activity) || ItemObject.GetType() == typeof(CleanUpActivity) || ItemObject.GetType() == typeof(ErrorHandler)) + else if (ItemObject is Activity activity) { GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xStatus, StatusItem.StatusProperty, ItemObject, nameof(Activity.Status), BindingMode.OneWay); PropertyChangedEventManager.AddHandler(source: activity, handler: RunnerItem_ActivityPropertyChanged, propertyName: allProperties); @@ -234,7 +234,7 @@ public RunnerItemPage(object Runnerobj = null, bool ViewMode = false, EventHandl else { GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xStatus, StatusItem.StatusProperty, ItemObject, nameof(Act.Status), BindingMode.OneWay); - PropertyChangedEventManager.AddHandler(source: ((RepositoryItemBase)ItemObject), handler: RunnerItem_ActionPropertyChanged, propertyName: allProperties); + PropertyChangedEventManager.AddHandler(source: ((Act)ItemObject), handler: RunnerItem_ActionPropertyChanged, propertyName: allProperties); xRunnerItemContinue.ToolTip = "Resume Run from this Action"; xViewRunnerItem.ToolTip = "View Action"; xRunnerItemMenu.Visibility = Visibility.Collapsed; @@ -530,4 +530,4 @@ public RunnerItemEventArgs(eEventType EventType, RunnerItemPage runnerItemPage, this.RunnerItemObject = runnerItemObject; } } -} \ No newline at end of file +} From daacd0248f79185513ddee61925394a4abb7b12b Mon Sep 17 00:00:00 2001 From: Mahesh Kale Date: Mon, 28 Oct 2024 16:33:10 +0530 Subject: [PATCH 28/29] added required try catch --- .../Web/Selenium/ChromeDriverEx.cs | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs index ff54abcab1..b9ed1582eb 100644 --- a/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs +++ b/Ginger/GingerCoreNET/Drivers/CoreDrivers/Web/Selenium/ChromeDriverEx.cs @@ -26,8 +26,18 @@ public static class ChromeDriverEx { public static Screenshot GetFullPageScreenshot(this ChromiumDriver driver) { - // Capture the original scroll position - Dictionary originalScrollPosition = (Dictionary)driver.ExecuteScript("return { x: window.pageXOffset, y: window.pageYOffset };"); + // Capture the original scroll position + Dictionary originalScrollPosition; + try + { + originalScrollPosition = (Dictionary)driver.ExecuteScript("return { x: window.pageXOffset, y: window.pageYOffset };") + ?? new Dictionary { ["x"] = 0, ["y"] = 0 }; + } + catch + { + // Fallback to default values if script execution fails + originalScrollPosition = new Dictionary { ["x"] = 0, ["y"] = 0 }; + } // Capture page dimensions and device metrics Dictionary metrics = new Dictionary @@ -40,15 +50,13 @@ public static Screenshot GetFullPageScreenshot(this ChromiumDriver driver) object devicePixelRatio = driver.ExecuteScript("return window.devicePixelRatio"); if (devicePixelRatio != null) { - double doubleValue = 0; - if (double.TryParse(devicePixelRatio.ToString(), out doubleValue)) + if (double.TryParse(devicePixelRatio.ToString(), out var doubleValue)) { metrics["deviceScaleFactor"] = doubleValue; } else { - long longValue = 0; - if (long.TryParse(devicePixelRatio.ToString(), out longValue)) + if (long.TryParse(devicePixelRatio.ToString(), out var longValue)) { metrics["deviceScaleFactor"] = longValue; } @@ -56,14 +64,25 @@ public static Screenshot GetFullPageScreenshot(this ChromiumDriver driver) } // Execute the emulation Chrome command to change browser to a custom device that is the size of the entire page - driver.ExecuteCdpCommand("Emulation.setDeviceMetricsOverride", metrics); - - // Take screenshot as everything is now visible - Screenshot screenshot = driver.GetScreenshot(); - - // Reset the device metrics and scroll position to original state - driver.ExecuteCdpCommand("Emulation.clearDeviceMetricsOverride", new Dictionary()); - driver.ExecuteScript($"window.scrollTo({{ top: {originalScrollPosition["y"]}, left: {originalScrollPosition["x"]}, behavior: 'instant' }});"); + Screenshot screenshot = null; + try + { + driver.ExecuteCdpCommand("Emulation.setDeviceMetricsOverride", metrics); + screenshot = driver.GetScreenshot(); + } + finally + { + try + { + // Always attempt to restore original state + driver.ExecuteCdpCommand("Emulation.clearDeviceMetricsOverride", []); + driver.ExecuteScript($"window.scrollTo({{ top: {originalScrollPosition["y"]}, left: {originalScrollPosition["x"]}, behavior: 'instant' }});"); + } + catch (WebDriverException) + { + // Log warning if restoration fails + } + } return screenshot; } From ecc6070f0eb43c60b25c163266aaa616b146b2dc Mon Sep 17 00:00:00 2001 From: Mahesh Kale Date: Mon, 28 Oct 2024 17:48:53 +0530 Subject: [PATCH 29/29] Updated styles and added nearest option --- .../UIElementScrollToOptionsPage.xaml | 6 ++-- .../UIElementScrollToOptionsPage.xaml.cs | 11 ++---- .../Web/Selenium/SeleniumDriver.cs | 35 +++++++++++++------ Ginger/GingerCoreNET/GeneralLib/General.cs | 27 ++++++++++++++ 4 files changed, 58 insertions(+), 21 deletions(-) diff --git a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml index c5f60a5bfa..269b7d6b44 100644 --- a/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml +++ b/Ginger/Ginger/Actions/ActionEditPages/ActUIElementLib/UIElementScrollToOptionsPage.xaml @@ -15,9 +15,9 @@ - -