Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ jobs:
| `Path` | Path to where tests are located or a configuration file. | *(none)* |
| `ReportAsJson` | Output generated reports in JSON format in addition to the configured format through Pester. | `true` |
| `Prescript` | Script to be executed before the test run. This script is executed in the same context as the test run. | *(none)* |
| `Notice_Mode` | Controls when to show notices for test completion. Allows "Full" (show on success and failure), "Failed" (show only on failure), or "None" (disable notices). | `Failed` |
| `StepSummary_Mode` | Controls which tests to show in the GitHub step summary. Allows "Full" (all tests), "Failed" (only failed tests), or "None" (disable step summary). | `Failed` |
| `StepSummary_ShowTestOverview` | Controls whether to show the test overview table in the GitHub step summary. | `false` |
| `StepSummary_ShowConfiguration` | Controls whether to show the configuration details in the GitHub step summary. | `false` |
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ inputs:
description: |
Script to be executed before the test run. This script is executed in the same context as the test run.
required: false
Notice_Mode:
description: |
Controls when to show notices for test completion. Allows "Full" (show on success and failure), "Failed" (show only on failure), or "None" (disable notices).
required: false
default: 'Failed'
StepSummary_Mode:
description: |
Controls which tests to show in the GitHub step summary. Allows "Full" (show all tests), "Failed" (only failed tests), or "None" (disable step summary).
Expand Down Expand Up @@ -344,6 +349,7 @@ runs:
working-directory: ${{ inputs.WorkingDirectory }}
env:
PSMODULE_INVOKE_PESTER_INPUT_ReportAsJson: ${{ inputs.ReportAsJson }}
PSMODULE_INVOKE_PESTER_INPUT_Notice_Mode: ${{ inputs.Notice_Mode }}
PSMODULE_INVOKE_PESTER_INPUT_StepSummary_Mode: ${{ inputs.StepSummary_Mode }}
PSMODULE_INVOKE_PESTER_INPUT_StepSummary_ShowTestOverview: ${{ inputs.StepSummary_ShowTestOverview }}
PSMODULE_INVOKE_PESTER_INPUT_StepSummary_ShowConfiguration: ${{ inputs.StepSummary_ShowConfiguration }}
Expand Down
17 changes: 14 additions & 3 deletions scripts/exec.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,34 @@ $codeCoverageOutputFolderPath = $testResults.Configuration.CodeCoverage.OutputPa
"TotalCount=$($testResults.TotalCount)" >> $env:GITHUB_OUTPUT

if ($env:PSMODULE_INVOKE_PESTER_INPUT_ReportAsJson -eq 'true' -and $testResults.Configuration.TestResult.Enabled.Value) {
$jsonOutputPath = $testResults.Configuration.TestResult.OutputPath.Value -Replace '\.xml$', '.json'
$jsonOutputPath = $testResults.Configuration.TestResult.OutputPath.Value -replace '\.xml$', '.json'
Write-Output "Exporting test results to [$jsonOutputPath]"
$testResults | Get-PesterTestTree | ConvertTo-Json -Depth 100 -Compress | Out-File -FilePath $jsonOutputPath
}

if ($env:PSMODULE_INVOKE_PESTER_INPUT_ReportAsJson -eq 'true' -and $testResults.Configuration.CodeCoverage.Enabled.Value) {
$jsonOutputPath = $testResults.Configuration.CodeCoverage.OutputPath.Value -Replace '\.xml$', '.json'
$jsonOutputPath = $testResults.Configuration.CodeCoverage.OutputPath.Value -replace '\.xml$', '.json'
Write-Output "Exporting code coverage results to [$jsonOutputPath]"
$testResults.CodeCoverage | ConvertTo-Json -Depth 100 -Compress | Out-File -FilePath $jsonOutputPath
}
'::endgroup::'

'::group::Exit'
$noticeMode = $env:PSMODULE_INVOKE_PESTER_INPUT_Notice_Mode
$failedTests = $testResults.FailedCount
if ($testResults.Result -eq 'Passed') {
'::notice::✅ All tests passed.'
if ($noticeMode -eq 'Full') {
'::notice::✅ All tests passed.'
}
$script:exit = 0
} else {
if ($noticeMode -in @('Full', 'Failed')) {
if ($failedTests -gt 0) {
"::notice::❌ Some [$failedTests] tests failed."
} else {
'::notice::❌ Some tests failed.'
}
}
if ($failedTests -gt 0) {
"::error::❌ Some [$failedTests] tests failed."
$script:exit = $failedTests
Expand Down
Loading