|
| 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 |
0 commit comments