Skip to content

Commit 993d539

Browse files
🚀 [Feature]: Add options to configure step summary for a test (#34)
## Description This pull request includes several updates to the GitHub Actions workflow and related documentation to enhance the reporting and summary capabilities for test results. The most important changes include the addition of new job configurations, updates to the `README.md` file, and modifications to the `action.yml` and `scripts/Helpers.psm1` files. Enhancements to GitHub Actions workflow: * [`.github/workflows/Action-Test.yml`](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R66-R96): Added new job configurations for `ActionTest1SimpleFailureOnlyFailedSummary` and `ActionTest2StandardNoSummary`, including steps to enable detailed step summaries and status outputs. [[1]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R66-R96) [[2]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R151-R180) [[3]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4L155-R223) [[4]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R261-R273) [[5]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R300-R312) [[6]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R357-R371) [[7]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R402-R416) Updates to documentation: * [`README.md`](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R266-R269): Added new configuration options for controlling the GitHub step summary, including `StepSummary_Enabled`, `StepSummary_ShowTestOverview`, `StepSummary_ShowTests`, and `StepSummary_ShowConfiguration`. Also updated the default values for `Debug`, `Verbose`, `Prerelease`, and `WorkingDirectory` options. [[1]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R266-R269) [[2]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L308-R316) Modifications to action configuration: * [`action.yml`](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6R18-R37): Added new input parameters for controlling the GitHub step summary and updated the environment variables to include these new parameters. [[1]](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6R18-R37) [[2]](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6R347-R350) [[3]](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6L360-R384) Enhancements to helper scripts: * [`scripts/Helpers.psm1`](diffhunk://#diff-acb1351e3ba396afa6a397b0bd44b5d8ed3ffeb97a3f3ef3633e9cfd6cacf11aR822-R869): Updated the `Set-PesterReportSummary` and `Set-PesterReportTestsSummary` filters to include new parameters for controlling the display of test overview, test details, and configuration in the summary. Added logic to filter tests based on the specified mode (Full, Failed, None). [[1]](diffhunk://#diff-acb1351e3ba396afa6a397b0bd44b5d8ed3ffeb97a3f3ef3633e9cfd6cacf11aR822-R869) [[2]](diffhunk://#diff-acb1351e3ba396afa6a397b0bd44b5d8ed3ffeb97a3f3ef3633e9cfd6cacf11aL911-R983) [[3]](diffhunk://#diff-acb1351e3ba396afa6a397b0bd44b5d8ed3ffeb97a3f3ef3633e9cfd6cacf11aL947-R992) ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [x] 🚀 [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 42d2652 commit 993d539

7 files changed

Lines changed: 259 additions & 48 deletions

File tree

.github/workflows/Action-Test.yml

Lines changed: 121 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Action-Test
22

3-
run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
3+
run-name: 'Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}'
44

55
on:
66
workflow_dispatch:
@@ -63,6 +63,37 @@ jobs:
6363
continue-on-error: true
6464
with:
6565
WorkingDirectory: tests/1-Simple-Failure
66+
StepSummary_Enabled: true
67+
StepSummary_ShowTests: Full
68+
69+
- name: Status
70+
shell: pwsh
71+
run: |
72+
Write-Host "Outcome: ${{ steps.action-test.outcome }}"
73+
Write-Host "Conclusion: ${{ steps.action-test.conclusion }}"
74+
75+
ActionTest1SimpleFailureOnlyFailedSummary:
76+
name: Action-Test - [1-Simple-Failure-OnlyFailedSummary]
77+
runs-on: ubuntu-latest
78+
outputs:
79+
Outcome: ${{ steps.action-test.outcome }}
80+
Conclusion: ${{ steps.action-test.conclusion }}
81+
Executed: ${{ steps.action-test.outputs.Executed }}
82+
Result: ${{ steps.action-test.outputs.Result }}
83+
84+
steps:
85+
# Need to check out as part of the test, as its a local action
86+
- name: Checkout repo
87+
uses: actions/checkout@v4
88+
89+
- name: Action-Test [1-Simple-Failure]
90+
uses: ./
91+
id: action-test
92+
continue-on-error: true
93+
with:
94+
WorkingDirectory: tests/1-Simple-Failure
95+
TestResult_TestSuiteName: 1-Simple-Failure
96+
StepSummary_Enabled: true
6697

6798
- name: Status
6899
shell: pwsh
@@ -117,6 +148,36 @@ jobs:
117148
with:
118149
WorkingDirectory: tests/2-Standard
119150
Output_CIFormat: GithubActions
151+
StepSummary_Enabled: true
152+
StepSummary_ShowTests: Failed
153+
154+
- name: Status
155+
shell: pwsh
156+
run: |
157+
Write-Host "Outcome: ${{ steps.action-test.outcome }}"
158+
Write-Host "Conclusion: ${{ steps.action-test.conclusion }}"
159+
160+
ActionTest2StandardNoSummary:
161+
name: Action-Test - [2-Standard-NoSummary]
162+
runs-on: ubuntu-latest
163+
outputs:
164+
Outcome: ${{ steps.action-test.outcome }}
165+
Conclusion: ${{ steps.action-test.conclusion }}
166+
Executed: ${{ steps.action-test.outputs.Executed }}
167+
Result: ${{ steps.action-test.outputs.Result }}
168+
169+
steps:
170+
# Need to check out as part of the test, as its a local action
171+
- name: Checkout repo
172+
uses: actions/checkout@v4
173+
174+
- name: Action-Test [2-Standard-NoSummary]
175+
uses: ./
176+
id: action-test
177+
with:
178+
WorkingDirectory: tests/2-Standard
179+
Output_CIFormat: GithubActions
180+
TestResult_TestSuiteName: 2-Standard-NoSummary
120181

121182
- name: Status
122183
shell: pwsh
@@ -152,12 +213,14 @@ jobs:
152213
Write-Host "Conclusion: ${{ steps.action-test.conclusion }}"
153214
154215
CatchJob:
155-
name: "Catch Job - Aggregate Status"
216+
name: Catch Job - Aggregate Status
156217
needs:
157218
- ActionTest1Simple
158219
- ActionTest1SimpleFailure
220+
- ActionTest1SimpleFailureOnlyFailedSummary
159221
- ActionTest1SimpleExecutionFailure
160222
- ActionTest2Standard
223+
- ActionTest2StandardNoSummary
161224
- ActionTest3Advanced
162225
if: always()
163226
runs-on: ubuntu-latest
@@ -195,6 +258,19 @@ jobs:
195258
$ActionTest1SimpleFailureResultExpected = 'Failed'
196259
$ActionTest1SimpleFailureResultResult = $ActionTest1SimpleFailureResult -eq $ActionTest1SimpleFailureResultExpected
197260
261+
$ActionTest1SimpleFailureOnlyFailedSummaryOutcome = '${{ needs.ActionTest1SimpleFailureOnlyFailedSummary.outputs.outcome }}'
262+
$ActionTest1SimpleFailureOnlyFailedSummaryOutcomeExpected = 'failure'
263+
$ActionTest1SimpleFailureOnlyFailedSummaryOutcomeResult = $ActionTest1SimpleFailureOnlyFailedSummaryOutcome -eq $ActionTest1SimpleFailureOnlyFailedSummaryOutcomeExpected
264+
$ActionTest1SimpleFailureOnlyFailedSummaryConclusion = '${{ needs.ActionTest1SimpleFailureOnlyFailedSummary.outputs.conclusion }}'
265+
$ActionTest1SimpleFailureOnlyFailedSummaryonclusionExpected = 'success'
266+
$ActionTest1SimpleFailureOnlyFailedSummaryonclusionResult = $ActionTest1SimpleFailureOnlyFailedSummaryConclusion -eq $ActionTest1SimpleFailureOnlyFailedSummaryonclusionExpected
267+
$ActionTest1SimpleFailureOnlyFailedSummaryExecuted = '${{ needs.ActionTest1SimpleFailureOnlyFailedSummary.outputs.Executed }}'
268+
$ActionTest1SimpleFailureOnlyFailedSummaryExecutedExpected = 'True'
269+
$ActionTest1SimpleFailureOnlyFailedSummaryExecutedResult = $ActionTest1SimpleFailureOnlyFailedSummaryExecuted -eq $ActionTest1SimpleFailureOnlyFailedSummaryExecutedExpected
270+
$ActionTest1SimpleFailureOnlyFailedSummaryResult = '${{ needs.ActionTest1SimpleFailureOnlyFailedSummary.outputs.Result }}'
271+
$ActionTest1SimpleFailureOnlyFailedSummaryResultExpected = 'Failed'
272+
$ActionTest1SimpleFailureOnlyFailedSummaryResultResult = $ActionTest1SimpleFailureOnlyFailedSummaryResult -eq $ActionTest1SimpleFailureOnlyFailedSummaryResultExpected
273+
198274
$ActionTest1SimpleExecutionFailureOutcome = '${{ needs.ActionTest1SimpleExecutionFailure.outputs.outcome }}'
199275
$ActionTest1SimpleExecutionFailureOutcomeExpected = 'failure'
200276
$ActionTest1SimpleExecutionFailureOutcomeResult = $ActionTest1SimpleExecutionFailureOutcome -eq $ActionTest1SimpleExecutionFailureOutcomeExpected
@@ -221,6 +297,19 @@ jobs:
221297
$ActionTest2StandardResultExpected = 'Passed'
222298
$ActionTest2StandardResultResult = $ActionTest2StandardResult -eq $ActionTest2StandardResultExpected
223299
300+
$ActionTest2StandardNoSummaryOutcome = '${{ needs.ActionTest2StandardNoSummary.outputs.outcome }}'
301+
$ActionTest2StandardNoSummaryOutcomeExpected = 'success'
302+
$ActionTest2StandardNoSummaryOutcomeResult = $ActionTest2StandardNoSummaryOutcome -eq $ActionTest2StandardNoSummaryOutcomeExpected
303+
$ActionTest2StandardNoSummaryConclusion = '${{ needs.ActionTest2StandardNoSummary.outputs.conclusion }}'
304+
$ActionTest2StandardNoSummaryConclusionExpected = 'success'
305+
$ActionTest2StandardNoSummaryConclusionResult = $ActionTest2StandardNoSummaryConclusion -eq $ActionTest2StandardNoSummaryConclusionExpected
306+
$ActionTest2StandardNoSummaryExecuted = '${{ needs.ActionTest2StandardNoSummary.outputs.Executed }}'
307+
$ActionTest2StandardNoSummaryExecutedExpected = 'True'
308+
$ActionTest2StandardNoSummaryExecutedResult = $ActionTest2StandardNoSummaryExecuted -eq $ActionTest2StandardNoSummaryExecutedExpected
309+
$ActionTest2StandardNoSummaryResult = '${{ needs.ActionTest2StandardNoSummary.outputs.Result }}'
310+
$ActionTest2StandardNoSummaryResultExpected = 'Passed'
311+
$ActionTest2StandardNoSummaryResultResult = $ActionTest2StandardNoSummaryResult -eq $ActionTest2StandardNoSummaryResultExpected
312+
224313
$ActionTest3AdvancedOutcome = '${{ needs.ActionTest3Advanced.outputs.outcome }}'
225314
$ActionTest3AdvancedOutcomeExpected = 'success'
226315
$ActionTest3AdvancedOutcomeResult = $ActionTest3AdvancedOutcome -eq $ActionTest3AdvancedOutcomeExpected
@@ -265,6 +354,21 @@ jobs:
265354
ResultExpected = $ActionTest1SimpleFailureResultExpected
266355
ResultResult = $ActionTest1SimpleFailureResultResult
267356
},
357+
[PSCustomObject]@{
358+
Name = "Action-Test - [1-Simple-Failure-OnlyFailedSummary]"
359+
Outcome = $ActionTest1SimpleFailureOnlyFailedSummaryOutcome
360+
OutcomeExpected = $ActionTest1SimpleFailureOnlyFailedSummaryOutcomeExpected
361+
OutcomeResult = $ActionTest1SimpleFailureOnlyFailedSummaryOutcomeResult
362+
Conclusion = $ActionTest1SimpleFailureOnlyFailedSummaryConclusion
363+
ConclusionExpected = $ActionTest1SimpleFailureOnlyFailedSummaryonclusionExpected
364+
ConclusionResult = $ActionTest1SimpleFailureOnlyFailedSummaryonclusionResult
365+
Executed = $ActionTest1SimpleFailureOnlyFailedSummaryExecuted
366+
ExecutedExpected = $ActionTest1SimpleFailureOnlyFailedSummaryExecutedExpected
367+
ExecutedResult = $ActionTest1SimpleFailureOnlyFailedSummaryExecutedResult
368+
Result = $ActionTest1SimpleFailureOnlyFailedSummaryResult
369+
ResultExpected = $ActionTest1SimpleFailureOnlyFailedSummaryResultExpected
370+
ResultResult = $ActionTest1SimpleFailureOnlyFailedSummaryResultResult
371+
},
268372
[PSCustomObject]@{
269373
Name = "Action-Test - [1-Simple-ExecutionFailure]"
270374
Outcome = $ActionTest1SimpleExecutionFailureOutcome
@@ -295,6 +399,21 @@ jobs:
295399
ResultExpected = $ActionTest2StandardResultExpected
296400
ResultResult = $ActionTest2StandardResultResult
297401
},
402+
[PSCustomObject]@{
403+
Name = "Action-Test - [2-Standard-NoSummary]"
404+
Outcome = $ActionTest2StandardNoSummaryOutcome
405+
OutcomeExpected = $ActionTest2StandardNoSummaryOutcomeExpected
406+
OutcomeResult = $ActionTest2StandardNoSummaryOutcomeResult
407+
Conclusion = $ActionTest2StandardNoSummaryConclusion
408+
ConclusionExpected = $ActionTest2StandardNoSummaryConclusionExpected
409+
ConclusionResult = $ActionTest2StandardNoSummaryConclusionResult
410+
Executed = $ActionTest2StandardNoSummaryExecuted
411+
ExecutedExpected = $ActionTest2StandardNoSummaryExecutedExpected
412+
ExecutedResult = $ActionTest2StandardNoSummaryExecutedResult
413+
Result = $ActionTest2StandardNoSummaryResult
414+
ResultExpected = $ActionTest2StandardNoSummaryResultExpected
415+
ResultResult = $ActionTest2StandardNoSummaryResultResult
416+
},
298417
[PSCustomObject]@{
299418
Name = "Action-Test - [3-Advanced]"
300419
Outcome = $ActionTest3AdvancedOutcome

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ jobs:
263263
|--------------------------------------|--------------------------------------------------------------------------------------------------------|-------------|
264264
| `Path` | Path to where tests are located or a configuration file. | *(none)* |
265265
| `ReportAsJson` | Output generated reports in JSON format in addition to the configured format through Pester. | `true` |
266+
| `StepSummary_Enabled` | Controls if a GitHub step summary should be shown. | `false` |
267+
| `StepSummary_ShowTestOverview` | Controls whether to show the test overview table in the GitHub step summary. | `true` |
268+
| `StepSummary_ShowTests` | Controls which tests to show in the GitHub step summary. Allows "Full", "Failed", or "None". | `Failed` |
269+
| `StepSummary_ShowConfiguration` | Controls whether to show the configuration details in the GitHub step summary. | `false` |
266270
| `Run_Path` | Directories/files to be searched for tests. | *(none)* |
267271
| `Run_ExcludePath` | Directories/files to exclude from the run. | *(none)* |
268272
| `Run_ScriptBlock` | ScriptBlocks containing tests to be executed. | *(none)* |
@@ -305,11 +309,11 @@ jobs:
305309
| `Output_RenderMode` | How to render console output: `Auto`, `Ansi`, `ConsoleColor`, `Plaintext`. | *(none)* |
306310
| `TestDrive_Enabled` | Enable `TestDrive`. | *(none)* |
307311
| `TestRegistry_Enabled` | Enable `TestRegistry`. | *(none)* |
308-
| `Debug` | Enable debug output. | `'false'` |
309-
| `Verbose` | Enable verbose output. | `'false'` |
312+
| `Debug` | Enable debug output. | `false` |
313+
| `Verbose` | Enable verbose output. | `false` |
310314
| `Version` | Specifies the exact version of the GitHub module to install. | *(none)* |
311-
| `Prerelease` | Allow prerelease versions if available. | `'false'` |
312-
| `WorkingDirectory` | The working directory where the script runs. | `'.'` |
315+
| `Prerelease` | Allow prerelease versions if available. | `false` |
316+
| `WorkingDirectory` | The working directory where the script runs. | `.` |
313317

314318
### Outputs
315319

action.yml

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@ inputs:
1515
Output generated reports in JSON format in addition to the configured format through Pester.
1616
required: false
1717
default: 'true'
18+
StepSummary_Enabled:
19+
description: |
20+
Controls if a GitHub step summary should be shown.
21+
required: false
22+
default: 'false'
23+
StepSummary_ShowTestOverview:
24+
description: |
25+
Controls whether to show the test overview table in the GitHub step summary.
26+
required: false
27+
default: 'true'
28+
StepSummary_ShowTests:
29+
description: |
30+
Controls which tests to show in the GitHub step summary. Allows "Full", "Failed", or "None".
31+
required: false
32+
default: 'Failed'
33+
StepSummary_ShowConfiguration:
34+
description: |
35+
Controls whether to show the configuration details in the GitHub step summary.
36+
required: false
37+
default: 'false'
1838
Run_Path:
1939
description: |
2040
Directories to be searched for tests, paths directly to test files, or combination of both.
@@ -324,6 +344,10 @@ runs:
324344
working-directory: ${{ inputs.WorkingDirectory }}
325345
env:
326346
PSMODULE_INVOKE_PESTER_INPUT_ReportAsJson: ${{ inputs.ReportAsJson }}
347+
PSMODULE_INVOKE_PESTER_INPUT_StepSummary_Enabled: ${{ inputs.StepSummary_Enabled }}
348+
PSMODULE_INVOKE_PESTER_INPUT_StepSummary_ShowTestOverview: ${{ inputs.StepSummary_ShowTestOverview }}
349+
PSMODULE_INVOKE_PESTER_INPUT_StepSummary_ShowTests: ${{ inputs.StepSummary_ShowTests }}
350+
PSMODULE_INVOKE_PESTER_INPUT_StepSummary_ShowConfiguration: ${{ inputs.StepSummary_ShowConfiguration }}
327351
id: test
328352
run: |
329353
# Invoke-Pester (exec)
@@ -357,31 +381,4 @@ runs:
357381
PSMODULE_INVOKE_PESTER_INTERNAL_Conclusion: ${{ steps.test.conclusion }}
358382
run: |
359383
# Status
360-
$PSStyle.OutputRendering = 'Ansi'
361-
$executed = $env:PSMODULE_INVOKE_PESTER_INTERNAL_Executed -eq 'true'
362-
$outcome = $env:PSMODULE_INVOKE_PESTER_INTERNAL_Outcome
363-
$conclusion = $env:PSMODULE_INVOKE_PESTER_INTERNAL_Conclusion
364-
365-
"Executed=$executed" >> $env:GITHUB_OUTPUT
366-
367-
[PSCustomObject]@{
368-
Executed = $executed
369-
Outcome = $outcome
370-
Conclusion = $conclusion
371-
} | Format-List | Out-String
372-
373-
# If the tests did not execute, exit with a failure code
374-
if ($executed -ne 'true') {
375-
Write-Error "Tests did not execute."
376-
exit 1
377-
}
378-
# If the outcome is not success, exit with a failure code
379-
if ($outcome -ne 'success') {
380-
Write-Error "Tests did not pass."
381-
exit 1
382-
}
383-
# If the conclusion is not success
384-
if ($conclusion -ne 'success') {
385-
Write-Error "Tests did not pass."
386-
exit 1
387-
}
384+
${{ github.action_path }}/scripts/status.ps1

0 commit comments

Comments
 (0)