Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2025.3.0",
"version": "2025.3.0.3",
"commands": [
"jb"
],
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/Steeltoe.All.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- os: windows-latest
skipFilter: Category!=Integration
- os: macos-latest
skipFilter: Category!=Integration&Category!=SkipOnMacOS
skipFilter: Category!=Integration
runs-on: ${{ matrix.os }}
continue-on-error: true

Expand Down Expand Up @@ -74,12 +74,12 @@ jobs:
# When that happens, select 'Always Allow' to grant 'dotnet' access to the certificate key in the future.
# and the test run fails, but without indicating which test caused it. By setting this, the causing test fails with the next message:
# Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
# To prevent the causing test from failing the test run, disable it on macOS by adding [Trait("Category", "SkipOnMacOS")].
# To prevent the causing test from failing the test run, disable it on macOS using FactSkippedOnPlatform/TheorySkippedOnPlatform.
shell: bash
run: echo "DOTNET_GENERATE_ASPNET_CERTIFICATE=false" >> $GITHUB_ENV

- name: Git checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
persist-credentials: false

Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:

- name: Upload crash/hang dumps (on failure)
if: ${{ failure() }}
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: FailedTestOutput-${{ matrix.os }}
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/component-configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
with:
component: Configuration
OS: ubuntu
runConfigServer: true
runDockerContainers: true
1 change: 0 additions & 1 deletion .github/workflows/component-management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
with:
component: Management
OS: macos
skipFilter: Category!=SkipOnMacOS

windows:
uses: ./.github/workflows/component-shared-workflow.yml
Expand Down
38 changes: 15 additions & 23 deletions .github/workflows/component-shared-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ on:
OS:
required: true
type: string
skipFilter:
required: false
type: string
runConfigServer:
runDockerContainers:
required: false
type: boolean
default: false
Expand All @@ -24,14 +21,10 @@ permissions:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: true
SOLUTION_FILE: src/Steeltoe.${{ inputs.component }}.slnf
SOLUTION_FILE: 'src/Steeltoe.${{ inputs.component }}.slnf'
COMMON_TEST_ARGS: >-
--no-build --configuration Release --collect "XPlat Code Coverage" --logger trx --results-directory ${{ github.workspace }}/dumps
--settings coverlet.runsettings --blame-crash --blame-hang-timeout 3m
SKIP_FILTER_NO_MEMORY_DUMPS: >-
${{ inputs.skipFilter && format('--filter "{0}&Category!=MemoryDumps"', inputs.skipFilter) || '--filter "Category!=MemoryDumps"' }}
SKIP_FILTER_WITH_MEMORY_DUMPS: >-
${{ inputs.skipFilter && format('--filter "{0}&Category=MemoryDumps"', inputs.skipFilter) || '--filter "Category=MemoryDumps"' }}

jobs:
build:
Expand All @@ -41,11 +34,11 @@ jobs:

services:
eurekaServer:
image: ${{ inputs.runConfigServer && 'steeltoe.azurecr.io/eureka-server' || null }}
image: ${{ inputs.runDockerContainers && 'steeltoe.azurecr.io/eureka-server' || null }}
ports:
- 8761:8761
configServer:
image: ${{ inputs.runConfigServer && 'steeltoe.azurecr.io/config-server' || null }}
image: ${{ inputs.runDockerContainers && 'steeltoe.azurecr.io/config-server' || null }}
env:
eureka.client.enabled: true
eureka.client.serviceUrl.defaultZone: http://eurekaServer:8761/eureka
Expand All @@ -71,12 +64,12 @@ jobs:
# When that happens, select 'Always Allow' to grant 'dotnet' access to the certificate key in the future.
# and the test run fails, but without indicating which test caused it. By setting this, the causing test fails with the next message:
# Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
# To prevent the causing test from failing the test run, disable it on macOS by adding [Trait("Category", "SkipOnMacOS")].
# To prevent the causing test from failing the test run, disable it on macOS using FactSkippedOnPlatform/TheorySkippedOnPlatform.
shell: bash
run: echo "DOTNET_GENERATE_ASPNET_CERTIFICATE=false" >> $GITHUB_ENV

- name: Git checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
persist-credentials: false

Expand All @@ -87,32 +80,31 @@ jobs:
run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release --verbosity minimal

- name: Test (net10.0)
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net10.0 ${{ env.SKIP_FILTER_NO_MEMORY_DUMPS }} ${{ env.COMMON_TEST_ARGS }}
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net10.0 --filter "Category!=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}

