Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/Steeltoe.All.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
SOLUTION_FILE: 'src/Steeltoe.All.sln'
TEST_OUTPUT_DIRECTORY: '${{ github.workspace }}/TestOutput'
COMMON_TEST_ARGS: >-
--no-build --configuration Release --collect "XPlat Code Coverage" --logger trx --results-directory ${{ github.workspace }}/TestOutput
--settings coverlet.runsettings --blame-crash --blame-hang-timeout 1m
--no-build --no-progress --configuration Release --results-directory '${{ github.workspace }}/TestOutput'
--report-trx --coverage --coverage-settings coverage.config --crashdump --hangdump --hangdump-timeout 1m

jobs:
analyze:
Expand Down Expand Up @@ -91,19 +92,19 @@ jobs:
run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release --verbosity minimal

- name: Test
run: dotnet test ${{ env.SOLUTION_FILE }} --filter "${{ matrix.skipIntegrationTests == true && 'Category!=MemoryDumps&Category!=Integration' || 'Category!=MemoryDumps' }}" ${{ env.COMMON_TEST_ARGS }}
run: dotnet test --solution ${{ env.SOLUTION_FILE }} --filter-query "${{ matrix.skipIntegrationTests == true && '/[(Category!=MemoryDumps)&(Category!=Integration)]' || '/[Category!=MemoryDumps]' }}" ${{ env.COMMON_TEST_ARGS }}

- name: Test (memory dumps)
run: dotnet test src/Management/test/Endpoint.Test --filter "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}
run: dotnet test --project src/Management/test/Endpoint.Test/Steeltoe.Management.Endpoint.Test.csproj --filter-trait "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}

- name: Upload crash/hang dumps (on failure)
if: ${{ failure() }}
uses: actions/upload-artifact@v5
with:
name: FailedTestOutput-${{ matrix.os }}
path: |
${{ github.workspace }}/TestOutput/**/*.dmp
${{ github.workspace }}/TestOutput/**/Sequence_*.xml
${{ env.TEST_OUTPUT_DIRECTORY }}/*.dmp
${{ env.TEST_OUTPUT_DIRECTORY }}/Sequence_*.xml
if-no-files-found: ignore

- name: Report test results
Expand All @@ -112,14 +113,15 @@ jobs:
with:
name: ${{ matrix.os }} test results
reporter: dotnet-trx
path: '**/*.trx'
path: '${{ env.TEST_OUTPUT_DIRECTORY }}/*.trx'
path-replace-backslashes: true
fail-on-empty: 'true'
fail-on-error: 'false'

- name: Generate code coverage report
uses: danielpalme/ReportGenerator-GitHub-Action@v5
with:
reports: '**/coverage.opencover.xml'
reports: '${{ env.TEST_OUTPUT_DIRECTORY }}/*cobertura.xml'
targetdir: 'coveragereport'
reporttypes: 'MarkdownAssembliesSummary;MarkdownSummaryGithub'
filefilters: '-*.g.cs'
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/component-shared-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
SOLUTION_FILE: 'src/Steeltoe.${{ inputs.component }}.slnf'
TEST_OUTPUT_DIRECTORY: '${{ github.workspace }}/TestOutput'
COMMON_TEST_ARGS: >-
--no-build --configuration Release --collect "XPlat Code Coverage" --logger trx --results-directory ${{ github.workspace }}/TestOutput
--settings coverlet.runsettings --blame-crash --blame-hang-timeout 1m
--no-build --no-progress --configuration Release --results-directory '${{ github.workspace }}/TestOutput'
--report-trx --coverage --coverage-settings coverage.config --crashdump --hangdump --hangdump-timeout 1m

jobs:
build:
Expand Down Expand Up @@ -81,20 +82,20 @@ jobs:
run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release --verbosity minimal

- name: Test
run: dotnet test ${{ env.SOLUTION_FILE }} --filter "Category!=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}
run: dotnet test --solution ${{ env.SOLUTION_FILE }} --filter-not-trait "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}

- name: Test (memory dumps)
if: ${{ inputs.component == 'Management' }}
run: dotnet test src/Management/test/Endpoint.Test --filter "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}
run: dotnet test --project src/Management/test/Endpoint.Test/Steeltoe.Management.Endpoint.Test.csproj --filter-trait "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}

