Skip to content

Commit

Permalink
feat: Added Hx_HxReport target to generate test reports from TRX test…
Browse files Browse the repository at this point in the history
  • Loading branch information
hennadiilu authored Jun 24, 2024
1 parent 3f192b4 commit 09f51fe
Show file tree
Hide file tree
Showing 26 changed files with 368 additions and 171 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="/" />
<None Include="..\..\README.md" Pack="true" PackagePath="/" />
<None Include="..\..\LICENSE" Pack="true" PackagePath="/" Visible="False" />
<None Include="..\..\README.md" Pack="true" PackagePath="/" Visible="False" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ So, if you follow well-known standards too, you do not even neeed to write custo
## More details

- [Usage](https://heleonix.github.io/docs/Heleonix.Build/usage.html)
- [Extensibility](https://heleonix.github.io/docs/Heleonix.Build/extensibility.md)
- [Extensibility](https://heleonix.github.io/docs/Heleonix.Build/extensibility.html)
- [API](https://heleonix.github.io/docs/Heleonix.Build/api/Heleonix.Build.html)

## Contribution Guideline
Expand Down
94 changes: 94 additions & 0 deletions src/Heleonix.Build/Schemas/Targets/Hx_HxReport.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
Example custom itemtype with particular meta-data required
<xs:element name="MyItem" substitutionGroup="msb:Item">
<xs:complexType>
<xs:complexContent>
<xs:extension base="msb:SimpleItemType">
<xs:sequence maxOccurs="1">
<xs:choice>
<xs:element name="MyMetaData" type="xs:string"/>
</xs:choice>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
Example custom itemtype with NO meta-data
<xs:element name="MySimpleItem" type="msb:SimpleItemType" substitutionGroup="msb:Item"/>
Example custom itemtype with ANY meta-data
<xs:element name="MyFlexibleItem" type="msb:GenericItemType" substitutionGroup="msb:Item"/>
Example custom property that allows string content only
<xs:element name="MySimpleProperty" type="msb:StringPropertyType" substitutionGroup="msb:Property"/>
-->

<xs:schema xmlns:msb="http://schemas.microsoft.com/developer/msbuild/2003"
elementFormDefault="qualified"
targetNamespace="http://schemas.microsoft.com/developer/msbuild/2003"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Hx_HxReport" type="xs:string">
<xs:annotation>
<xs:documentation>
Integrates the https://heleonix.github.io/docs/Testing/Heleonix.Testing.Reporting/index.html into the build framework.
</xs:documentation>
</xs:annotation>
</xs:element>

<xs:element name="Hx_HxReport_ArtifactsDir" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation>A path to the HxReport artifacts directory. Default is '$Hx_Run_ArtifactsDir/HxReport'</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Hx_HxReport_Formats" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation>Formats of output reports to generate. Default is 'Html'.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Hx_HxReport_Merge" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation>
Defines whether the reports for input files should be merged into a single one
or for every input file should be generated a separate report file.
Default is 'true'.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Hx_HxReport_Verbosity" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation>
The verbosity level for loggingn of the report generation process.
Can be 'Critical', 'Debug', 'Error', 'Information', 'None', 'Trace', 'Warning'.
Default is 'Information'.
</xs:documentation>
</xs:annotation>
</xs:element>

<xs:element name="Hx_HxReport_TestResultFiles" type="msb:SimpleItemType" substitutionGroup="msb:Item">
<xs:annotation>
<xs:documentation>The test results files. Defaults are '$Hx_Run_ArtifactsDir/*Test/**/*.trx'.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Hx_HxReport_Style" type="msb:SimpleItemType" substitutionGroup="msb:Item">
<xs:annotation>
<xs:documentation>
The MSBuild item containing style overrides in its metadata.
The metadata keys are possible styles as described in https://heleonix.github.io/docs/Testing/Heleonix.Testing.Reporting/index.html.
For example: 'color-primary', 'color-secondary' etc.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Hx_HxReport_Content" type="msb:SimpleItemType" substitutionGroup="msb:Item">
<xs:annotation>
<xs:documentation>
The MSBuild item containing content overrides in its metadata.
The metadata keys are possible content overrides as described in https://heleonix.github.io/docs/Testing/Heleonix.Testing.Reporting/index.html.
Metadata keys must have '_' instead of '.' in the content paths to be valid metadata keys.
Underscores are replaced back with dots during the 'Hx_HxReport' target execution.
For example: 'Footer_Text', 'Footer_Url', 'Result_Summary_Title', 'Result_Summary_Owner' etc.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
2 changes: 1 addition & 1 deletion src/Heleonix.Build/Schemas/Targets/Hx_ReportGenerator.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Example custom property that allows string content only
</xs:element>
<xs:element name="Hx_ReportGenerator_Verbosity" type="msb:StringPropertyType" substitutionGroup="msb:Property">
<xs:annotation>
<xs:documentation>The verbosity: 'Error', 'Info', 'Verbose'. 'Default' is 'Info'.</xs:documentation>
<xs:documentation>The verbosity: 'Error', 'Info', 'Verbose'. Default is 'Info'.</xs:documentation>
</xs:annotation>
</xs:element>

Expand Down
52 changes: 0 additions & 52 deletions src/Heleonix.Build/Schemas/Targets/Hx_TrxReport.xsd

This file was deleted.

2 changes: 1 addition & 1 deletion src/Heleonix.Build/Schemas/Targets/Targets.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
<xs:include schemaLocation="./Hx_NetValidate.xsd"/>
<xs:include schemaLocation="./Hx_Release_GitHub.xsd"/>
<xs:include schemaLocation="./Hx_ReportGenerator.xsd"/>
<xs:include schemaLocation="./Hx_TrxReport.xsd"/>
<xs:include schemaLocation="./Hx_HxReport.xsd"/>
</xs:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Hx_ChangeLog_GitHubCommit_VersionTagRegExp Condition="'$(Hx_ChangeLog_GitHubCommit_VersionTagRegExp)' == ''">(?&lt;=\D*|^)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?=\D*)</Hx_ChangeLog_GitHubCommit_VersionTagRegExp>
<Hx_ChangeLog_GitHubCommit_MajorChangeRegExp Condition="'$(Hx_ChangeLog_GitHubCommit_MajorChangeRegExp)' == ''">^(\w+)(\([\w-.]+\))?!: (.+)|^(\w+)(\([\w-.]+\))?: (.+)([\r\n])*(?&lt;=\r\r|\n\n|\r\n\r\n)[\s\S]*?(BREAKING CHANGE|BREAKING-CHANGE)(: | #)</Hx_ChangeLog_GitHubCommit_MajorChangeRegExp>
<Hx_ChangeLog_GitHubCommit_MinorChangeRegExp Condition="'$(Hx_ChangeLog_GitHubCommit_MinorChangeRegExp)' == ''">^(feat)(\([\w-.]+\))?: (.+)</Hx_ChangeLog_GitHubCommit_MinorChangeRegExp>
<Hx_ChangeLog_GitHubCommit_PatchChangeRegExp Condition="'$(Hx_ChangeLog_GitHubCommit_PatchChangeRegExp)' == ''">^(fix)(\([\w-.]+\))?: (.+)</Hx_ChangeLog_GitHubCommit_PatchChangeRegExp>
<Hx_ChangeLog_GitHubCommit_PatchChangeRegExp Condition="'$(Hx_ChangeLog_GitHubCommit_PatchChangeRegExp)' == ''">^(fix|docs|perf)(\([\w-.]+\))?: (.+)</Hx_ChangeLog_GitHubCommit_PatchChangeRegExp>
<Hx_ChangeLog_GitHubCommit_ChangeLogRegExp Condition="'$(Hx_ChangeLog_GitHubCommit_ChangeLogRegExp)' == ''">^(?'type'[a-z]+)(?:\((?'scope'[\w-.]+)\))?(?'breaking'!)?: (?'description'.+)(?:[\r\n])*(?'body'(?&lt;=\r\r|\n\n|\r\n\r\n)[\s\S]+?(?!([\w-.]+|BREAKING CHANGE)(: | #)[\s\S]+))??(?:[\r\n])*(?'footer'(?&lt;=\r\r|\n\n|\r\n\r\n)(?:[\w-.]+|(?'breaking'BREAKING-CHANGE|BREAKING CHANGE))(?:: | #)[\s\S]+?)?(?:[\r\n])*$</Hx_ChangeLog_GitHubCommit_ChangeLogRegExp>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Heleonix.Build/Targets/Hx_DocFX_Git.targets
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
EchoOff="true"/>
<Exec
Condition="'$(_Hx_DocFX_Git_ChangesCount)' != '0' and ('$(Hx_DocFX_Git_Token)' == '' or !$(Hx_DocFX_RepositoryUrl.StartsWith('https://')))"
Command="&quot;$(_Hx_DocFX_Git_GitExe)&quot; push &quot;$(Hx_DocFX_RepositoryUrl&quot;"
Command="&quot;$(_Hx_DocFX_Git_GitExe)&quot; push &quot;$(Hx_DocFX_RepositoryUrl)&quot;"
WorkingDirectory="$(Hx_DocFX_ArtifactsDir)"
EchoOff="true"/>
<Message
Expand Down
51 changes: 51 additions & 0 deletions src/Heleonix.Build/Targets/Hx_HxReport.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Hx_HxReport_ArtifactsDir>$(Hx_Run_ArtifactsDir)/HxReport</Hx_HxReport_ArtifactsDir>
</PropertyGroup>

<Target Name="Hx_HxReport">
<Message Text="> RUNNING Hx_HxReport ..." Importance="high"/>

<Hx_NetSetupTool DotnetExe="$(Hx_Sys_DotnetExe)" Name="hxreport">
<Output TaskParameter="ToolPath" PropertyName="_Hx_HxReport_HxReportExe"/>
</Hx_NetSetupTool>

<ItemGroup>
<Hx_HxReport_TestResultFiles
Condition="'@(Hx_HxReport_TestResultFiles)' == ''"
Include="$(Hx_Run_ArtifactsDir)/*Test/**/*.trx"/>
</ItemGroup>
<PropertyGroup>
<Hx_HxReport_Formats Condition="'$(Hx_HxReport_Formats)' == ''">Html</Hx_HxReport_Formats>
<Hx_HxReport_Merge Condition="'$(Hx_HxReport_Merge)' == ''">true</Hx_HxReport_Merge>
<Hx_HxReport_Verbosity Condition="'$(Hx_HxReport_Verbosity)' == ''">Information</Hx_HxReport_Verbosity>
</PropertyGroup>
<Hx_MetadataToCmdArgs Condition="'@(Hx_HxReport_Style)' != ''" Item="@(Hx_HxReport_Style)">
<Output TaskParameter="Result" PropertyName="_Hx_HxReport_StyleArg"/>
</Hx_MetadataToCmdArgs>
<Hx_MetadataToCmdArgs Condition="'@(Hx_HxReport_Content)' != ''" Item="@(Hx_HxReport_Content)" DottedKeys="true">
<Output TaskParameter="Result" PropertyName="_Hx_HxReport_ContentArg"/>
</Hx_MetadataToCmdArgs>

<Message Text="> 1/2: Creating the artifacts directory" Importance="high"/>
<RemoveDir Directories="$(Hx_HxReport_ArtifactsDir)"/>
<MakeDir Directories="$(Hx_HxReport_ArtifactsDir)"/>

<Message Text="> 2/2: Generating report" Importance="high"/>
<PropertyGroup>
<_Hx_HxReport_Arg>--input @(Hx_HxReport_TestResultFiles->'&quot;%(Identity)&quot;', ' ')</_Hx_HxReport_Arg>
<_Hx_HxReport_Arg Condition="'$(Hx_HxReport_Merge)' == 'true'">$(_Hx_HxReport_Arg) --output &quot;$(Hx_HxReport_ArtifactsDir)/Report.ext&quot;</_Hx_HxReport_Arg>
<_Hx_HxReport_Arg Condition="'$(Hx_HxReport_Merge)' != 'true'">$(_Hx_HxReport_Arg) --output &quot;$(Hx_HxReport_ArtifactsDir)&quot;</_Hx_HxReport_Arg>
<_Hx_HxReport_Arg Condition="'$(Hx_HxReport_Merge)' == 'true'">$(_Hx_HxReport_Arg) --merge</_Hx_HxReport_Arg>
<_Hx_HxReport_Arg Condition="'$(_Hx_HxReport_StyleArg)' != ''">$(_Hx_HxReport_Arg) --style $(_Hx_HxReport_StyleArg)</_Hx_HxReport_Arg>
<_Hx_HxReport_Arg Condition="'$(_Hx_HxReport_ContentArg)' != ''">$(_Hx_HxReport_Arg) --content $(_Hx_HxReport_ContentArg)</_Hx_HxReport_Arg>
<_Hx_HxReport_Arg>$(_Hx_HxReport_Arg) --format $(Hx_HxReport_Formats.Replace(';', ' '))</_Hx_HxReport_Arg>
<_Hx_HxReport_Arg>$(_Hx_HxReport_Arg) --verbosity $(Hx_HxReport_Verbosity)</_Hx_HxReport_Arg>
</PropertyGroup>
<Exec Command="&quot;$(_Hx_HxReport_HxReportExe)&quot; $(_Hx_HxReport_Arg)" />

<Message Text="> DONE Hx_HxReport" Importance="high"/>

<OnError ExecuteTargets="Hx_OnError"/>
</Target>
</Project>
2 changes: 1 addition & 1 deletion src/Heleonix.Build/Targets/Hx_NetNugetPush.targets
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<PropertyGroup Condition="'$(_Hx_NetNugetPush_SlnFile)' != ''">
<_Hx_NetNugetPush_VersionProps Condition="'$(Hx_NetNugetPush_Version)' != ''">Version=$(Hx_NetNugetPush_Version)</_Hx_NetNugetPush_VersionProps>
<_Hx_NetNugetPush_ReleaseNotesProps Condition="'$(Hx_NetNugetPush_ReleaseNotesFile)' != ''">PackageReleaseNotes=&quot;$([System.IO.File]::ReadAllText('$(Hx_NetNugetPush_ReleaseNotesFile)').Trim())&quot;</_Hx_NetNugetPush_ReleaseNotesProps>
<_Hx_NetNugetPush_ReleaseNotesProps Condition="'$(Hx_NetNugetPush_ReleaseNotesFile)' != ''">PackageReleaseNotes=$([System.IO.File]::ReadAllText('$(Hx_NetNugetPush_ReleaseNotesFile)').Trim())</_Hx_NetNugetPush_ReleaseNotesProps>
</PropertyGroup>

<MSBuild
Expand Down
3 changes: 2 additions & 1 deletion src/Heleonix.Build/Targets/Hx_NetTest.targets
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<Hx_NetTest_MinLineCoverage Condition="'$(Hx_NetTest_MinLineCoverage)' == ''">100</Hx_NetTest_MinLineCoverage>
<Hx_NetTest_MinBranchCoverage Condition="'$(Hx_NetTest_MinBranchCoverage)' == ''">100</Hx_NetTest_MinBranchCoverage>
<Hx_NetTest_MinMethodCoverage Condition="'$(Hx_NetTest_MinMethodCoverage)' == ''">100</Hx_NetTest_MinMethodCoverage>
<Hx_NetTest_Verbosity Condition="'$(Hx_NetTest_Verbosity)' == ''">minimal</Hx_NetTest_Verbosity>
</PropertyGroup>

<Hx_NetFindSln Condition="'@(Hx_NetTest_TestFiles)' == ''" StartDir="$(Hx_NetBuild_ArtifactsDir)">
Expand All @@ -52,7 +53,7 @@
<_Hx_NetTest_Arg Condition="'$(Hx_NetTest_AdapterDir)' != ''">$(_Hx_NetTest_Arg) --test-adapter-path &quot;$(Hx_NetTest_AdapterDir)&quot;</_Hx_NetTest_Arg>
<_Hx_NetTest_Arg Condition="'$(Hx_NetTest_Collect)' != ''">$(_Hx_NetTest_Arg) --collect &quot;$(Hx_NetTest_Collect)&quot;</_Hx_NetTest_Arg>
<_Hx_NetTest_Arg Condition="'$(Hx_NetTest_DiagFile)' != ''">$(_Hx_NetTest_Arg) --diag &quot;$(Hx_NetTest_DiagFile)&quot;</_Hx_NetTest_Arg>
<_Hx_NetTest_Arg Condition="'$(Hx_NetTest_Verbosity)' != ''">$(_Hx_NetTest_Arg) --verbosity $(Hx_NetTest_Verbosity)</_Hx_NetTest_Arg>
<_Hx_NetTest_Arg>$(_Hx_NetTest_Arg) --verbosity $(Hx_NetTest_Verbosity)</_Hx_NetTest_Arg>
</PropertyGroup>
<PropertyGroup Condition="'$(Hx_NetTest_Logger)' == ''">
<Hx_NetTest_Logger>nunit;LogFileName=NUnitTestResults.xml</Hx_NetTest_Logger>
Expand Down
1 change: 1 addition & 0 deletions src/Heleonix.Build/Targets/Hx_ReportGenerator.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<PropertyGroup>
<Hx_ReportGenerator_ReportTypes Condition="'$(Hx_ReportGenerator_ReportTypes)' == ''">Badges;Html</Hx_ReportGenerator_ReportTypes>
<Hx_ReportGenerator_Verbosity Condition="'$(Hx_ReportGenerator_Verbosity)' == ''">Info</Hx_ReportGenerator_Verbosity>
</PropertyGroup>

<ItemGroup>
Expand Down
30 changes: 0 additions & 30 deletions src/Heleonix.Build/Targets/Hx_TrxReport.targets

This file was deleted.

2 changes: 1 addition & 1 deletion src/Heleonix.Build/Targets/Targets.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
<Import Project="Hx_OnError.targets"/>
<Import Project="Hx_Release_GitHub.targets"/>
<Import Project="Hx_ReportGenerator.targets"/>
<Import Project="Hx_TrxReport.targets"/>
<Import Project="Hx_HxReport.targets"/>
</Project>
6 changes: 6 additions & 0 deletions src/Heleonix.Build/Tasks/Hx_NetSetupTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ protected override void ExecuteInternal()
this.Version = "0.0.3";
}

if ("hxreport".Equals(this.Name, StringComparison.OrdinalIgnoreCase))
{
this.PackageName = "Heleonix.Testing.Reporting";
this.Version = "1.0.2";
}

if ("NunitXml.TestLogger".Equals(this.Name, StringComparison.OrdinalIgnoreCase))
{
this.IsPackage = true;
Expand Down
12 changes: 4 additions & 8 deletions src/Heleonix.Build/Templates/ReleaseNotes.txt.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,40 @@
d.GetMetadata("type") != "fix");
}
@Model.Single(d => !string.IsNullOrEmpty(d.GetMetadata("Version"))).ItemSpec (@DateTime.UtcNow.ToShortDateString())

@if (breaking.Count() > 0)
{
<text>Breaking Changes</text>
@:
<text>Breaking Changes</text>@:
foreach (var change in breaking)
{
<text>- </text> @change.GetMetadata("description").Trim()
@:
}
}

@if (features.Count() > 0)
{
<text>New Features</text>
@:
<text>New Features</text>@:
foreach (var change in features)
{
<text>- </text> @change.GetMetadata("description").Trim()
@:
}
}

@if (fixes.Count() > 0)
{
<text>Bug Fixes</text>
@:
<text>Bug Fixes</text>@:
foreach (var change in fixes)
{
<text>- </text> @change.GetMetadata("description").Trim()
@:
}
}

@if (others.Count() > 0)
{
<text>Other Changes</text>
@:
<text>Other Changes</text>@:
foreach (var change in others)
{
<text>- </text> @change.GetMetadata("description").Trim()
Expand Down
2 changes: 0 additions & 2 deletions src/Heleonix.Build/Templates/TrxReport/TrxReport.css

This file was deleted.

Empty file.
Loading

0 comments on commit 09f51fe

Please sign in to comment.