Skip to content

Commit

Permalink
chore: add net8.0 preview support (#537)
Browse files Browse the repository at this point in the history
* chore: add net8.0 preview support

* Update ci-build.yml

* Update run-docker-integration-tests.yml

* Update nuget-release.yml

* Update ci-build.yml

* Update ci-build.yml

* Update build.yml

* pr-fix: update with preview version in dockerfile

* pr-fix: use correct preview version in dockerfile

* Upgrade dependencies

* includePreviewVersions on running integration-tests

* pr-fix: use default info log level

* pr-fix: use net8.0 preview in gh actions

* pr-fix: use isolated timer function

* pr-fix: update w/ isolated tests

* pr-fix: update with env vars

* pr-fix: streamline w/ templates

* pr-fix: streamline w/ templates

* pr-fix: strip down timer function

* Update run-docker-integration-tests.yml

* Update run-docker-integration-tests.yml

* Update run-docker-integration-tests.yml

* Update run-docker-integration-tests.yml

* Update run-docker-integration-tests.yml

* pr-fix: register correlation accessor

* pr-fix: do not call 'create logger' in host setup

* pr-fix: update with storage

* Update Arcus.Observability.Tests.Runtimes.AzureFunction.csproj

* Update Dockerfile

---------

Co-authored-by: Frederik Gheysels <[email protected]>
  • Loading branch information
stijnmoreels and fgheysels authored Sep 15, 2023
1 parent 2ed0469 commit 4eea11a
Show file tree
Hide file tree
Showing 25 changed files with 257 additions and 155 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2

- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'
- name: Coverlet coverage test
uses: b3b00/[email protected]
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
dotnet-quality: 'preview'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
9 changes: 9 additions & 0 deletions build/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ stages:
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.PreviousVersion)'
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.Version))'
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.Version)'
includePreviewVersions: true
- template: 'build/build-solution.yml@templates'
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
versionSuffix: '$(packageVersion)'
includePreviewVersions: true
- task: CopyFiles@2
displayName: 'Copy build artifacts'
inputs:
Expand Down Expand Up @@ -86,6 +93,7 @@ stages:
- template: test/run-unit-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: true
projectName: '$(Project).Tests.Unit'

- stage: IntegrationTests
Expand All @@ -111,6 +119,7 @@ stages:
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: true
projectName: '$(Project).Tests.Integration'
category: 'Integration'

Expand Down
3 changes: 3 additions & 0 deletions build/nuget-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ stages:
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
version: $(Build.BuildNumber)
includePreviewVersions: true
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
inputs:
Expand Down Expand Up @@ -74,6 +75,7 @@ stages:
- template: test/run-unit-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: true
projectName: '$(Project).Tests.Unit'

- stage: IntegrationTests
Expand All @@ -99,6 +101,7 @@ stages:
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: true
projectName: '$(Project).Tests.Integration'
category: 'Integration'