- name: Upload crash/hang dumps (on failure)
if: ${{ failure() }}
uses: actions/upload-artifact@v5
with:
name: FailedTestOutput-${{ inputs.OS }}-latest
path: |
${{ github.workspace }}/TestOutput/**/*.dmp
${{ github.workspace }}/TestOutput/**/Sequence_*.xml
${{ env.TEST_OUTPUT_DIRECTORY }}/*.dmp
${{ env.TEST_OUTPUT_DIRECTORY }}/Sequence_*.xml
if-no-files-found: ignore

- name: Report test results
Expand All @@ -103,6 +104,7 @@ jobs:
with:
name: ${{ inputs.OS }}-latest test results
reporter: dotnet-trx
path: '**/*.trx'
path: '${{ env.TEST_OUTPUT_DIRECTORY }}/*.trx'
path-replace-backslashes: true
fail-on-empty: 'true'
fail-on-error: 'false'
19 changes: 14 additions & 5 deletions .github/workflows/sonarcube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
SOLUTION_FILE: 'src/Steeltoe.All.sln'
TEST_OUTPUT_DIRECTORY: '${{ github.workspace }}/TestOutput'
SONAR_TEST_ARGS: >-
--no-build --configuration Release --collect "XPlat Code Coverage" --logger trx --results-directory ${{ github.workspace }}/TestOutput
--settings coverlet.runsettings -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.UseSourceLink=false
--no-build --no-progress --configuration Release --results-directory '${{ github.workspace }}/TestOutput'
--report-trx --coverage --coverage-settings coverage.sonar.config

jobs:
analyze:
Expand Down Expand Up @@ -75,16 +76,24 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >-
dotnet sonarscanner begin /k:"SteeltoeOSS_steeltoe" /o:"steeltoeoss" /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
/d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
/d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths="${{ env.TEST_OUTPUT_DIRECTORY }}/SonarQube.xml"

- name: Build solution
run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release --verbosity minimal

- name: Test
run: dotnet test ${{ env.SOLUTION_FILE }} --filter "Category!=MemoryDumps" ${{ env.SONAR_TEST_ARGS }}
run: dotnet test --solution ${{ env.SOLUTION_FILE }} --filter-not-trait "Category=MemoryDumps" ${{ env.SONAR_TEST_ARGS }}

- name: Test (memory dumps)
run: dotnet test src/Management/test/Endpoint.Test --filter "Category=MemoryDumps" ${{ env.SONAR_TEST_ARGS }}
run: dotnet test --project src/Management/test/Endpoint.Test/Steeltoe.Management.Endpoint.Test.csproj --filter-trait "Category=MemoryDumps" ${{ env.SONAR_TEST_ARGS }}

- name: Convert Cobertura coverage to Sonar format
uses: danielpalme/ReportGenerator-GitHub-Action@v5
with:
reports: '${{ env.TEST_OUTPUT_DIRECTORY }}/*cobertura.xml'
targetdir: '${{ env.TEST_OUTPUT_DIRECTORY }}'
reporttypes: 'SonarQube'
filefilters: '-*.g.cs'

- name: End Sonar .NET scanner
if: ${{ !cancelled() && steps.sonar_begin.outcome == 'success' }}
Expand Down
29 changes: 29 additions & 0 deletions coverage.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<!--
This file format is documented at https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md.
CAUTION: Microsoft Testing Platform uses different defaults, see https://learn.microsoft.com/en-us/dotnet/core/testing/microsoft-testing-platform-extensions-code-coverage.
-->
<Format>cobertura</Format>
<DeterministicReport>true</DeterministicReport>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*ConfigurationSchemaGenerator.*</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
<Attribute>^System\.ObsoleteAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.Runtime\.CompilerServices\.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
<Sources>
<Exclude>
<Source>.*\\test\\.*</Source>
</Exclude>
</Sources>
</CodeCoverage>
</Configuration>
32 changes: 32 additions & 0 deletions coverage.sonar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<!--
This file format is documented at https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md.
CAUTION: Microsoft Testing Platform uses different defaults, see https://learn.microsoft.com/en-us/dotnet/core/testing/microsoft-testing-platform-extensions-code-coverage.
-->
<Format>cobertura</Format>
<!--
Deterministic paths are turned off for Sonar, because it fails to report coverage otherwise.
<DeterministicReport>true</DeterministicReport>
-->
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*ConfigurationSchemaGenerator.*</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
<Attribute>^System\.ObsoleteAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.Runtime\.CompilerServices\.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
</Exclude>
</Attributes>
<Sources>
<Exclude>
<Source>.*\\test\\.*</Source>
</Exclude>
</Sources>
</CodeCoverage>
</Configuration>
16 changes: 0 additions & 16 deletions coverlet.runsettings

This file was deleted.

5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
6 changes: 1 addition & 5 deletions nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="test-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
15 changes: 11 additions & 4 deletions shared-test.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@
<NoWarn>$(NoWarn);S2094;S3717;SA1602;CA1062;CA1707;NU5104</NoWarn>
</PropertyGroup>

