Skip to content

Commit

Permalink
Publish test results with the dorny/test-reporter GitHub action
Browse files Browse the repository at this point in the history
So that test results are available at a glance in the GitHub action run page.

Also give a proper name to the trx files in order to understand the test results, see microsoft/vstest#1876 (comment)
  • Loading branch information
0xced committed Jan 24, 2024
1 parent c914b28 commit e228066
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .cake-scripts/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal sealed class BuildParameters
public NuGetCredentials NuGetCredentials { get; private set; }
public BuildProjects Projects { get; private set; }
public BuildPaths Paths { get; private set; }
public DotNetMSBuildSettings MSBuildSettings { get; private set; }

public static BuildParameters Instance(ICakeContext context)
{
Expand Down Expand Up @@ -58,7 +59,8 @@ internal sealed class BuildParameters
SonarQubeCredentials = SonarQubeCredentials.GetSonarQubeCredentials(context),
NuGetCredentials = NuGetCredentials.GetNuGetCredentials(context),
Projects = BuildProjects.Instance(context, solutionFilePath),
Paths = BuildPaths.Instance(context, buildInformation.Version)
Paths = BuildPaths.Instance(context, buildInformation.Version),
MSBuildSettings = new DotNetMSBuildSettings()
};
}
}
30 changes: 30 additions & 0 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Test Report'

on:
workflow_run:
workflows: ['Continuous Integration & Delivery']
types:
- completed

permissions:
contents: read
actions: read
checks: write

jobs:
report:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04, windows-2022 ]

runs-on: ubuntu-latest

steps:
- name: Publish ${{ matrix.os }} Test Results
uses: dorny/test-reporter@v1
with:
artifact: ${{ matrix.os }}
name: Test Results (${{ matrix.os }})
path: '*.trx'
reporter: dotnet-trx
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Task("Tests")
NoRestore = true,
NoBuild = true,
Collectors = new[] { "XPlat Code Coverage;Format=opencover" },
Loggers = new[] { "trx" },
MSBuildSettings = param.MSBuildSettings.WithProperty("UseTrxLogger", "true"),
Filter = param.TestFilter,
ResultsDirectory = param.Paths.Directories.TestResultsDirectoryPath,
ArgumentCustomization = args => args
Expand Down
6 changes: 6 additions & 0 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<VSTestLogger Include="trx%3BLogFileName=$(MSBuildProjectName).trx" Condition="$(UseTrxLogger) == 'true'" />
</ItemGroup>
<PropertyGroup>
<VSTestLogger>@(VSTestLogger)</VSTestLogger>
</PropertyGroup>
</Project>

0 comments on commit e228066

Please sign in to comment.