Skip to content

Commit f056ef7

Browse files
committed
feat: xml extension
1 parent 9b0621d commit f056ef7

52 files changed

Lines changed: 2360 additions & 382 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/hooks/hooks.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"Stop": [
1111
{
1212
"type": "command",
13-
"command": "node .github/hooks/scripts/stop-build.js",
14-
"timeout": 600
13+
"command": "node .github/hooks/scripts/stop-test-coverage.js",
14+
"timeout": 30
1515
},
1616
{
1717
"type": "command",
18-
"command": "node .github/hooks/scripts/stop-test-coverage.js",
19-
"timeout": 30
18+
"command": "node .github/hooks/scripts/stop-build.js",
19+
"timeout": 600
2020
}
2121
]
2222
}

Flowthru.slnx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<Project Path="src/core/Flowthru.Core.CodeFixes/Flowthru.Core.CodeFixes.csproj" />
1313
<Project Path="src/core/Flowthru.FUnit.CodeFixes/Flowthru.FUnit.CodeFixes.csproj" />
1414
<Project Path="src/extensions/Flowthru.Extensions.Csv/Flowthru.Extensions.Csv.csproj" />
15+
<Project Path="src/extensions/Flowthru.Extensions.Xml/Flowthru.Extensions.Xml.csproj" />
1516
<Project Path="src/extensions/Flowthru.Extensions.Excel/Flowthru.Extensions.Excel.csproj" />
1617
<Project Path="src/extensions/Flowthru.Extensions.EFCore/Flowthru.Extensions.EFCore.csproj" />
1718
<Project Path="src/extensions/Flowthru.Extensions.GQL/Flowthru.Extensions.GQL.csproj" />
@@ -59,6 +60,7 @@
5960
<Project Path="tests/extensions/Flowthru.Extensions.EFCore.Bulk.Tests/Flowthru.Extensions.EFCore.Bulk.Tests.csproj" />
6061
<Project Path="tests/extensions/Flowthru.Extensions.Python.Tests/Flowthru.Extensions.Python.Tests.csproj" />
6162
<Project Path="tests/extensions/Flowthru.Extensions.Python.SourceGenerators.Tests/Flowthru.Extensions.Python.SourceGenerators.Tests.csproj" />
63+
<Project Path="tests/extensions/Flowthru.Extensions.Xml.Tests/Flowthru.Extensions.Xml.Tests.csproj" />
6264
</Folder>
6365
<Folder Name="/tests/misc/">
6466
<Project Path="tests/misc/Flowthru.Misc.DataFrames.Tests/Flowthru.Misc.DataFrames.Tests.csproj" />
@@ -85,5 +87,6 @@
8587
<Project Path="examples/advanced/SpaceflightsDistributed/SpaceflightsDistributed/SpaceflightsDistributed.csproj" />
8688
<Project Path="examples/advanced/RetailDataSplitFlow/RetailDataSplitFlow.csproj" />
8789
<Project Path="examples/advanced/KedroSpaceflightsGQL/KedroSpaceflightsGQL.csproj" />
90+
<Project Path="examples/advanced/FlowthruCoverage/FlowthruCoverage.csproj" />
8891
</Folder>
8992
</Solution>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated metadata
2+
Metadata/
3+
4+
# Ignore all generated data artifacts
5+
Data/**
6+
7+
# Un-ignore layer directories and their Schemas subdirectories
8+
!Data/*/
9+
!Data/*/Schemas/
10+
!Data/_01_Raw/Datasets/
11+
12+
# Un-ignore schema and catalog .cs files
13+
!Data/**/*.cs
14+
15+
# Un-ignore .gitkeep files
16+
!**/.gitkeep
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Flowthru.Core.Data;
2+
3+
namespace FlowthruCoverage.Data;
4+
5+
public partial class Catalog : CatalogAbstract
6+
{
7+
private readonly string _basePath;
8+
9+
public Catalog(string basePath)
10+
{
11+
_basePath = basePath;
12+
InitializeCatalogProperties();
13+
}
14+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FlowthruCoverage.Data._01_Raw.Schemas;
2+
using Flowthru.Core.Data;
3+
4+
namespace FlowthruCoverage.Data;
5+
6+
public partial class Catalog
7+
{
8+
/// <summary>
9+
/// Staged Cobertura XML files, one per test or example project.
10+
/// Run the <c>_stage-coverage-xml</c> NX target before executing the pipeline.
11+
/// Each file is named <c>{ProjectName}.xml</c>.
12+
/// </summary>
13+
public IItem<IEnumerable<XmlDocument<CoberturaReport>>> CoverageXmlFiles =>
14+
CreateItem(
15+
() =>
16+
ItemFactory.Enumerable.XmlDocuments<CoberturaReport>(
17+
label: "CoverageXmlFiles",
18+
directoryPath: $"{_basePath}/_01_Raw/Datasets"
19+
)
20+
);
21+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using System.Xml.Serialization;
2+
using Flowthru.Core.Abstractions;
3+
4+
namespace FlowthruCoverage.Data._01_Raw.Schemas;
5+
6+
/// <summary>Root element of a Cobertura XML coverage report.</summary>
7+
[XmlRoot("coverage")]
8+
public class CoberturaReport : IStructuredSerializable
9+
{
10+
[XmlAttribute("line-rate")]
11+
public double LineRate { get; set; }
12+
13+
[XmlAttribute("branch-rate")]
14+
public double BranchRate { get; set; }
15+
16+
[XmlAttribute("lines-covered")]
17+
public int LinesCovered { get; set; }
18+
19+
[XmlAttribute("lines-valid")]
20+
public int LinesValid { get; set; }
21+
22+
[XmlAttribute("branches-covered")]
23+
public int BranchesCovered { get; set; }
24+
25+
[XmlAttribute("branches-valid")]
26+
public int BranchesValid { get; set; }
27+
28+
[XmlArray("packages")]
29+
[XmlArrayItem("package")]
30+
public List<CoberturaPackage> Packages { get; set; } = [];
31+
}
32+
33+
/// <summary>A named package (assembly) within a Cobertura report.</summary>
34+
public class CoberturaPackage
35+
{
36+
[XmlAttribute("name")]
37+
public string Name { get; set; } = string.Empty;
38+
39+
[XmlAttribute("line-rate")]
40+
public double LineRate { get; set; }
41+
42+
[XmlAttribute("branch-rate")]
43+
public double BranchRate { get; set; }
44+
45+
[XmlArray("classes")]
46+
[XmlArrayItem("class")]
47+
public List<CoberturaClass> Classes { get; set; } = [];
48+
}
49+
50+
/// <summary>A named class within a package.</summary>
51+
public class CoberturaClass
52+
{
53+
[XmlAttribute("name")]
54+
public string Name { get; set; } = string.Empty;
55+
56+
[XmlAttribute("filename")]
57+
public string Filename { get; set; } = string.Empty;
58+
59+
[XmlAttribute("line-rate")]
60+
public double LineRate { get; set; }
61+
62+
[XmlAttribute("branch-rate")]
63+
public double BranchRate { get; set; }
64+
65+
[XmlArray("methods")]
66+
[XmlArrayItem("method")]
67+
public List<CoberturaMethod> Methods { get; set; } = [];
68+
}
69+
70+
/// <summary>A named method within a class.</summary>
71+
public class CoberturaMethod
72+
{
73+
[XmlAttribute("name")]
74+
public string Name { get; set; } = string.Empty;
75+
76+
[XmlAttribute("signature")]
77+
public string Signature { get; set; } = string.Empty;
78+
79+
[XmlAttribute("line-rate")]
80+
public double LineRate { get; set; }
81+
82+
[XmlAttribute("branch-rate")]
83+
public double BranchRate { get; set; }
84+
85+
[XmlArray("lines")]
86+
[XmlArrayItem("line")]
87+
public List<CoberturaLine> Lines { get; set; } = [];
88+
}
89+
90+
/// <summary>A single instrumented line within a method.</summary>
91+
public class CoberturaLine
92+
{
93+
[XmlAttribute("number")]
94+
public int Number { get; set; }
95+
96+
[XmlAttribute("hits")]
97+
public int Hits { get; set; }
98+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using FlowthruCoverage.Data._02_Intermediate.Schemas;
2+
using Flowthru.Core.Data;
3+
4+
namespace FlowthruCoverage.Data;
5+
6+
public partial class Catalog
7+
{
8+
/// <summary>Flat line-level coverage rows, one row per instrumented line per test project.</summary>
9+
public IItem<IEnumerable<LineCoverageRow>> LineCoverage =>
10+
CreateItem(
11+
() =>
12+
ItemFactory.Enumerable.Csv<LineCoverageRow>(
13+
label: "LineCoverage",
14+
filePath: $"{_basePath}/_02_Intermediate/Datasets/line_coverage.csv"
15+
)
16+
);
17+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Flowthru.Core.Abstractions;
2+
3+
namespace FlowthruCoverage.Data._02_Intermediate.Schemas;
4+
5+
/// <summary>
6+
/// A single instrumented line from a coverage report, tagged with its origin test project.
7+
/// One row per source line per test project that exercised it.
8+
/// </summary>
9+
[FlowthruSchema]
10+
public partial record LineCoverageRow
11+
{
12+
/// <summary>The test or example project that produced this coverage reading (derived from file name).</summary>
13+
public required string TestProject { get; init; }
14+
15+
/// <summary>The assembly/package name as reported by Cobertura (e.g. "Flowthru.Core").</summary>
16+
public required string SrcPackage { get; init; }
17+
18+
/// <summary>The source file path as recorded in the Cobertura XML.</summary>
19+
public required string SourceFile { get; init; }
20+
21+
/// <summary>The fully-qualified class name.</summary>
22+
public required string ClassName { get; init; }
23+
24+
/// <summary>The method name.</summary>
25+
public required string MethodName { get; init; }
26+
27+
/// <summary>The method signature.</summary>
28+
public required string MethodSignature { get; init; }
29+
30+
/// <summary>The source line number.</summary>
31+
public required int LineNumber { get; init; }
32+
33+
/// <summary>
34+
/// Number of times this line was executed. 0 = uncovered; &gt;0 = covered with that many hits.
35+
/// </summary>
36+
public required int Hits { get; init; }
37+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using FlowthruCoverage.Data._03_Primary.Schemas;
2+
using Flowthru.Core.Data;
3+
4+
namespace FlowthruCoverage.Data;
5+
6+
public partial class Catalog
7+
{
8+
/// <summary>
9+
/// Per-(TestProject, SrcPackage) coverage aggregates.
10+
/// Pivot this CSV on TestProject vs SrcPackage to produce the coverage heatmap.
11+
/// </summary>
12+
public IItem<IEnumerable<PackageCoverageRow>> PackageCoverage =>
13+
CreateItem(
14+
() =>
15+
ItemFactory.Enumerable.Csv<PackageCoverageRow>(
16+
label: "PackageCoverage",
17+
filePath: $"{_basePath}/_03_Primary/Datasets/package_coverage.csv"
18+
)
19+
);
20+
}

0 commit comments

Comments
 (0)