Skip to content

Commit

Permalink
Merge pull request #16 from brenordv/feature/dotnet8-migration
Browse files Browse the repository at this point in the history
Upgrade to .net8.
  • Loading branch information
brenordv authored Feb 11, 2024
2 parents 869386f + e4ec0cb commit 80f00d5
Show file tree
Hide file tree
Showing 35 changed files with 584 additions and 417 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/master-publish-dataapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
call-reusable-workflow:
uses: ./.github/workflows/template-test-build-and-publish-to-azure.yml
with:
dotnetVersion: '6.0.x'
dotnetVersion: '8.0.x'
targetPlatform: win-x64
targetRuntime: net6.0
targetRuntime: net8.0
projectFolder: Raccoon.Ninja.AzFn.DataApi
projectFile: Raccoon.Ninja.AzFn.DataApi.csproj
releaseFilePrefix: "AzFnDataApi"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/master-publish-glucose-mon-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
deploy-using-template:
uses: ./.github/workflows/template-test-build-and-publish-to-azure.yml
with:
dotnetVersion: '6.0.x'
dotnetVersion: '8.0.x'
targetPlatform: win-x64
targetRuntime: net6.0-windows
targetRuntime: net8.0-windows
projectFolder: Raccoon.Ninja.WForm.GlucoseIcon
projectFile: Raccoon.Ninja.WForm.GlucoseIcon.csproj
releaseFilePrefix: "CGMDataDisplayApp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
deploy-using-template:
uses: ./.github/workflows/template-test-build-and-publish-to-azure.yml
with:
dotnetVersion: '6.0.x'
dotnetVersion: '8.0.x'
targetPlatform: win-x64
targetRuntime: net6.0
projectFolder: Raccoon.Ninja.AzFn.DataTransfer
projectFile: Raccoon.Ninja.AzFn.DataTransfer.csproj
releaseFilePrefix: "AzFnDataTransfer"
targetRuntime: net8.0
projectFolder: Raccoon.Ninja.AzFn.ScheduledTasks
projectFile: Raccoon.Ninja.AzFn.ScheduledTasks.csproj
releaseFilePrefix: "AzFnScheduledTasks"
publishToAzure: true
secrets:
githubToken: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/qa-auto-monthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
organization: 'raccoon-ninja'
branchName: 'master'
verbose: true
sonarExclusions: '**/*Usings.cs,Raccoon.Ninja.TestHelpers/*'
coverageExclusions: '**/*Usings.cs,Raccoon.Ninja.TestHelpers/*,**/*Program.cs,Raccoon.Ninja.WForm.GlucoseIcon/Utils/AppSettings.cs,Raccoon.Ninja.AzFn.DataApi/DataLatestHbA1cFunc.cs,Raccoon.Ninja.AzFn.ScheduledTasks/HbA1cCalcFunc.cs'

secrets:
githubToken: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qa-on-pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
organization: 'raccoon-ninja'
verbose: true
sonarExclusions: '**/*Usings.cs,Raccoon.Ninja.TestHelpers/*'
coverageExclusions: '**/*Usings.cs,Raccoon.Ninja.TestHelpers/*,**/*Program.cs,Raccoon.Ninja.WForm.GlucoseIcon/Utils/AppSettings.cs,Raccoon.Ninja.AzFn.DataApi/DataLatestHbA1cFunc.cs,Raccoon.Ninja.AzFn.DataTransfer/HbA1cCalcFunc.cs'
coverageExclusions: '**/*Usings.cs,Raccoon.Ninja.TestHelpers/*,**/*Program.cs,Raccoon.Ninja.WForm.GlucoseIcon/Utils/AppSettings.cs,Raccoon.Ninja.AzFn.DataApi/*Func.cs,Raccoon.Ninja.AzFn.ScheduledTasks/*Func.cs'

