Skip to content

Commit 03e40bf

Browse files
🚀 [Feature]: Add more inputs outputs from Pester (#14)
## Description This pull request includes significant changes to the GitHub Actions workflow and configuration files. The key updates involve simplifying the workflow script, adding new input and outputs, and updating documentation to reflect these changes. ### Simplification of Workflow Script: * [`.github/workflows/Action-Test.yml`](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4L141-R142): Replaced the detailed PowerShell script for aggregating job statuses with a single line calling a new script `Get-AggregatedStatus.ps1`. ### Addition of New Inputs and Outputs: * [`action.yml`](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6L38-R249): Added multiple new input parameters to control various aspects of the test run and reporting, such as JSON report output, GitHub step summary options, code coverage settings, and test result configurations. ### Documentation Updates: * [`README.md`](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L19-R84): Updated to include descriptions of the new input parameters and outputs, providing detailed information on their usage and default values. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 6e5d4df commit 03e40bf

File tree

4 files changed

+431
-124
lines changed

4 files changed

+431
-124
lines changed

.github/workflows/Action-Test.yml

Lines changed: 5 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -134,117 +134,12 @@ jobs:
134134
ActionTestOutputsOutcome: ${{ needs.ActionTestOutputs.outputs.Outcome }}
135135
ActionTestOutputsConclusion: ${{ needs.ActionTestOutputs.outputs.Conclusion }}
136136
steps:
137+
- name: Checkout repo
138+
uses: actions/checkout@v4
139+
137140
- name: Aggregated Status
138141
uses: PSModule/Github-Script@v1
139142
with:
140143
Script: |
141-
'Markdown' | ForEach-Object {
142-
$name = $_
143-
Write-Output "Installing module: $name"
144-
$retryCount = 5
145-
$retryDelay = 10
146-
for ($i = 0; $i -lt $retryCount; $i++) {
147-
try {
148-
Install-PSResource -Name $name -WarningAction SilentlyContinue -TrustRepository -Repository PSGallery
149-
break
150-
} catch {
151-
Write-Warning "Installation of $name failed with error: $_"
152-
if ($i -eq $retryCount - 1) {
153-
throw
154-
}
155-
Write-Warning "Retrying in $retryDelay seconds..."
156-
Start-Sleep -Seconds $retryDelay
157-
}
158-
}
159-
Import-Module -Name $name
160-
}
161-
162-
# Build an array of objects for each job
163-
$ActionTestSrcSourceCodeExpectedOutcome = 'success'
164-
$ActionTestSrcSourceCodeOutcomeResult = $env:ActionTestSrcSourceCodeOutcome -eq $ActionTestSrcSourceCodeExpectedOutcome
165-
$ActionTestSrcSourceCodeExpectedConclusion = 'success'
166-
$ActionTestSrcSourceCodeConclusionResult = $env:ActionTestSrcSourceCodeConclusion -eq $ActionTestSrcSourceCodeExpectedConclusion
167-
168-
$ActionTestSrcCustomExpectedOutcome = 'success'
169-
$ActionTestSrcCustomOutcomeResult = $env:ActionTestSrcCustomOutcome -eq $ActionTestSrcCustomExpectedOutcome
170-
$ActionTestSrcCustomExpectedConclusion = 'success'
171-
$ActionTestSrcCustomConclusionResult = $env:ActionTestSrcCustomConclusion -eq $ActionTestSrcCustomExpectedConclusion
172-
173-
$ActionTestSrcWithManifestExpectedOutcome = 'failure'
174-
$ActionTestSrcWithManifestOutcomeResult = $env:ActionTestSrcWithManifestOutcome -eq $ActionTestSrcWithManifestExpectedOutcome
175-
$ActionTestSrcWithManifestExpectedConclusion = 'success'
176-
$ActionTestSrcWithManifestConclusionResult = $env:ActionTestSrcWithManifestConclusion -eq $ActionTestSrcWithManifestExpectedConclusion
177-
178-
$ActionTestOutputsExpectedOutcome = 'success'
179-
$ActionTestOutputsOutcomeResult = $env:ActionTestOutputsOutcome -eq $ActionTestOutputsExpectedOutcome
180-
$ActionTestOutputsExpectedConclusion = 'success'
181-
$ActionTestOutputsConclusionResult = $env:ActionTestOutputsConclusion -eq $ActionTestOutputsExpectedConclusion
182-
183-
$jobs = @(
184-
[PSCustomObject]@{
185-
Name = 'Action-Test - [Src-SourceCode]'
186-
Outcome = $env:ActionTestSrcSourceCodeOutcome
187-
ExpectedOutcome = $ActionTestSrcSourceCodeExpectedOutcome
188-
PassedOutcome = $ActionTestSrcSourceCodeOutcomeResult
189-
Conclusion = $env:ActionTestSrcSourceCodeConclusion
190-
ExpectedConclusion = $ActionTestSrcSourceCodeExpectedConclusion
191-
PassedConclusion = $ActionTestSrcSourceCodeConclusionResult
192-
},
193-
[PSCustomObject]@{
194-
Name = 'Action-Test - [Src-Custom]'
195-
Outcome = $env:ActionTestSrcCustomOutcome
196-
ExpectedOutcome = $ActionTestSrcCustomExpectedOutcome
197-
PassedOutcome = $ActionTestSrcCustomOutcomeResult
198-
Conclusion = $env:ActionTestSrcCustomConclusion
199-
ExpectedConclusion = $ActionTestSrcCustomExpectedConclusion
200-
PassedConclusion = $ActionTestSrcCustomConclusionResult
201-
},
202-
[PSCustomObject]@{
203-
Name = 'Action-Test - [Src-WithManifest]'
204-
Outcome = $env:ActionTestSrcWithManifestOutcome
205-
ExpectedOutcome = $ActionTestSrcWithManifestExpectedOutcome
206-
PassedOutcome = $ActionTestSrcWithManifestOutcomeResult
207-
Conclusion = $env:ActionTestSrcWithManifestConclusion
208-
ExpectedConclusion = $ActionTestSrcWithManifestExpectedConclusion
209-
PassedConclusion = $ActionTestSrcWithManifestConclusionResult
210-
},
211-
[PSCustomObject]@{
212-
Name = 'Action-Test - [outputs]'
213-
Outcome = $env:ActionTestOutputsOutcome
214-
ExpectedOutcome = $ActionTestOutputsExpectedOutcome
215-
PassedOutcome = $ActionTestOutputsOutcomeResult
216-
Conclusion = $env:ActionTestOutputsConclusion
217-
ExpectedConclusion = $ActionTestOutputsExpectedConclusion
218-
PassedConclusion = $ActionTestOutputsConclusionResult
219-
}
220-
)
221-
222-
# Display the table in the workflow logs
223-
$jobs | Format-List
224-
225-
$passed = $true
226-
$jobs | ForEach-Object {
227-
if (-not $_.PassedOutcome) {
228-
Write-Error "Job $($_.Name) failed with Outcome $($_.Outcome) and Expected Outcome $($_.ExpectedOutcome)"
229-
$passed = $false
230-
}
231-
232-
if (-not $_.PassedConclusion) {
233-
Write-Error "Job $($_.Name) failed with Conclusion $($_.Conclusion) and Expected Conclusion $($_.ExpectedConclusion)"
234-
$passed = $false
235-
}
236-
}
237-
238-
$icon = if ($passed) { '✅' } else { '❌' }
239-
$status = Heading 1 "$icon - GitHub Actions Status" {
240-
Table {
241-
$jobs
242-
}
243-
}
244-
245-
Set-GitHubStepSummary -Summary $status
246-
247-
if (-not $passed) {
248-
Write-GitHubError 'One or more jobs failed'
249-
exit 1
250-
}
144+
# Aggregated Status
145+
tests/Get-AggregatedStatus.ps1

README.md

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,73 @@ customize rule selection, severity filtering, and custom rule inclusion.
1515

1616
## Inputs
1717

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

2967
## Outputs
3068

31-
N/A
69+
The action provides the following outputs:
70+
71+
| Output | Description |
72+
|-------------------------|--------------------------------------------------|
73+
| `Outcome` | The outcome of the test run (success/failure) |
74+
| `Conclusion` | The conclusion of the test run (success/failure) |
75+
| `Executed` | Whether tests were executed (True/False) |
76+
| `Result` | Overall result of the test run (Passed/Failed) |
77+
| `FailedCount` | Number of failed tests |
78+
| `FailedBlocksCount` | Number of failed blocks |
79+
| `FailedContainersCount` | Number of failed containers |
80+
| `PassedCount` | Number of passed tests |
81+
| `SkippedCount` | Number of skipped tests |
82+
| `InconclusiveCount` | Number of inconclusive tests |
83+
| `NotRunCount` | Number of tests not run |
84+
| `TotalCount` | Total count of tests |
3285

3386
## How It Works
3487

0 commit comments

Comments
 (0)