Skip to content

Commit b38677c

Browse files
Copilotpascalberger
andcommitted
Complete JUnit provider implementation with solution integration and documentation
Co-authored-by: pascalberger <[email protected]>
1 parent 12352b6 commit b38677c

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

src/Cake.Issues.JUnit/JUnitIssuesProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// </summary>
1515
/// <param name="log">The Cake log context.</param>
1616
/// <param name="issueProviderSettings">Settings for the issue provider.</param>
17-
internal class JUnitIssuesProvider(ICakeLog log, JUnitIssuesSettings issueProviderSettings) : BaseConfigurableIssueProvider<JUnitIssuesSettings>(log, issueProviderSettings)
17+
public class JUnitIssuesProvider(ICakeLog log, JUnitIssuesSettings issueProviderSettings) : BaseConfigurableIssueProvider<JUnitIssuesSettings>(log, issueProviderSettings)
1818
{
1919
/// <summary>
2020
/// Gets the name of the JUnit issue provider.

src/Cake.Issues.JUnit/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Cake.Issues.JUnit
2+
3+
This provider supports reading issues from JUnit XML format, which is used by various linters and tools.
4+
5+
## Supported Tools
6+
7+
The JUnit issue provider can read issues from any tool that outputs JUnit XML format, including:
8+
9+
- **cpplint**: C++ linter that can output JUnit format
10+
- **commitlint-format-junit**: Commit message linter with JUnit output
11+
- **kubeconform**: Kubernetes manifest validator with JUnit format
12+
- **htmlhint**: HTML linter with JUnit format support
13+
- Many other tools that support JUnit XML output
14+
15+
## Features
16+
17+
- Parses both single `testsuite` and `testsuites` root elements
18+
- Extracts file paths from classname attributes or failure messages
19+
- Supports multiple file path patterns:
20+
- `file:line:column` (e.g., `src/file.cpp:15:5`)
21+
- `file(line,column)` (e.g., `index.html(12,5)`)
22+
- `file line number` (e.g., `about.html line 8`)
23+
- Maps test failures and errors to Cake.Issues format
24+
- Handles system-out sections for additional context
25+
26+
## Usage
27+
28+
```csharp
29+
#addin nuget:?package=Cake.Issues&version=x.x.x
30+
#addin nuget:?package=Cake.Issues.JUnit&version=x.x.x
31+
32+
Task("ReadIssues")
33+
.Does(() =>
34+
{
35+
var issues = ReadIssues(
36+
JUnitIssuesFromFilePath(@"c:\build\junit-results.xml"),
37+
@"c:\repo");
38+
39+
Information($"{issues.Count()} issues found");
40+
});
41+
```
42+
43+
## JUnit XML Format
44+
45+
The provider expects standard JUnit XML format:
46+
47+
```xml
48+
<?xml version="1.0" encoding="UTF-8"?>
49+
<testsuite name="tool-name" tests="2" failures="1" errors="0" time="0.123">
50+
<testcase classname="src/file.cpp" name="rule-name" time="0.001">
51+
<failure message="Issue description" type="error-type">
52+
Additional failure details with file:line:column information
53+
</failure>
54+
</testcase>
55+
</testsuite>
56+
```
57+
58+
The provider will extract:
59+
- File path from `classname` attribute or failure message
60+
- Line/column numbers from failure message patterns
61+
- Issue description from `message` attribute and failure content
62+
- Rule name from failure `type` attribute or test `name`
63+
- Priority based on failure vs error elements

src/Cake.Issues.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{9887889A
301301
..\nuspec\nuget\Cake.Issues.Tap.nuspec = ..\nuspec\nuget\Cake.Issues.Tap.nuspec
302302
EndProjectSection
303303
EndProject
304+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Issues.JUnit", "Cake.Issues.JUnit\Cake.Issues.JUnit.csproj", "{993E2A82-6E24-47EB-BBA7-0E735B0E8172}"
305+
EndProject
306+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Issues.JUnit.Tests", "Cake.Issues.JUnit.Tests\Cake.Issues.JUnit.Tests.csproj", "{9AFF330A-9151-4AF9-BAFE-B79DB6016228}"
307+
EndProject
304308
Global
305309
GlobalSection(SolutionConfigurationPlatforms) = preSolution
306310
Debug|Any CPU = Debug|Any CPU
@@ -455,6 +459,14 @@ Global
455459
{58C5D37D-18B1-4F44-9527-F515C319C7BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
456460
{58C5D37D-18B1-4F44-9527-F515C319C7BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
457461
{58C5D37D-18B1-4F44-9527-F515C319C7BE}.Release|Any CPU.Build.0 = Release|Any CPU
462+
{993E2A82-6E24-47EB-BBA7-0E735B0E8172}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
463+
{993E2A82-6E24-47EB-BBA7-0E735B0E8172}.Debug|Any CPU.Build.0 = Debug|Any CPU
464+
{993E2A82-6E24-47EB-BBA7-0E735B0E8172}.Release|Any CPU.ActiveCfg = Release|Any CPU
465+
{993E2A82-6E24-47EB-BBA7-0E735B0E8172}.Release|Any CPU.Build.0 = Release|Any CPU
466+
{9AFF330A-9151-4AF9-BAFE-B79DB6016228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
467+
{9AFF330A-9151-4AF9-BAFE-B79DB6016228}.Debug|Any CPU.Build.0 = Debug|Any CPU
468+
{9AFF330A-9151-4AF9-BAFE-B79DB6016228}.Release|Any CPU.ActiveCfg = Release|Any CPU
469+
{9AFF330A-9151-4AF9-BAFE-B79DB6016228}.Release|Any CPU.Build.0 = Release|Any CPU
458470
EndGlobalSection
459471
GlobalSection(SolutionProperties) = preSolution
460472
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)