diff --git a/.github/actions/ci-unit-tests/action.yml b/.github/actions/ci-unit-tests/action.yml index c83696d..ea2edda 100644 --- a/.github/actions/ci-unit-tests/action.yml +++ b/.github/actions/ci-unit-tests/action.yml @@ -1,7 +1,7 @@ name: "CI Unit Tests" description: | - Discovers and runs unit tests for the caller repo, generating code coverage reports - and posting results to the PR. + Discovers and runs unit tests for the caller repo. Results and coverage are + published as artifacts by the test runner and ReportGenerator. inputs: app_id: @@ -16,12 +16,6 @@ inputs: description: Fallback token when App credentials are absent. required: false default: "" - pr_number: - description: > - PR number in the caller repo. Proxy workflows pass this so the - coverage comment targets the right PR in cross-org contexts. - required: false - default: "" test_toolkit_repo: description: > Test_Toolkit repository (owner/repo). Override to point at a fork. @@ -119,47 +113,6 @@ runs: Write-Host "::notice title=UnitTests::Discovered $($projects.Count) test project(s)" foreach ($p in $projects) { Write-Host " $(Resolve-Path -Relative $p)" } - # Diagnostic only, never fails the check. Reports where the new selection - # differs from what the previous .sln-driven implementation would have - # picked, so a repo whose set changes is visible rather than silent. - - name: Compare against the solution-driven selection - if: steps.test_check.outputs.found == 'true' - shell: pwsh - env: - PROJECT_LIST: ${{ runner.temp }}/ci-unit-tests-projects.txt - run: | - $new = @(Get-Content $env:PROJECT_LIST | Where-Object { $_ }) - - # Exactly the previous behaviour: non-recursive .sln lookup, first - # match, quoted paths ending in Tests.csproj. - $slns = Get-ChildItem -Path ".ci/unit-tests" -Filter "*.sln" -ErrorAction SilentlyContinue - $old = @() - if ($slns) { - $sln = $slns[0].FullName - $slnDir = Split-Path $sln -Parent - $old = @(Select-String -Path $sln -Pattern '"(?
[^"]+Tests\.csproj)"' | ForEach-Object {
- $rel = $_.Matches[0].Groups['p'].Value -replace '\\','/'
- $abs = Join-Path $slnDir $rel
- if (Test-Path $abs) { (Resolve-Path $abs).Path }
- })
- }
-
- $onlyNew = @($new | Where-Object { $old -notcontains $_ })
- $onlyOld = @($old | Where-Object { $new -notcontains $_ })
-
- if (-not $slns) {
- Write-Host "::notice title=UnitTests::No .sln directly under .ci/unit-tests, so the previous implementation selected nothing here and ran no tests."
- }
- if ($onlyNew) {
- Write-Host "::notice title=UnitTests::Newly discovered, not selected by the solution: $(($onlyNew | ForEach-Object { Split-Path $_ -Leaf }) -join ', ')"
- }
- if ($onlyOld) {
- Write-Host "::warning title=UnitTests::Listed in the solution but not detected as a test project: $(($onlyOld | ForEach-Object { Split-Path $_ -Leaf }) -join ', ')"
- }
- if ($slns -and -not $onlyNew -and -not $onlyOld) {
- Write-Host "::notice title=UnitTests::Selection matches the solution-driven selection."
- }
-
- name: Mint dependency token
id: dep-token
if: steps.test_check.outputs.found == 'true'
@@ -329,10 +282,20 @@ runs:
continue
}
+ # The excluded tests never reach the results files, so vstest lists
+ # them by category, as written, beside the run's own output.
+ New-Item -ItemType Directory -Force -Path TestResults | Out-Null
+ foreach ($dll in [regex]::Matches($listOut, '(?m)^Test run for (.+?\.dll) \(')) {
+ dotnet vstest $dll.Groups[1].Value /ListFullyQualifiedTests `
+ "/ListTestsTargetPath:$(Join-Path $PWD "TestResults/$name.excluded.txt")" `
+ "/TestCaseFilter:TestCategory=$category" | Out-Null
+ }
+
Write-Host "::group::dotnet test $name --filter $filter"
dotnet test $proj -c Test --no-build --filter $filter `
--collect:"XPlat Code Coverage" `
- --logger "trx;LogFileName=$name.trx" --results-directory TestResults
+ --logger "trx;LogFileName=$name.trx" --logger "html;LogFileName=$name.html" `
+ --results-directory TestResults
$exit = $LASTEXITCODE
Write-Host "::endgroup::"
@@ -430,13 +393,9 @@ runs:
}
if ($partialNotRun) {
- "" | Add-Content -Path $env:GITHUB_STEP_SUMMARY
- "> **Not run.** These tests were admitted by the filter and the runner did not execute them, usually `Assert.Inconclusive` or `[Ignore]`. The check passed on the tests that did run." |
+ $names = @(foreach ($p in $partialNotRun) { foreach ($t in $p.Names) { "- ``$($p.Name)``: $t" } })
+ @("", "Not run ($($names.Count))
", "") + $names + @("", "