- name: Test (net10.0) (memory dumps)
if: ${{ inputs.component == 'Management' }}
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net10.0 ${{ env.SKIP_FILTER_WITH_MEMORY_DUMPS }} ${{ env.COMMON_TEST_ARGS }}
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net10.0 --filter "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}

- name: Test (net9.0)
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net9.0 ${{ env.SKIP_FILTER_NO_MEMORY_DUMPS }} ${{ env.COMMON_TEST_ARGS }}
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net9.0 --filter "Category!=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}

- name: Test (net9.0) (memory dumps)
if: ${{ inputs.component == 'Management' }}
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net9.0 ${{ env.SKIP_FILTER_WITH_MEMORY_DUMPS }} ${{ env.COMMON_TEST_ARGS }}
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net9.0 --filter "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}

- name: Test (net8.0)
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net8.0 ${{ env.SKIP_FILTER_NO_MEMORY_DUMPS }} ${{ env.COMMON_TEST_ARGS }}
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net8.0 --filter "Category!=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}

- name: Test (net8.0) (memory dumps)
if: ${{ inputs.component == 'Management' }}
run: dotnet test ${{ env.SOLUTION_FILE }} --framework net8.0 ${{ env.SKIP_FILTER_WITH_MEMORY_DUMPS }} ${{ env.COMMON_TEST_ARGS }}

run: dotnet test ${{ env.SOLUTION_FILE }} --framework net8.0 --filter "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }}

- name: Upload crash/hang dumps (on failure)
if: ${{ failure() }}
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: FailedTestOutput-${{ inputs.OS }}
name: FailedTestOutput-${{ inputs.OS }}-latest
path: |
${{ github.workspace }}/dumps/**/*.dmp
${{ github.workspace }}/dumps/**/Sequence_*.xml
Expand All @@ -122,7 +114,7 @@ jobs:
if: ${{ !cancelled() }}
uses: dorny/test-reporter@v2
with:
name: ${{ inputs.OS }} test results
name: ${{ inputs.OS }}-latest test results
reporter: dotnet-trx
path: '**/*.trx'
fail-on-empty: 'true'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
10.0.*

- name: Git checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
persist-credentials: false

Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
run: dotnet pack ${{ env.SOLUTION_FILE }} --no-build --configuration Release --output ${{ github.workspace }}/packages /p:VersionSuffix=${{ env.PACKAGE_VERSION_SUFFIX }}

- name: Upload unsigned packages
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
if-no-files-found: error
name: unsigned-packages
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
--description-url 'https://steeltoe.io/'

- name: Upload signed packages
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
if-no-files-found: error
name: signed-packages
Expand Down Expand Up @@ -263,7 +263,7 @@ jobs:

steps:
- name: Git checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
persist-credentials: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scan-vulnerable-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
10.0.*

- name: Git checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
persist-credentials: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonarcube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: dotnet tool install --global dotnet-sonarscanner

- name: Git checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
persist-credentials: false
# Sonar: Shallow clones should be disabled for a better relevancy of analysis.
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/verify-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
10.0.*

- name: Git checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
persist-credentials: false
fetch-depth: 2
Expand All @@ -44,7 +44,10 @@ jobs:
run: dotnet tool restore --verbosity minimal

- name: Restore packages
run: dotnet restore ${{ env.SOLUTION_FILE }} /p:Configuration=Release --verbosity minimal
run: dotnet restore ${{ env.SOLUTION_FILE }} /p:Configuration=Release /p:NuGetAudit=false --verbosity minimal

- name: Build
run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release /p:RunAnalyzers=false

- name: CleanupCode (on PR diff)
if: ${{ github.event_name == 'pull_request' }}
Expand All @@ -56,11 +59,13 @@ jobs:
$baseCommitHash = git rev-parse HEAD~1

Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash in pull request."
dotnet regitlint -s ${{ env.SOLUTION_FILE }} --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff
dotnet jb cleanupcode --version
dotnet regitlint -s $env:SOLUTION_FILE --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --no-updates --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN -f commits -a $headCommitHash -b $baseCommitHash --fail-on-diff --print-diff

- name: CleanupCode (on branch)
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' }}
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
shell: pwsh
run: |
Write-Output "Running code cleanup on all files."
dotnet regitlint -s ${{ env.SOLUTION_FILE }} --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN --fail-on-diff --print-diff
Write-Output 'Running code cleanup on all files.'
dotnet jb cleanupcode --version
dotnet regitlint -s $env:SOLUTION_FILE --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --no-updates --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN --fail-on-diff --print-diff
31 changes: 12 additions & 19 deletions cleanupcode.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 7.0
#Requires -Version 7.4