secrets:
githubToken: ${{ secrets.GITHUB_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ on:
workflow_call:
inputs:
dotnetVersion:
description: '[Required] The version of .NET to use. Example: "6.0.x"'
description: '[Required] The version of .NET to use. Example: "8.0.x"'
required: true
type: string
targetPlatform:
description: '[Required] The target platform for the build. Example: "win-x64"'
required: true
type: string
targetRuntime:
description: '[Required] The target runtime for the build. Example: "net6.0"'
description: '[Required] The target runtime for the build. Example: "net8.0"'
required: true
type: string
projectFolder:
Expand Down
45 changes: 28 additions & 17 deletions NightScout.Raccoon.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "00. Applications", "00. Applications", "{0F4894B1-AE2F-4119-94D4-82B7B33A7C39}"
EndProject
Expand All @@ -7,34 +7,40 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "98. Docs", "98. Docs", "{B4511EF8-6D39-4B4D-AC77-D00B2763F896}"
ProjectSection(SolutionItems) = preProject
readme.md = readme.md
.github\workflows\master-publish-dataapi.yml = .github\workflows\master-publish-dataapi.yml
.github\workflows\master-publish-datatransfer.yml = .github\workflows\master-publish-datatransfer.yml
.github\workflows\master-publish-glucose-mon-app.yml = .github\workflows\master-publish-glucose-mon-app.yml
.github\workflows\template-test-build-and-publish-to-azure.yml = .github\workflows\template-test-build-and-publish-to-azure.yml
.github\workflows\template-qa-sonarcloud.yml = .github\workflows\template-qa-sonarcloud.yml
.github\workflows\qa-auto-monthly.yml = .github\workflows\qa-auto-monthly.yml
.github\workflows\qa-on-pull-requests.yml = .github\workflows\qa-on-pull-requests.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "01. Domain", "01. Domain", "{11F72AFB-B94A-4E9A-8817-F1FB60E9DF6D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.Domain.Core", "Raccoon.Ninja.Domain.Core\Raccoon.Ninja.Domain.Core.csproj", "{2B19A689-B703-450C-9E06-DFD0BE969053}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raccoon.Ninja.Domain.Core", "Raccoon.Ninja.Domain.Core\Raccoon.Ninja.Domain.Core.csproj", "{2B19A689-B703-450C-9E06-DFD0BE969053}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raccoon.Ninja.Domain.Core.Tests", "Raccoon.Ninja.Domain.Core.Tests\Raccoon.Ninja.Domain.Core.Tests.csproj", "{09718350-0A4E-4D05-A1D6-80A1CC5275A5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raccoon.Ninja.TestHelpers", "Raccoon.Ninja.TestHelpers\Raccoon.Ninja.TestHelpers.csproj", "{3B8CFC31-3D0C-4BDA-94A1-38D572B64FFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.Domain.Core.Tests", "Raccoon.Ninja.Domain.Core.Tests\Raccoon.Ninja.Domain.Core.Tests.csproj", "{09718350-0A4E-4D05-A1D6-80A1CC5275A5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raccoon.Ninja.AzFn.ScheduledTasks", "Raccoon.Ninja.AzFn.ScheduledTasks\Raccoon.Ninja.AzFn.ScheduledTasks.csproj", "{7367C858-3DAF-4FD7-B33E-31BA39B0F19E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.TestHelpers", "Raccoon.Ninja.TestHelpers\Raccoon.Ninja.TestHelpers.csproj", "{3B8CFC31-3D0C-4BDA-94A1-38D572B64FFA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raccoon.Ninja.AzFn.DataApi", "Raccoon.Ninja.AzFn.DataApi\Raccoon.Ninja.AzFn.DataApi.csproj", "{7D1BE348-53AF-4765-B0D9-9B87E685EE18}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.AzFn.DataTransfer", "Raccoon.Ninja.AzFn.DataTransfer\Raccoon.Ninja.AzFn.DataTransfer.csproj", "{7367C858-3DAF-4FD7-B33E-31BA39B0F19E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raccoon.Ninja.WForm.GlucoseIcon", "Raccoon.Ninja.WForm.GlucoseIcon\Raccoon.Ninja.WForm.GlucoseIcon.csproj", "{FDBD9D04-065E-46C4-9948-5E2BBA1998CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.AzFn.DataApi", "Raccoon.Ninja.AzFn.DataApi\Raccoon.Ninja.AzFn.DataApi.csproj", "{7D1BE348-53AF-4765-B0D9-9B87E685EE18}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raccoon.Ninja.Extensions.MongoDb", "Raccoon.Ninja.Extensions.MongoDb\Raccoon.Ninja.Extensions.MongoDb.csproj", "{734F0969-C86D-449F-80FF-DC8129C07A61}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.WForm.GlucoseIcon", "Raccoon.Ninja.WForm.GlucoseIcon\Raccoon.Ninja.WForm.GlucoseIcon.csproj", "{FDBD9D04-065E-46C4-9948-5E2BBA1998CB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raccoon.Ninja.Cli.CGMDataDisplayLauncher", "Raccoon.Ninja.Cli.CGMDataDisplayLauncher\Raccoon.Ninja.Cli.CGMDataDisplayLauncher.csproj", "{7BC539F4-D458-40C0-8277-0E6D24416E8C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.Extensions.MongoDb", "Raccoon.Ninja.Extensions.MongoDb\Raccoon.Ninja.Extensions.MongoDb.csproj", "{734F0969-C86D-449F-80FF-DC8129C07A61}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Raccoon.Ninja.Extensions.Desktop.Logging", "Raccoon.Ninja.Extensions.Desktop.Logging\Raccoon.Ninja.Extensions.Desktop.Logging.csproj", "{1CAC242F-719D-4E31-BEF8-7E3972F12482}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.Cli.CGMDataDisplayLauncher", "Raccoon.Ninja.Cli.CGMDataDisplayLauncher\Raccoon.Ninja.Cli.CGMDataDisplayLauncher.csproj", "{7BC539F4-D458-40C0-8277-0E6D24416E8C}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "97. Pipelines", "97. Pipelines", "{E55E0AE2-F43E-4647-9884-7F41EA819D5E}"
ProjectSection(SolutionItems) = preProject
.github\workflows\master-publish-dataapi.yml = .github\workflows\master-publish-dataapi.yml
.github\workflows\master-publish-scheduledtasks.yml = .github\workflows\master-publish-scheduledtasks.yml
.github\workflows\master-publish-glucose-mon-app.yml = .github\workflows\master-publish-glucose-mon-app.yml
.github\workflows\qa-auto-monthly.yml = .github\workflows\qa-auto-monthly.yml
.github\workflows\qa-on-pull-requests.yml = .github\workflows\qa-on-pull-requests.yml
.github\workflows\template-qa-sonarcloud.yml = .github\workflows\template-qa-sonarcloud.yml
.github\workflows\template-test-build-and-publish-to-azure.yml = .github\workflows\template-test-build-and-publish-to-azure.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.Extensions.Desktop.Logging", "Raccoon.Ninja.Extensions.Desktop.Logging\Raccoon.Ninja.Extensions.Desktop.Logging.csproj", "{1CAC242F-719D-4E31-BEF8-7E3972F12482}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raccoon.Ninja.AzFn.ScheduledTasks.Tests", "Raccoon.Ninja.AzFn.ScheduledTasks.Tests\Raccoon.Ninja.AzFn.ScheduledTasks.Tests.csproj", "{D4D62A6B-724A-4499-B462-A9E95E7896CD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -78,6 +84,10 @@ Global
{1CAC242F-719D-4E31-BEF8-7E3972F12482}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1CAC242F-719D-4E31-BEF8-7E3972F12482}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1CAC242F-719D-4E31-BEF8-7E3972F12482}.Release|Any CPU.Build.0 = Release|Any CPU
{D4D62A6B-724A-4499-B462-A9E95E7896CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4D62A6B-724A-4499-B462-A9E95E7896CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4D62A6B-724A-4499-B462-A9E95E7896CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4D62A6B-724A-4499-B462-A9E95E7896CD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2B19A689-B703-450C-9E06-DFD0BE969053} = {11F72AFB-B94A-4E9A-8817-F1FB60E9DF6D}
Expand All @@ -89,5 +99,6 @@ Global
{734F0969-C86D-449F-80FF-DC8129C07A61} = {11F72AFB-B94A-4E9A-8817-F1FB60E9DF6D}
{7BC539F4-D458-40C0-8277-0E6D24416E8C} = {0F4894B1-AE2F-4119-94D4-82B7B33A7C39}
{1CAC242F-719D-4E31-BEF8-7E3972F12482} = {11F72AFB-B94A-4E9A-8817-F1FB60E9DF6D}
{D4D62A6B-724A-4499-B462-A9E95E7896CD} = {BC1845AD-353C-4548-A86D-80A7EBC55C34}
EndGlobalSection
EndGlobal
39 changes: 24 additions & 15 deletions Raccoon.Ninja.AzFn.DataApi/DataApiFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,58 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using Raccoon.Ninja.AzFn.DataApi.ExtensionMethods;
using Raccoon.Ninja.AzFn.DataApi.Utils;
using Raccoon.Ninja.Domain.Core.Entities;
using Raccoon.Ninja.Domain.Core.Models;
using Microsoft.Azure.Functions.Worker;

namespace Raccoon.Ninja.AzFn.DataApi;

public static class DataApiFunc
public class DataApiFunc
{
[FunctionName("DataApiFunc")]
public static async Task<IActionResult> RunAsync(
private readonly ILogger _logger;

public DataApiFunc(ILogger<DataApiFunc> logger)
{
_logger = logger;
}

[Function("DataApiFunc")]
public async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
HttpRequest req,
[CosmosDB(databaseName: "%CosmosDatabaseName%", containerName: "%CosmosContainerName%",
HttpRequest req,
[CosmosDBInput(
databaseName: "%CosmosDatabaseName%",
containerName: "%CosmosContainerName%",
Connection = "CosmosConnectionString",
CreateIfNotExists = false,
SqlQuery = "SELECT TOP 1 * FROM c ORDER BY c.readAt DESC"
)]
IEnumerable<GlucoseReading> previousReadings,
ILogger log)
IEnumerable<GlucoseReading> previousReadings)
{
log.LogInformation("Data API call received. Request by IP: {Ip}", req.HttpContext.Connection.RemoteIpAddress);
_logger.LogInformation("Data API call received. Request by IP: {Ip}", req.HttpContext.Connection.RemoteIpAddress);

GlucoseReading latestReading = null;

try
{
if (!Validators.IsKeyValid(await req.Body.ExtractKey()))
return new UnauthorizedResult();

latestReading = previousReadings.FirstOrDefault();
GlucoseReadingResponse response = latestReading;

GlucoseReadingResponse response = latestReading;

return latestReading is null
? new NoContentResult()
: new OkObjectResult(response);
}
catch (Exception e)
{
log.LogError(e, "Error while processing request from IP: {Ip} | Latest reading : {LatestReading}",
req.HttpContext.Connection.RemoteIpAddress, latestReading);
_logger.LogError(e, "Error while processing request from IP: {Ip} | Latest reading : {LatestReading}",
req.HttpContext.Connection.RemoteIpAddress, latestReading);

return new StatusCodeResult(500);
}
}
Expand Down
45 changes: 27 additions & 18 deletions Raccoon.Ninja.AzFn.DataApi/DataLatestHbA1cFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,46 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using Raccoon.Ninja.AzFn.DataApi.ExtensionMethods;
using Raccoon.Ninja.AzFn.DataApi.Utils;
using Raccoon.Ninja.Domain.Core.Entities;
using Raccoon.Ninja.Domain.Core.Models;
using Microsoft.Azure.Functions.Worker;

namespace Raccoon.Ninja.AzFn.DataApi;

public static class DataLatestHbA1CFunc
public class DataLatestHbA1CFunc
{
[FunctionName("DataLatestHbA1cFunc")]
public static async Task<IActionResult> RunAsync(
private readonly ILogger _logger;

public DataLatestHbA1CFunc(ILogger<DataLatestHbA1CFunc> logger)
{
_logger = logger;
}

[Function("DataLatestHbA1cFunc")]
public async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
HttpRequest req,
[CosmosDB(databaseName: "%CosmosDatabaseName%", containerName: "%CosmosAggregateContainerName%",
HttpRequest req, [CosmosDBInput(
databaseName: "%CosmosDatabaseName%",
containerName: "%CosmosAggregateContainerName%",
Connection = "CosmosConnectionString",
CreateIfNotExists = false,
SqlQuery = "SELECT TOP 1 * FROM c WHERE c.docType = 1 and c.status = 1 ORDER BY c.createdAt DESC"
)]
IEnumerable<HbA1CCalculation> latestSuccessCalculations,
[CosmosDB(databaseName: "%CosmosDatabaseName%", containerName: "%CosmosAggregateContainerName%",
IEnumerable<HbA1CCalculation> latestSuccessCalculations, [CosmosDBInput(
databaseName: "%CosmosDatabaseName%",
containerName: "%CosmosAggregateContainerName%",
Connection = "CosmosConnectionString",
CreateIfNotExists = false,
SqlQuery = "SELECT TOP 1 * FROM c WHERE c.docType = 1 and c.status = 2 ORDER BY c.createdAt DESC"
)]
IEnumerable<HbA1CCalculation> latestPartialSuccessCalculations,
ILogger log)
IEnumerable<HbA1CCalculation> latestPartialSuccessCalculations)
{
log.LogInformation("Data Latest HbA1c API call received. Request by IP: {Ip}",
req.HttpContext.Connection.RemoteIpAddress);
_logger.LogInformation("Data Latest HbA1c API call received. Request by IP: {Ip}",
req.HttpContext.Connection.RemoteIpAddress);

HbA1CCalculation latestSuccessful = null;

HbA1CCalculation latestPartialSuccessful = null;

try
Expand All @@ -45,6 +52,7 @@ public static async Task<IActionResult> RunAsync(
return new UnauthorizedResult();

latestSuccessful = latestSuccessCalculations.FirstOrDefault();

latestPartialSuccessful = latestPartialSuccessCalculations.FirstOrDefault();

if (latestSuccessful is null && latestPartialSuccessful is null)
Expand All @@ -58,9 +66,10 @@ public static async Task<IActionResult> RunAsync(
}
catch (Exception e)
{
log.LogError(e,
"Error while processing request from IP: {Ip} | Latest success : {LatestSuccessReading} / Latest Partial Success: {LatestPartialSuccess}",
req.HttpContext.Connection.RemoteIpAddress, latestSuccessful, latestPartialSuccessful);
_logger.LogError(e,
"Error while processing request from IP: {Ip} | Latest success : {LatestSuccessReading} / Latest Partial Success: {LatestPartialSuccess}",
req.HttpContext.Connection.RemoteIpAddress, latestSuccessful, latestPartialSuccessful);

return new StatusCodeResult(500);
}
}
Expand Down
Loading

0 comments on commit 80f00d5

Please sign in to comment.