Overview
The file src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/GitHubActionsSummaryReporter.cs has grown to 661 lines, making it harder to navigate and maintain. This task involves refactoring it into smaller, more focused files.
Note: XxHashShared.cs (925 lines) and JsonReader.cs (691 lines) were also identified as large files but are excluded — they are verbatim/ported vendored code from dotnet/runtime and a third-party library (Jsonite), respectively, so refactoring them is out of scope.
Current State
- File:
src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/GitHubActionsSummaryReporter.cs
- Size: 661 lines
- Language: C#
Structural Analysis
The file defines a single internal sealed class GitHubActionsSummaryReporter implementing IDataConsumer, IDataProducer, ITestSessionLifetimeHandler, and IOutputDeviceDataProducer. Key members include:
- Lifecycle/interface methods:
IsEnabledAsync, OnTestSessionStartingAsync, ConsumeAsync, OnTestSessionFinishingAsync (the finishing method spans lines ~169–296, building the summary content)
- Retry/upload helpers:
AppendStepSummaryWithRetryAsync (line 296) and UpsertStepSummaryWithRetryAsync (line 334) — handle writing/upserting content to the GITHUB_STEP_SUMMARY file with retry logic
- Markdown rendering:
AppendModuleMarkdown (line 603) — a static helper that formats a CiRunSummaryModule into markdown output
The class mixes test-session lifecycle orchestration, file I/O retry logic, and markdown formatting concerns in one file.
Refactoring Strategy
Proposed File Splits
-
GitHubActionsSummaryReporter.cs (retain, trimmed)
- Contents: Class declaration,
IsEnabledAsync, OnTestSessionStartingAsync, ConsumeAsync, OnTestSessionFinishingAsync
- Responsibility: Core reporter lifecycle and orchestration of the GitHub Actions summary generation
-
GitHubActionsSummaryReporter.StepSummaryIO.cs (partial class)
- Contents:
AppendStepSummaryWithRetryAsync, UpsertStepSummaryWithRetryAsync
- Responsibility: Retry-aware file I/O for writing/upserting the
GITHUB_STEP_SUMMARY file
-
GitHubActionsSummaryReporter.Markdown.cs (partial class or static helper class)
- Contents:
AppendModuleMarkdown and any related markdown-formatting helpers
- Responsibility: Rendering
CiRunSummaryModule data into markdown
Implementation Guidelines
- Preserve Behavior: All existing functionality must work identically after the split
- Maintain Public API: Keep exported/public symbols accessible with the same names
- Update Imports: Fix all import paths throughout the codebase
- Test After Each Split: Run the test suite after each incremental change
- One File at a Time: Split one module at a time to make review easier
Acceptance Criteria
Priority: Medium
Effort: Small
Expected Impact: Improved code navigability, easier testing, reduced merge conflicts
🤖 Automated content by GitHub Copilot. Generated by the Daily File Diet workflow. · auto · 30.9 AIC · ⌖ 3.65 AIC · ⊞ 11.4K · [◷]( · ◷)
Overview
The file
src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/GitHubActionsSummaryReporter.cshas grown to 661 lines, making it harder to navigate and maintain. This task involves refactoring it into smaller, more focused files.Note:
XxHashShared.cs(925 lines) andJsonReader.cs(691 lines) were also identified as large files but are excluded — they are verbatim/ported vendored code fromdotnet/runtimeand a third-party library (Jsonite), respectively, so refactoring them is out of scope.Current State
src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/GitHubActionsSummaryReporter.csStructural Analysis
The file defines a single
internal sealed class GitHubActionsSummaryReporterimplementingIDataConsumer,IDataProducer,ITestSessionLifetimeHandler, andIOutputDeviceDataProducer. Key members include:IsEnabledAsync,OnTestSessionStartingAsync,ConsumeAsync,OnTestSessionFinishingAsync(the finishing method spans lines ~169–296, building the summary content)AppendStepSummaryWithRetryAsync(line 296) andUpsertStepSummaryWithRetryAsync(line 334) — handle writing/upserting content to theGITHUB_STEP_SUMMARYfile with retry logicAppendModuleMarkdown(line 603) — a static helper that formats aCiRunSummaryModuleinto markdown outputThe class mixes test-session lifecycle orchestration, file I/O retry logic, and markdown formatting concerns in one file.
Refactoring Strategy
Proposed File Splits
GitHubActionsSummaryReporter.cs(retain, trimmed)IsEnabledAsync,OnTestSessionStartingAsync,ConsumeAsync,OnTestSessionFinishingAsyncGitHubActionsSummaryReporter.StepSummaryIO.cs(partial class)AppendStepSummaryWithRetryAsync,UpsertStepSummaryWithRetryAsyncGITHUB_STEP_SUMMARYfileGitHubActionsSummaryReporter.Markdown.cs(partial class or static helper class)AppendModuleMarkdownand any related markdown-formatting helpersCiRunSummaryModuledata into markdownImplementation Guidelines
Acceptance Criteria
Priority: Medium
Effort: Small
Expected Impact: Improved code navigability, easier testing, reduced merge conflicts