# This script reformats (part of) the codebase to make it compliant with our coding guidelines.

Expand All @@ -7,38 +7,31 @@ param(
[string] $revision
)

function VerifySuccessExitCode {
if ($LastExitCode -ne 0) {
throw "Command failed with exit code $LastExitCode."
}
}
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
$solutionFile = 'src/Steeltoe.All.sln'

dotnet tool restore
VerifySuccessExitCode

dotnet restore src
VerifySuccessExitCode
dotnet restore $solutionFile /p:NuGetAudit=false
dotnet build $solutionFile --no-restore --configuration Release /p:RunAnalyzers=false

if ($revision) {
$headCommitHash = git rev-parse HEAD
VerifySuccessExitCode

$baseCommitHash = git rev-parse $revision
VerifySuccessExitCode

if ($baseCommitHash -eq $headCommitHash) {
Write-Output "Running code cleanup on staged/unstaged files."
dotnet regitlint -s src/Steeltoe.All.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --properties:Configuration=Release --jb --properties:NuGetAudit=false --jb --verbosity=WARN -f staged,modified
VerifySuccessExitCode
dotnet jb cleanupcode --version
dotnet regitlint -s $solutionFile --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --no-updates --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN -f staged,modified
}
else {
Write-Output "Running code cleanup on commit range $baseCommitHash..$headCommitHash, including staged/unstaged files."
dotnet regitlint -s src/Steeltoe.All.sln --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --properties:Configuration=Release --jb --properties:NuGetAudit=false --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash
VerifySuccessExitCode
dotnet jb cleanupcode --version
dotnet regitlint -s $solutionFile --print-command --skip-tool-check --max-runs=5 --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --no-updates --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN -f staged,modified,commits -a $headCommitHash -b $baseCommitHash
}
}
else {
Write-Output "Running code cleanup on all files."
dotnet regitlint -s src/Steeltoe.All.sln --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --properties:Configuration=Release --jb --properties:NuGetAudit=false --jb --verbosity=WARN
VerifySuccessExitCode
dotnet jb cleanupcode --version
dotnet regitlint -s $solutionFile --print-command --skip-tool-check --jb --dotnetcoresdk=$(dotnet --version) --jb-profile="Steeltoe Full Cleanup" --jb --no-updates --jb --properties:Configuration=Release --jb --properties:RunAnalyzers=false --jb --properties:NuGetAudit=false --jb --verbosity=WARN
}
3 changes: 2 additions & 1 deletion shared-project.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<Import Condition="$(MSBuildProjectName.EndsWith('.Test'))" Project="$(MSBuildThisFileDirectory)\shared-test.props" />
<Import Condition="$(MSBuildProjectName.EndsWith('.Test')) Or $(MSBuildProjectName.EndsWith('.Tests'))"
Project="$(MSBuildThisFileDirectory)\shared-test.props" />
</Project>
3 changes: 2 additions & 1 deletion shared-test.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
</PropertyGroup>

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

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text.Json;
Expand Down Expand Up @@ -50,10 +51,9 @@ public void ConfigureCertificateOptions_BadPath_NoCertificate(string certificate
options.Certificate.Should().BeNull();
}

[Theory]
[TheorySkippedOnPlatform(nameof(OSPlatform.OSX))]
[InlineData("")]
[InlineData(CertificateName)]
[Trait("Category", "SkipOnMacOS")]
public void ConfigureCertificateOptions_ThrowsOnEmptyFile(string certificateName)
{
var appSettings = new Dictionary<string, string?>
Expand Down
29 changes: 29 additions & 0 deletions src/Common/test/TestResources/FactSkippedOnPlatformAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Runtime.InteropServices;
using Xunit;
using Xunit.v3;

namespace Steeltoe.Common.TestResources;

/// <summary>
/// Skips running the decorated test on the specified platforms.
/// </summary>
/// <remarks>
/// A common reason for skipping tests on macOS is because the ASP.NET dev certificate is not trusted. See
/// https://github.com/dotnet/aspnetcore/issues/42273.
/// </remarks>
[XunitTestCaseDiscoverer(typeof(FactDiscoverer))]
[AttributeUsage(AttributeTargets.Method)]
public sealed class FactSkippedOnPlatformAttribute : FactAttribute
{
public FactSkippedOnPlatformAttribute(params string[] platformNames)
{
foreach (OSPlatform platform in platformNames.Select(OSPlatform.Create))
{
Assert.SkipWhen(RuntimeInformation.IsOSPlatform(platform), $"Skipping test on platform {platform}.");
}
}
}
Loading