A GitHub Action that aggregates Pester code coverage reports and generates a detailed summary with coverage statistics. Fails the workflow if coverage falls below specified targets.
This GitHub Action is a part of the PSModule framework. It is recommended to use the Process-PSModule workflow to automate the whole process of managing the PowerShell module.
- Combines multiple code coverage reports from parallel test runs
- Generates markdown/HTML tables showing missed & executed commands
- Displays analyzed files and coverage statistics
- Configurable step summary sections
- Threshold enforcement for minimum code coverage
Name | Description | Required | Default |
---|---|---|---|
Debug |
Enable debug output | No | false |
Verbose |
Enable verbose output | No | false |
Version |
Exact version of GitHub module to install | No | Latest |
Prerelease |
Allow prerelease versions | No | false |
WorkingDirectory |
Working directory for the action | No | . |
StepSummary_Mode |
Controls which sections to show in the GitHub step summary. Use 'Full' for all sections, 'None' to disable, or a comma-separated list of 'Missed, Executed, Files'. | No | Missed, Files |
CodeCoveragePercentTarget |
Target code coverage percentage | No | Max target from individual reports |
- name: Process Code Coverage
uses: PSModule/Get-PesterCodeCoverage@v1
with:
StepSummary_Mode: Full
CodeCoveragePercentTarget: 80
The action generates a detailed summary visible in the GitHub Actions UI:
-
Coverage Overview Table
- Coverage percentage vs target
- Analyzed/executed/missed command counts
- Number of files analyzed
-
Expandable Sections
- Missed Commands: HTML table with code snippets
- Executed Commands: HTML table with code snippets
- Analyzed Files: List of covered files
Example summary:
✅ Code Coverage Report
Summary:
| Coverage | Target | Analyzed | Executed | Missed | Files |
|----------|--------|---------------|---------------|---------------|---------------|
| 85% | 80% | 1000 commands | 850 commands | 150 commands | 15 files |
▶️ Missed commands [150] (click to expand)
▶️ Executed commands [850] (click to expand)
▶️ Files analyzed [15] (click to expand)
-
Pester Code Coverage Reports Preceding steps must generate JSON coverage reports named
*-CodeCoverage*.json
-
GitHub CLI The action uses
gh run download
to fetch artifacts from the current workflow run
-
Coverage Calculation
- Combines multiple coverage reports
- Removes duplicate entries
- Calculates aggregate coverage percentage
-
Threshold Enforcement Fails the workflow if coverage is below either:
- Explicitly specified
CodeCoveragePercentTarget
- Highest target from individual reports (if no target specified)
- Explicitly specified
-
Output Control Configure visibility of sections using
StepSummary_Mode
:# Show all sections StepSummary_Mode: Full # Disable summary StepSummary_Mode: None # Custom selection StepSummary_Mode: Missed, Files
Enable debugging by setting inputs:
with:
Debug: true
Verbose: true