Skip to content

🚀 [Feature]: Add more inputs outputs from Pester #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 9, 2025
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
115 changes: 5 additions & 110 deletions .github/workflows/Action-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,117 +134,12 @@ jobs:
ActionTestOutputsOutcome: ${{ needs.ActionTestOutputs.outputs.Outcome }}
ActionTestOutputsConclusion: ${{ needs.ActionTestOutputs.outputs.Conclusion }}
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Aggregated Status
uses: PSModule/Github-Script@v1
with:
Script: |
'Markdown' | ForEach-Object {
$name = $_
Write-Output "Installing module: $name"
$retryCount = 5
$retryDelay = 10
for ($i = 0; $i -lt $retryCount; $i++) {
try {
Install-PSResource -Name $name -WarningAction SilentlyContinue -TrustRepository -Repository PSGallery
break
} catch {
Write-Warning "Installation of $name failed with error: $_"
if ($i -eq $retryCount - 1) {
throw
}
Write-Warning "Retrying in $retryDelay seconds..."
Start-Sleep -Seconds $retryDelay
}
}
Import-Module -Name $name
}

# Build an array of objects for each job
$ActionTestSrcSourceCodeExpectedOutcome = 'success'
$ActionTestSrcSourceCodeOutcomeResult = $env:ActionTestSrcSourceCodeOutcome -eq $ActionTestSrcSourceCodeExpectedOutcome
$ActionTestSrcSourceCodeExpectedConclusion = 'success'
$ActionTestSrcSourceCodeConclusionResult = $env:ActionTestSrcSourceCodeConclusion -eq $ActionTestSrcSourceCodeExpectedConclusion

$ActionTestSrcCustomExpectedOutcome = 'success'
$ActionTestSrcCustomOutcomeResult = $env:ActionTestSrcCustomOutcome -eq $ActionTestSrcCustomExpectedOutcome
$ActionTestSrcCustomExpectedConclusion = 'success'
$ActionTestSrcCustomConclusionResult = $env:ActionTestSrcCustomConclusion -eq $ActionTestSrcCustomExpectedConclusion

$ActionTestSrcWithManifestExpectedOutcome = 'failure'
$ActionTestSrcWithManifestOutcomeResult = $env:ActionTestSrcWithManifestOutcome -eq $ActionTestSrcWithManifestExpectedOutcome
$ActionTestSrcWithManifestExpectedConclusion = 'success'
$ActionTestSrcWithManifestConclusionResult = $env:ActionTestSrcWithManifestConclusion -eq $ActionTestSrcWithManifestExpectedConclusion

$ActionTestOutputsExpectedOutcome = 'success'
$ActionTestOutputsOutcomeResult = $env:ActionTestOutputsOutcome -eq $ActionTestOutputsExpectedOutcome
$ActionTestOutputsExpectedConclusion = 'success'
$ActionTestOutputsConclusionResult = $env:ActionTestOutputsConclusion -eq $ActionTestOutputsExpectedConclusion

$jobs = @(
[PSCustomObject]@{
Name = 'Action-Test - [Src-SourceCode]'
Outcome = $env:ActionTestSrcSourceCodeOutcome
ExpectedOutcome = $ActionTestSrcSourceCodeExpectedOutcome
PassedOutcome = $ActionTestSrcSourceCodeOutcomeResult
Conclusion = $env:ActionTestSrcSourceCodeConclusion
ExpectedConclusion = $ActionTestSrcSourceCodeExpectedConclusion
PassedConclusion = $ActionTestSrcSourceCodeConclusionResult
},
[PSCustomObject]@{
Name = 'Action-Test - [Src-Custom]'
Outcome = $env:ActionTestSrcCustomOutcome
ExpectedOutcome = $ActionTestSrcCustomExpectedOutcome
PassedOutcome = $ActionTestSrcCustomOutcomeResult
Conclusion = $env:ActionTestSrcCustomConclusion
ExpectedConclusion = $ActionTestSrcCustomExpectedConclusion
PassedConclusion = $ActionTestSrcCustomConclusionResult
},
[PSCustomObject]@{
Name = 'Action-Test - [Src-WithManifest]'
Outcome = $env:ActionTestSrcWithManifestOutcome
ExpectedOutcome = $ActionTestSrcWithManifestExpectedOutcome
PassedOutcome = $ActionTestSrcWithManifestOutcomeResult
Conclusion = $env:ActionTestSrcWithManifestConclusion
ExpectedConclusion = $ActionTestSrcWithManifestExpectedConclusion
PassedConclusion = $ActionTestSrcWithManifestConclusionResult
},
[PSCustomObject]@{
Name = 'Action-Test - [outputs]'
Outcome = $env:ActionTestOutputsOutcome
ExpectedOutcome = $ActionTestOutputsExpectedOutcome
PassedOutcome = $ActionTestOutputsOutcomeResult
Conclusion = $env:ActionTestOutputsConclusion
ExpectedConclusion = $ActionTestOutputsExpectedConclusion
PassedConclusion = $ActionTestOutputsConclusionResult
}
)