<PropertyGroup>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<!-- Suppress certificate warnings about preview MTP extensions on dev-feed -->
<NoWarn>$(NoWarn);NU3018;NU3027;NU3042</NoWarn>
</PropertyGroup>

<ItemGroup>
<ProjectReference Condition="'$(MSBuildProjectName)' != 'ConfigurationSchemaGenerator.Tests'"
Include="$(MSBuildThisFileDirectory)\src\Common\test\TestResources\Steeltoe.Common.TestResources.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="$(CoverletVersion)" PrivateAssets="All" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(MatchTargetFrameworkVersion)" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="$(FoundationalVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="$(MicrosoftTestingExtensionsCodeCoverageVersion)" />
<PackageReference Include="Microsoft.Testing.Extensions.CrashDump" Version="$(MicrosoftTestingPlatformVersion)" />
<PackageReference Include="Microsoft.Testing.Extensions.HangDump" Version="$(MicrosoftTestingPlatformVersion)" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="$(MicrosoftTestingPlatformVersion)" />
<PackageReference Include="Moq" Version="$(MoqVersion)" />
<PackageReference Include="xunit.v3" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVisualStudioVersion)" />
<PackageReference Include="xunit.v3.mtp-v2" Version="$(XunitVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageReference Include="MongoDB.Driver" Version="$(MongoDbDriverVersion)" />
<PackageReference Include="MySqlConnector" Version="$(MySqlConnectorVersion)" />
<PackageReference Include="MySql.Data" Version="$(MySqlDataVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
<PackageReference Include="Npgsql" Version="$(EntityFrameworkCoreTestVersion)" />
<PackageReference Include="RabbitMQ.Client" Version="$(RabbitClientTestVersion)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.

using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;

namespace Steeltoe.Management.Endpoint.Actuators.Health.Contributors.FileSystem;
Expand All @@ -27,7 +26,6 @@ private NetworkShareWrapper(ulong freeBytesAvailable, ulong totalNumberOfBytes)
: null;
}

[ExcludeFromCodeCoverage(Justification = "Workaround for https://github.com/coverlet-coverage/coverlet/issues/1762")]
private static partial class NativeMethods
{
[LibraryImport("kernel32.dll", EntryPoint = "GetDiskFreeSpaceExW", StringMarshalling = StringMarshalling.Utf16, SetLastError = true)]
Expand Down
3 changes: 2 additions & 1 deletion src/Steeltoe.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_shared", "_shared", "{DC1B
..\.gitattributes = ..\.gitattributes
..\.gitignore = ..\.gitignore
..\cleanupcode.ps1 = ..\cleanupcode.ps1
..\coverlet.runsettings = ..\coverlet.runsettings
..\coverage.config = ..\coverage.config
..\coverage.sonar.config = ..\coverage.sonar.config
..\Directory.Build.targets = ..\Directory.Build.targets
..\nuget.config = ..\nuget.config
..\PackageReadme.md = ..\PackageReadme.md
Expand Down
6 changes: 3 additions & 3 deletions versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
-->

<AspNetCoreHealthChecksVersion>9.0.*</AspNetCoreHealthChecksVersion>
<CoverletVersion>6.0.*</CoverletVersion>
<FluentAssertionsVersion>7.2.*</FluentAssertionsVersion>
<MicrosoftAzureCosmosVersion>3.54.*</MicrosoftAzureCosmosVersion>
<MicrosoftCodeAnalysisVersion>4.14.*</MicrosoftCodeAnalysisVersion>
<!-- TODO: Use stable MTPv2 versions (don't use wildcards, the latest build from dev-feed is often broken). -->
<MicrosoftTestingExtensionsCodeCoverageVersion>18.3.0-preview.25611.1</MicrosoftTestingExtensionsCodeCoverageVersion>
<MicrosoftTestingPlatformVersion>2.1.0-preview.25611.7</MicrosoftTestingPlatformVersion>
<MicrosoftSqlClientVersion>6.1.*</MicrosoftSqlClientVersion>
<MockHttpVersion>7.0.*</MockHttpVersion>
<MongoDbDriverVersion>3.5.*</MongoDbDriverVersion>
Expand All @@ -26,9 +28,7 @@
<SystemCommandLineVersion>2.0.*</SystemCommandLineVersion>
<SystemIdentityModelVersion>8.14.*</SystemIdentityModelVersion>
<SystemSqlClientVersion>4.9.*</SystemSqlClientVersion>
<TestSdkVersion>18.0.*</TestSdkVersion>
<XunitVersion>3.2.*</XunitVersion>
<XunitVisualStudioVersion>3.1.*</XunitVisualStudioVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand Down