Expand Down
5 changes: 4 additions & 1 deletion build/templates/run-docker-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ steps:
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.Version)'
includePreviewVersions: true
- task: Docker@1
displayName: 'Build Docker image from ${{ parameters.dockerProjectName }}'
inputs:
Expand All @@ -36,9 +37,11 @@ steps:
ports: '${{ parameters.httpPort }}:80'
envVars: |
APPINSIGHTS_INSTRUMENTATIONKEY=$(ApplicationInsights.InstrumentationKey)
AzureWebJobsStorage=$(Arcus.AzureFunctions.AzureWebJobsStorage)
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: true
projectName: '$(Project).Tests.Integration'
category: 'Docker'
- task: Bash@3
Expand All @@ -48,4 +51,4 @@ steps:
docker logs ${{ parameters.dockerProjectName }}
failOnStderr: true
displayName: Show ${{ parameters.dockerProjectName }} logs
condition: always()
condition: always()
6 changes: 3 additions & 3 deletions build/variables/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
DotNet.Sdk.Version: '6.0.100'
DotNet.Sdk.PreviousVersion: '3.1.201'
DotNet.Sdk.Version: '8.0.x'
DotNet.Sdk.PreviousVersion: '6.0.100'
Project: 'Arcus.Observability'
Vm.Image: 'ubuntu-latest'
Vm.Image: 'ubuntu-latest'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<Description>Provides capability to use correlation in applications</Description>
Expand All @@ -24,13 +24,13 @@
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0' and '$(TargetFramework)' != 'net8.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.8" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<Description>Provides capability to improve ASP.NET Core telemetry with Serilog in applications</Description>
Expand Down Expand Up @@ -32,11 +32,11 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0' and '$(TargetFramework)' != 'net8.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<Description>Provides capability to improve telemetry with Serilog in Azure Functions applications</Description>
Expand All @@ -24,13 +24,13 @@
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Core" Version="1.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0' and '$(TargetFramework)' != 'net8.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.8" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
using Arcus.Observability.Telemetry.Core;
using Arcus.Observability.Telemetry.Core.Logging;
using GuardNet;
#if NET6_0
#if !(NETSTANDARD2_1)
using Microsoft.Azure.Functions.Worker.Http;
#endif

// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.Logging
{
#if NET6_0
#if !(NETSTANDARD2_1)
/// <summary>
/// Telemetry extensions on the <see cref="ILogger"/> instance to write Application Insights compatible log messages.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<Description>Provides capability to improve telemetry with Serilog in applications</Description>
Expand All @@ -24,12 +24,12 @@
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0' and '$(TargetFramework)' != 'net8.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.8" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<Description>Provides capability to improve IoT telemetry with Serilog in applications</Description>
Expand All @@ -24,12 +24,12 @@
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.39.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0' and '$(TargetFramework)' != 'net8.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.26.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<Description>Provides capability to improve telemetry with Serilog in applications</Description>
Expand All @@ -24,11 +24,11 @@
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0' and '$(TargetFramework)' != 'net8.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<Description>Provides capability to reduce telemetry with Serilog filters</Description>
Expand All @@ -24,11 +24,11 @@
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'net6.0' and '$(TargetFramework)' != 'net8.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<Description>Provides capability to improve telemetry with Serilog that is sent to Azure Application Insights</Description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -13,6 +13,7 @@
<PackageReference Include="Arcus.Testing.Logging" Version="0.3.0" />
<PackageReference Include="Bogus" Version="34.0.1" />
<PackageReference Include="Microsoft.Azure.ApplicationInsights.Query" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Core" Version="1.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Polly" Version="7.2.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Net;
using System.Net.Http;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.ApplicationInsights.Query.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -26,27 +23,16 @@ public AzureFunctionsDockerTests(ITestOutputHelper outputWriter)
[Fact]
public async Task LogRequest_WithRequestsOperationName_SinksToApplicationInsights()
{
// Arrange
int httpPort = Configuration.GetValue<int>("AzureFunctions:HttpPort");
string? requestUri = $"http://localhost:{httpPort}/api/order";
TestOutput.WriteLine("GET -> {0}", requestUri);

using (HttpResponseMessage response = await HttpClient.GetAsync(requestUri))
await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
{
TestOutput.WriteLine("{0} <- {1}", response.StatusCode, requestUri);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

await RetryAssertUntilTelemetryShouldBeAvailableAsync(async client =>
EventsRequestResult[] results = await client.GetRequestsAsync();
AssertX.Any(results, result =>
{
EventsRequestResult[] results = await client.GetRequestsAsync();
AssertX.Any(results, result =>
{
Assert.Contains("order", result.Request.Url);
Assert.Equal("200", result.Request.ResultCode);
Assert.Equal(HttpMethod.Get.Method + " /api/order", result.Operation.Name);
});
Assert.Equal("200", result.Request.ResultCode);
Assert.Equal("Timer", result.Request.Source);
Assert.Equal("Triggered", result.Operation.Name);
});
}
});
}
}
}
Loading

0 comments on commit 4eea11a

Please sign in to comment.