From d8df5c88cf22b9a90fb7a48b73ee3fa7dcf7eb07 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 18 Dec 2024 11:29:15 -0700 Subject: [PATCH 1/9] Activate GitHub Actions test reporting --- Directory.Packages.props | 1 + azure-pipelines/dotnet-test-cloud.ps1 | 35 ++++++++++++++++++++++++--- test/Directory.Build.props | 3 +++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 1023aca..1f94284 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,6 +6,7 @@ true + diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index 33ff3d7..c0be867 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -25,6 +25,8 @@ Param( $RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path $ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" +$TestLogsPath = "$ArtifactStagingFolder/test_logs" +if (!(Test-Path $TestLogsPath)) { New-Item -ItemType Directory -Path $TestLogsPath | Out-Null } $dotnet = 'dotnet' if ($x86) { @@ -44,21 +46,46 @@ if ($x86) { } } +$dotnetTestArgs = @() +$dotnetTestArgs2 = @() + +# The GitHubActions test logger fails when combined with certain switches, but only on mac/linux. +# We avoid those switches in that specific context. +# Failure symptoms when using the wrong switch combinations on mac/linux are (depending on the switches) EITHER: +# - The test runner fails with exit code 1 (and no error message) +# - The test runner succeeds but the GitHubActions logger only adds annotations on Windows agents. +# See https://github.com/Tyrrrz/GitHubActionsTestLogger/discussions/37 for more info. +# Thus, the mess of conditions you see below, in order to get GitHubActions to work +# without undermining other value we have when running in other contexts. +if ($env:GITHUB_WORKFLOW -and ($IsLinux -or $IsMacOS)) { + $dotnetTestArgs += '--collect','Xplat Code Coverage' + $dotnetTestArgs2 += 'DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover' +} else { + $dotnetTestArgs += '--diag','$$TestLogsPath/diag.log;TraceLevel=info' + $dotnetTestArgs += '--collect','Code Coverage;Format=cobertura' + $dotnetTestArgs += '--settings',"$PSScriptRoot/test.runsettings" +} + +if ($env:GITHUB_WORKFLOW) { + $dotnetTestArgs += '--logger','GitHubActions' + $dotnetTestArgs2 += 'RunConfiguration.CollectSourceInformation=true' +} + & $dotnet test $RepoRoot ` --no-build ` -c $Configuration ` --filter "TestCategory!=FailsInCloudTest" ` - --collect "Code Coverage;Format=cobertura" ` - --settings "$PSScriptRoot/test.runsettings" ` --blame-hang-timeout 60s ` --blame-crash ` -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` - --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" ` --logger trx ` + @dotnetTestArgs ` + -- ` + @dotnetTestArgs2 $unknownCounter = 0 Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { - Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/ + Copy-Item $_ -Destination $TestLogsPath/ if ($PublishResults) { $x = [xml](Get-Content -LiteralPath $_) diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 6c7aa71..65b3bad 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -7,4 +7,7 @@ true + + + From d2f4c5e339b1be2bb8bccff6ef13b0a3fe63c81e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 18 Dec 2024 15:10:28 -0700 Subject: [PATCH 2/9] Revert "Merge pull request #319 from AArnott/betterTestingLibTemplate" This reverts commit 01eeb1aff44be490aea525baa92f89240ba2f682, reversing changes made to 0a42cd9afd1e40f6a5392850a5115ca5f42dfd9a. --- Directory.Packages.props | 1 - azure-pipelines/dotnet-test-cloud.ps1 | 35 +++------------------------ test/Directory.Build.props | 3 --- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 1f94284..1023aca 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,6 @@ true - diff --git a/azure-pipelines/dotnet-test-cloud.ps1 b/azure-pipelines/dotnet-test-cloud.ps1 index c0be867..33ff3d7 100755 --- a/azure-pipelines/dotnet-test-cloud.ps1 +++ b/azure-pipelines/dotnet-test-cloud.ps1 @@ -25,8 +25,6 @@ Param( $RepoRoot = (Resolve-Path "$PSScriptRoot/..").Path $ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1" -$TestLogsPath = "$ArtifactStagingFolder/test_logs" -if (!(Test-Path $TestLogsPath)) { New-Item -ItemType Directory -Path $TestLogsPath | Out-Null } $dotnet = 'dotnet' if ($x86) { @@ -46,46 +44,21 @@ if ($x86) { } } -$dotnetTestArgs = @() -$dotnetTestArgs2 = @() - -# The GitHubActions test logger fails when combined with certain switches, but only on mac/linux. -# We avoid those switches in that specific context. -# Failure symptoms when using the wrong switch combinations on mac/linux are (depending on the switches) EITHER: -# - The test runner fails with exit code 1 (and no error message) -# - The test runner succeeds but the GitHubActions logger only adds annotations on Windows agents. -# See https://github.com/Tyrrrz/GitHubActionsTestLogger/discussions/37 for more info. -# Thus, the mess of conditions you see below, in order to get GitHubActions to work -# without undermining other value we have when running in other contexts. -if ($env:GITHUB_WORKFLOW -and ($IsLinux -or $IsMacOS)) { - $dotnetTestArgs += '--collect','Xplat Code Coverage' - $dotnetTestArgs2 += 'DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover' -} else { - $dotnetTestArgs += '--diag','$$TestLogsPath/diag.log;TraceLevel=info' - $dotnetTestArgs += '--collect','Code Coverage;Format=cobertura' - $dotnetTestArgs += '--settings',"$PSScriptRoot/test.runsettings" -} - -if ($env:GITHUB_WORKFLOW) { - $dotnetTestArgs += '--logger','GitHubActions' - $dotnetTestArgs2 += 'RunConfiguration.CollectSourceInformation=true' -} - & $dotnet test $RepoRoot ` --no-build ` -c $Configuration ` --filter "TestCategory!=FailsInCloudTest" ` + --collect "Code Coverage;Format=cobertura" ` + --settings "$PSScriptRoot/test.runsettings" ` --blame-hang-timeout 60s ` --blame-crash ` -bl:"$ArtifactStagingFolder/build_logs/test.binlog" ` + --diag "$ArtifactStagingFolder/test_logs/diag.log;TraceLevel=info" ` --logger trx ` - @dotnetTestArgs ` - -- ` - @dotnetTestArgs2 $unknownCounter = 0 Get-ChildItem -Recurse -Path $RepoRoot\test\*.trx |% { - Copy-Item $_ -Destination $TestLogsPath/ + Copy-Item $_ -Destination $ArtifactStagingFolder/test_logs/ if ($PublishResults) { $x = [xml](Get-Content -LiteralPath $_) diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 65b3bad..6c7aa71 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -7,7 +7,4 @@ true - - - From 7b18fd08172526499129f394ae71878cfc0acc63 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 Dec 2024 08:14:30 -0700 Subject: [PATCH 3/9] Resolve schema validation error in VS Code for docfx yml files --- docfx/docs/toc.yml | 2 +- docfx/toc.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docfx/docs/toc.yml b/docfx/docs/toc.yml index 36a3802..518ffad 100644 --- a/docfx/docs/toc.yml +++ b/docfx/docs/toc.yml @@ -1,5 +1,5 @@ +items: - name: Features href: features.md - name: Getting Started href: getting-started.md - diff --git a/docfx/toc.yml b/docfx/toc.yml index abd17b8..8e9a670 100644 --- a/docfx/toc.yml +++ b/docfx/toc.yml @@ -1,3 +1,4 @@ +items: - name: Docs href: docs/ - name: API From ad4ff0f092dfc147fdb6f5f2151c7071c9b8bc6e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 Dec 2024 10:19:52 -0700 Subject: [PATCH 4/9] Bump xunit.runner.visualstudio to 3.0.0 --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 1023aca..b10eaee 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From 2e9751f002252714719de4d2f914156902b8aae5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 Dec 2024 10:19:58 -0700 Subject: [PATCH 5/9] Bump .NET SDK to 9.0.101 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 088f23e..f3e0b32 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.100", + "version": "9.0.101", "rollForward": "patch", "allowPrerelease": false } From 0c33c695660191469a486f8f9de195f378f1bd2d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 Dec 2024 10:35:40 -0700 Subject: [PATCH 6/9] Organize Directory.Packages.props to reduce merge conflicts going forward --- Directory.Packages.props | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Directory.Packages.props b/Directory.Packages.props index b10eaee..32113f5 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,11 +6,17 @@ true + + + + + + From 99ee1fcd49f2d7ce9cf8e5c1d2927260548d0171 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 22 Dec 2024 18:50:42 -0700 Subject: [PATCH 7/9] Bump to Xunit v3 --- Directory.Packages.props | 4 ++-- test/Library.Tests/Library.Tests.csproj | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 32113f5..63808e7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,7 +11,7 @@ - + @@ -24,4 +24,4 @@ - + \ No newline at end of file diff --git a/test/Library.Tests/Library.Tests.csproj b/test/Library.Tests/Library.Tests.csproj index a853dc7..5cbc1e1 100644 --- a/test/Library.Tests/Library.Tests.csproj +++ b/test/Library.Tests/Library.Tests.csproj @@ -3,6 +3,7 @@ net8.0 $(TargetFrameworks);net472 + Exe @@ -13,7 +14,7 @@ - + From 94eba4a33a15fd28a0693bba3e3e5086d0df8d24 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 23 Dec 2024 09:48:35 -0700 Subject: [PATCH 8/9] Build servicing branches --- .github/workflows/build.yml | 1 + azure-pipelines.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 474d90c..fbd7115 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - 'v*.*' - validate/* pull_request: workflow_dispatch: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9867b3d..4d372fe 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,6 +3,7 @@ trigger: branches: include: - main + - 'v*.*' - 'validate/*' paths: exclude: From 275a44b6c5cb089a21ac2b2456c55d66ec172236 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 23 Dec 2024 11:39:09 -0700 Subject: [PATCH 9/9] Do not publish artifacts on cancelled GitHub workflows --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fbd7115..58e56cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,7 +62,7 @@ jobs: shell: pwsh - name: 📢 Publish artifacts uses: ./.github/actions/publish-artifacts - if: always() + if: cancelled() == false - name: 📢 Publish code coverage results to codecov.io run: ./azure-pipelines/publish-CodeCov.ps1 -CodeCovToken "${{ env.codecov_token }}" -PathToCodeCoverage "${{ runner.temp }}/_artifacts/coverageResults" -Name "${{ runner.os }} Coverage Results" -Flags "${{ runner.os }}" shell: pwsh