# Display the table in the workflow logs
$jobs | Format-List

$passed = $true
$jobs | ForEach-Object {
if (-not $_.PassedOutcome) {
Write-Error "Job $($_.Name) failed with Outcome $($_.Outcome) and Expected Outcome $($_.ExpectedOutcome)"
$passed = $false
}

if (-not $_.PassedConclusion) {
Write-Error "Job $($_.Name) failed with Conclusion $($_.Conclusion) and Expected Conclusion $($_.ExpectedConclusion)"
$passed = $false
}
}

$icon = if ($passed) { '✅' } else { '❌' }
$status = Heading 1 "$icon - GitHub Actions Status" {
Table {
$jobs
}
}

Set-GitHubStepSummary -Summary $status

if (-not $passed) {
Write-GitHubError 'One or more jobs failed'
exit 1
}
# Aggregated Status
tests/Get-AggregatedStatus.ps1
75 changes: 64 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,73 @@ customize rule selection, severity filtering, and custom rule inclusion.

## Inputs

| Input | Description | Required | Default |
|--------------------|----------------------------------------------------------------|----------|-----------------------------------------------------------------------------|
| `Path` | The path to the code to test. | false | `'.'` |
| `Settings` | The type of tests to run: `Module`, `SourceCode`, or `Custom`. | false | `Custom` |
| `SettingsFilePath` | If `Custom` is selected, the path to the settings file. | false | `${{ github.workspace }}/.github/linters/.powershell-psscriptanalyzer.psd1` |
| `Debug` | Enable debug output. | false | `'false'` |
| `Verbose` | Enable verbose output. | false | `'false'` |
| `Version` | Specifies the exact version of the GitHub module to install. | false | |
| `Prerelease` | Allow prerelease versions if available. | false | `'false'` |
| `WorkingDirectory` | The working directory where the script runs. | false | `${{ github.workspace }}` |
| Input | Description | Required | Default |
|--------------------------------------|--------------------------------------------------------------------------------|----------|-----------------------------------------------------------------------------|
| `Path` | The path to the code to test. | false | `'.'` |
| `Settings` | The type of tests to run: `Module`, `SourceCode`, or `Custom`. | false | `Custom` |
| `SettingsFilePath` | If `Custom` is selected, the path to the settings file. | false | `${{ github.workspace }}/.github/linters/.powershell-psscriptanalyzer.psd1` |
| `Debug` | Enable debug output. | false | `'false'` |
| `Verbose` | Enable verbose output. | false | `'false'` |
| `Version` | Specifies the exact version of the GitHub module to install. | false | |
| `Prerelease` | Allow prerelease versions if available. | false | `'false'` |
| `WorkingDirectory` | The working directory where the script runs. | false | `'.'` |
| `ReportAsJson` | Output generated reports in JSON format in addition to the configured format. | false | `'true'` |
| `StepSummary_Enabled` | Controls if a GitHub step summary should be shown. | false | `'true'` |
| `StepSummary_ShowTestOverview` | Controls whether to show the test overview table in the GitHub step summary. | false | `'true'` |
| `StepSummary_ShowTests` | Controls which tests to show in the GitHub step summary (Full/Failed/None). | false | `'Failed'` |
| `StepSummary_ShowConfiguration` | Controls whether to show the configuration details in the GitHub step summary. | false | `'false'` |
| `Run_ExcludePath` | Directories or files to be excluded from the run. | false | |
| `Run_Exit` | Exit with non-zero exit code when the test run fails. | false | |
| `Run_Throw` | Throw an exception when test run fails. | false | |
| `Run_SkipRun` | Runs the discovery phase but skips run. | false | |
| `Run_SkipRemainingOnFailure` | Skips remaining tests after failure (None/Run/Container/Block). | false | |
| `CodeCoverage_Enabled` | Enable CodeCoverage. | false | |
| `CodeCoverage_OutputFormat` | Format to use for code coverage report (JaCoCo/CoverageGutters/Cobertura). | false | |
| `CodeCoverage_OutputPath` | Path relative to the current directory where code coverage report is saved. | false | |
| `CodeCoverage_OutputEncoding` | Encoding of the output file. | false | |
| `CodeCoverage_Path` | Directories or files to be used for code coverage. | false | |
| `CodeCoverage_ExcludeTests` | Exclude tests from code coverage. | false | |
| `CodeCoverage_RecursePaths` | Will recurse through directories in the Path option. | false | |
| `CodeCoverage_CoveragePercentTarget` | Target percent of code coverage that you want to achieve. | false | |
| `CodeCoverage_UseBreakpoints` | EXPERIMENTAL: Use Profiler based tracer instead of breakpoints when false. | false | |
| `CodeCoverage_SingleHitBreakpoints` | Remove breakpoint when it is hit. | false | |
| `TestResult_Enabled` | Enable TestResult. | false | |
| `TestResult_OutputFormat` | Format to use for test result report (NUnitXml/NUnit2.5/NUnit3/JUnitXml). | false | |
| `TestResult_OutputPath` | Path relative to the current directory where test result report is saved. | false | |
| `TestResult_OutputEncoding` | Encoding of the output file. | false | |
| `TestResult_TestSuiteName` | Set the name assigned to the root 'test-suite' element. | false | `PSScriptAnalyzer` |
| `Should_ErrorAction` | Controls if Should throws on error. Use 'Stop' or 'Continue'. | false | |
| `Debug_ShowFullErrors` | Show full errors including Pester internal stack. | false | |
| `Debug_WriteDebugMessages` | Write Debug messages to screen. | false | |
| `Debug_WriteDebugMessagesFrom` | Write Debug messages from a given source. | false | |
| `Debug_ShowNavigationMarkers` | Write paths after every block and test, for easy navigation. | false | |
| `Debug_ReturnRawResultObject` | Returns unfiltered result object, for development only. | false | |
| `Output_Verbosity` | The verbosity of output (None/Normal/Detailed/Diagnostic). | false | |
| `Output_StackTraceVerbosity` | The verbosity of stacktrace output (None/FirstLine/Filtered/Full). | false | |
| `Output_CIFormat` | The CI format of error output (None/Auto/AzureDevops/GithubActions). | false | |
| `Output_CILogLevel` | The CI log level in build logs (Error/Warning). | false | |
| `Output_RenderMode` | The mode used to render console output (Auto/Ansi/ConsoleColor/Plaintext). | false | |
| `TestDrive_Enabled` | Enable TestDrive. | false | |
| `TestRegistry_Enabled` | Enable TestRegistry. | false | |

## Outputs

N/A
The action provides the following outputs:

| Output | Description |
|-------------------------|--------------------------------------------------|
| `Outcome` | The outcome of the test run (success/failure) |
| `Conclusion` | The conclusion of the test run (success/failure) |
| `Executed` | Whether tests were executed (True/False) |
| `Result` | Overall result of the test run (Passed/Failed) |
| `FailedCount` | Number of failed tests |
| `FailedBlocksCount` | Number of failed blocks |
| `FailedContainersCount` | Number of failed containers |
| `PassedCount` | Number of passed tests |
| `SkippedCount` | Number of skipped tests |
| `InconclusiveCount` | Number of inconclusive tests |
| `NotRunCount` | Number of tests not run |
| `TotalCount` | Total count of tests |

## How It Works

Expand Down
Loading
Loading