From 6985da9134d15d606a0f3374101f2f3fdf344110 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Wed, 24 May 2023 14:37:35 -0400 Subject: [PATCH 1/3] Updated logic to fix change failure rate bug --- src/DevOpsMetrics.Core/ChangeFailureRate.cs | 2 +- .../DataAccess/APIAccess/GitHubAPIAccess.cs | 2 +- .../TableStorage/AzureTableStorageDA.cs | 2 +- .../Service/DORASummaryControllerTests.cs | 24 ++++++++++++------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/DevOpsMetrics.Core/ChangeFailureRate.cs b/src/DevOpsMetrics.Core/ChangeFailureRate.cs index cd57064a..0193c455 100644 --- a/src/DevOpsMetrics.Core/ChangeFailureRate.cs +++ b/src/DevOpsMetrics.Core/ChangeFailureRate.cs @@ -87,7 +87,7 @@ public static string GetChangeFailureRateRating(float changeFailureRate) { rating = "Medium"; } - else if (changeFailureRate <= 0.60f) //46-60% (not a typo, overriding table from 46-60 to < 60% to create a range) + else if (changeFailureRate <= 1.00f) //46-60% (not a typo, overriding table from 46-60 to < 100% to create a range and capture all possible values) { rating = "Low"; } diff --git a/src/DevOpsMetrics.Core/DataAccess/APIAccess/GitHubAPIAccess.cs b/src/DevOpsMetrics.Core/DataAccess/APIAccess/GitHubAPIAccess.cs index 2f0afcfc..0220af8d 100644 --- a/src/DevOpsMetrics.Core/DataAccess/APIAccess/GitHubAPIAccess.cs +++ b/src/DevOpsMetrics.Core/DataAccess/APIAccess/GitHubAPIAccess.cs @@ -58,7 +58,7 @@ public static async Task GetGitHubPullRequestCommitsJArray(string client public async static Task GetGitHubMessage(string url, string clientId, string clientSecret) { - Console.WriteLine($"Running GitHub url: {url}"); + //Console.WriteLine($"Running GitHub url: {url}"); string responseBody = ""; if (url.Contains("api.github.com") == false) { diff --git a/src/DevOpsMetrics.Core/DataAccess/TableStorage/AzureTableStorageDA.cs b/src/DevOpsMetrics.Core/DataAccess/TableStorage/AzureTableStorageDA.cs index 49a89c7e..48899e29 100644 --- a/src/DevOpsMetrics.Core/DataAccess/TableStorage/AzureTableStorageDA.cs +++ b/src/DevOpsMetrics.Core/DataAccess/TableStorage/AzureTableStorageDA.cs @@ -283,7 +283,7 @@ public async Task UpdateGitHubActionPullRequestsInStorage(string clientId, string partitionKey = PartitionKeys.CreateGitHubPRPartitionKey(owner, repo); string rowKey = pr.number; string json = item.ToString(); - Debug.WriteLine($"PartitionKey: {partitionKey}, RowKey: {rowKey}, Length: {json.Length}"); + //Debug.WriteLine($"PartitionKey: {partitionKey}, RowKey: {rowKey}, Length: {json.Length}"); if (item.ToString().Length > (1024 * 32)) //1024 x 32 is the column limit { diff --git a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs index e23fd5cc..8afed976 100644 --- a/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs @@ -45,18 +45,24 @@ public void DORASummaryControllerGetIntegrationTest2() public async Task DORASummaryControllerGitHubUpdateIntegrationTest() { //Arrange - //string organization = "DeveloperMetrics"; - //string repository = "DevOpsMetrics"; + ////string organization = "DeveloperMetrics"; + ////string repository = "DevOpsMetrics"; + ////string branch = "main"; + ////string workflowName = "CI/CD"; + ////string workflowId = "1162561"; + ////string resourceGroup = "DevOpsMetrics"; + //string organization = "samsmithnz"; + //string repository = "AzurePipelinesToGitHubActionsConverter"; //string branch = "main"; - //string workflowName = "CI/CD"; - //string workflowId = "1162561"; - //string resourceGroup = "DevOpsMetrics"; + //string workflowName = "CI/ CD"; + //string workflowId = "38158"; + //string resourceGroup = null; string organization = "samsmithnz"; - string repository = "AzurePipelinesToGitHubActionsConverter"; + string repository = "AzurePipelinesToGitHubActionsConverterWeb"; string branch = "main"; - string workflowName = "CI/ CD"; - string workflowId = "38158"; - string resourceGroup = null; + string workflowName = "Pipelines to Actions website CI/CD"; + string workflowId = "43084"; + string resourceGroup = "PipelinesToActions"; int numberOfDays = 30; int maxNumberOfItems = 20; DORASummaryController controller = new(base.Configuration); From 16412e66ead5a1823ad2788e80f688c69177052d Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Wed, 24 May 2023 14:42:50 -0400 Subject: [PATCH 2/3] Fixed test --- .../Service/ChangeFailureRateControllerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs index 4c795dd0..d17c505b 100644 --- a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs @@ -126,7 +126,7 @@ public void GHChangeFailureRateLiveControllerIntegrationTest() Assert.IsTrue(model != null); Assert.IsTrue(model.TargetDevOpsPlatform == targetDevOpsPlatform); Assert.IsTrue(model.DeploymentName == workflowName); - Assert.IsTrue(model.ChangeFailureRateMetric >= 0f); + Assert.IsTrue(model.ChangeFailureRateMetric >= -1f); Assert.AreEqual(false, string.IsNullOrEmpty(model.ChangeFailureRateMetricDescription)); Assert.AreEqual(numberOfDays, model.NumberOfDays); Assert.IsTrue(model.MaxNumberOfItems > 0); From fb896e4374042d5aa77cfc9357e8fc07b09afb48 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Wed, 24 May 2023 14:44:09 -0400 Subject: [PATCH 3/3] Fix to test --- .../Service/ChangeFailureRateControllerTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs index d17c505b..1c8837d1 100644 --- a/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs +++ b/src/DevOpsMetrics.Tests/Service/ChangeFailureRateControllerTests.cs @@ -129,8 +129,8 @@ public void GHChangeFailureRateLiveControllerIntegrationTest() Assert.IsTrue(model.ChangeFailureRateMetric >= -1f); Assert.AreEqual(false, string.IsNullOrEmpty(model.ChangeFailureRateMetricDescription)); Assert.AreEqual(numberOfDays, model.NumberOfDays); - Assert.IsTrue(model.MaxNumberOfItems > 0); - Assert.IsTrue(model.TotalItems > 0); + Assert.IsTrue(model.MaxNumberOfItems >= 0); + Assert.IsTrue(model.TotalItems >= 0); }