Skip to content

[file-diet] Refactor GitHubActionsSummaryReporter.cs (661 lines) into focused modules #10561

Description

@github-actions

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

  1. GitHubActionsSummaryReporter.cs (retain, trimmed)

    • Contents: Class declaration, IsEnabledAsync, OnTestSessionStartingAsync, ConsumeAsync, OnTestSessionFinishingAsync
    • Responsibility: Core reporter lifecycle and orchestration of the GitHub Actions summary generation
  2. GitHubActionsSummaryReporter.StepSummaryIO.cs (partial class)

    • Contents: AppendStepSummaryWithRetryAsync, UpsertStepSummaryWithRetryAsync
    • Responsibility: Retry-aware file I/O for writing/upserting the GITHUB_STEP_SUMMARY file
  3. 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

  1. Preserve Behavior: All existing functionality must work identically after the split
  2. Maintain Public API: Keep exported/public symbols accessible with the same names
  3. Update Imports: Fix all import paths throughout the codebase
  4. Test After Each Split: Run the test suite after each incremental change
  5. One File at a Time: Split one module at a time to make review easier

Acceptance Criteria

  • Original file is split into focused modules
  • Each new file is under 300 lines
  • All tests pass after refactoring
  • No breaking changes to public API
  • All import paths updated correctly

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 · [◷]( · )

  • expires on Aug 13, 2026, 7:17 PM UTC

Metadata

Metadata

Labels

type/automationCreated or maintained by an agentic workflow.type/tech-debtCode health, refactoring, simplification.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions