Skip to content

Commit da2a725

Browse files
🩹 [Patch]: Group successful and failed doc generation (#26)
## Description This pull request reorganizes the GitHub Actions workflow, improves input handling and environment variable usage in the action, and enhances the summary output for PowerShell module documentation commands. The most notable changes are the restructuring of workflow jobs to support different summary behaviors, improved input/environment variable consistency, and more detailed step summaries. - Fixes PSModule/Process-PSModule#229 **GitHub Actions workflow improvements:** * The `.github/workflows/Action-Test.yml` workflow now separates artifact upload into its own `UploadArtifact` job, and introduces two test jobs: `ActionTestDefault` (without always showing summary) and `ActionTestWithSummary` (always shows summary on success). This allows testing both behaviors and ensures artifacts are available before running tests. [[1]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4L26-R27) [[2]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R44-L49) [[3]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4R69-R87) **Action input and environment variable handling:** * The `action.yml` file reorders the `inputs` section for clarity, and environment variables passed to scripts now use a consistent `DOCUMENT_PSMODULE_INPUT_*` naming scheme instead of the previous `GITHUB_ACTION_INPUT_*`. [[1]](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6L12-R19) [[2]](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6L30-R31) * The `scripts/main.ps1` script now accepts `Name` and `ShowSummaryOnSuccess` as parameters, defaulting to the new environment variable names, and updates how these values are handled and passed to helper scripts. [[1]](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011L6-R19) [[2]](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011L28-R30) [[3]](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011L40-R51) **Summary output enhancements:** * The `Build-PSModuleDocumentation.ps1` script changes the summary section to use collapsible `<details>` blocks for failed and succeeded commands, making the output clearer and easier to navigate in GitHub step summaries. [[1]](diffhunk://#diff-95b236851bd9052577a2cdf569f08e195e7d6cc424f6cb6d074ccc10b2cb7241L98-R98) [[2]](diffhunk://#diff-95b236851bd9052577a2cdf569f08e195e7d6cc424f6cb6d074ccc10b2cb7241L114-R146)
1 parent b693138 commit da2a725

File tree

4 files changed

+82
-27
lines changed

4 files changed

+82
-27
lines changed

.github/workflows/Action-Test.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ permissions:
2323
statuses: write # to create commit status
2424

2525
jobs:
26-
ActionTestDefault:
27-
name: Action-Test - [Default]
26+
UploadArtifact:
27+
name: Upload Artifact
2828
runs-on: ubuntu-latest
2929
steps:
3030
- name: Checkout repo
@@ -41,12 +41,22 @@ jobs:
4141
if-no-files-found: error
4242
retention-days: 1
4343

44+
ActionTestDefault:
45+
name: Action-Test - [Default]
46+
runs-on: ubuntu-latest
47+
needs: UploadArtifact
48+
steps:
49+
- name: Checkout repo
50+
uses: actions/checkout@v5
51+
with:
52+
persist-credentials: false
53+
fetch-depth: 0
54+
4455
- name: Action-Test
4556
uses: ./
4657
with:
4758
Name: PSModuleTest
4859
WorkingDirectory: tests/srcTestRepo
49-
ShowSummaryOnSuccess: true
5060

5161
- name: Lint documentation
5262
uses: super-linter/super-linter/[email protected]
@@ -56,3 +66,22 @@ jobs:
5666
VALIDATE_NATURAL_LANGUAGE: true
5767
VALIDATE_ALL_CODEBASE: true
5868
USE_FIND_ALGORITHM: true
69+
70+
ActionTestWithSummary:
71+
name: Action-Test - [With Summary]
72+
runs-on: ubuntu-latest
73+
needs: UploadArtifact
74+
steps:
75+
- name: Checkout repo
76+
uses: actions/checkout@v5
77+
with:
78+
persist-credentials: false
79+
fetch-depth: 0
80+
81+
82+
- name: Action-Test
83+
uses: ./
84+
with:
85+
Name: PSModuleTest
86+
WorkingDirectory: tests/srcTestRepo
87+
ShowSummaryOnSuccess: true

action.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ inputs:
99
Name:
1010
description: Name of the module to process.
1111
required: false
12-
WorkingDirectory:
13-
description: The working directory where the script will run from.
14-
required: false
15-
default: '.'
1612
ShowSummaryOnSuccess:
1713
description: Show GitHub Step Summary even when all commands succeed.
1814
required: false
1915
default: 'false'
16+
WorkingDirectory:
17+
description: The working directory where the script will run from.
18+
required: false
19+
default: '.'
2020

2121
runs:
2222
using: composite
@@ -27,8 +27,8 @@ runs:
2727
- name: Document-PSModule
2828
shell: pwsh
2929
env:
30-
GITHUB_ACTION_INPUT_Name: ${{ inputs.Name }}
31-
GITHUB_ACTION_INPUT_ShowSummaryOnSuccess: ${{ inputs.ShowSummaryOnSuccess }}
30+
DOCUMENT_PSMODULE_INPUT_Name: ${{ inputs.Name }}
31+
DOCUMENT_PSMODULE_INPUT_ShowSummaryOnSuccess: ${{ inputs.ShowSummaryOnSuccess }}
3232
working-directory: ${{ inputs.WorkingDirectory }}
3333
run: |
3434
# Build-PSModuleDocumentation

scripts/helpers/Build-PSModuleDocumentation.ps1

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function Build-PSModuleDocumentation {
22
<#
3-
.SYNOPSIS
4-
Builds a module.
3+
.SYNOPSIS
4+
Builds a module.
55
6-
.DESCRIPTION
7-
Builds a module.
6+
.DESCRIPTION
7+
Builds a module.
88
#>
99
[CmdletBinding()]
1010
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
@@ -95,7 +95,7 @@
9595
$hasFailures = $failedCommands.Count -gt 0
9696
$shouldShowSummary = $hasFailures -or $ShowSummaryOnSuccess
9797

98-
# Generate summary if there are failures OR if ShowSummaryOnSuccess is enabled
98+
# Generate summary if ShowSummaryOnSuccess is enabled
9999
if ($shouldShowSummary) {
100100
$statusIcon = $hasFailures ? '' : ''
101101
$statusText = $hasFailures ? 'Failed' : 'Succeeded'
@@ -111,13 +111,39 @@
111111
|---------|---------|
112112
| $successCount | $failureCount |
113113
114-
## Command status
114+
"@
115+
116+
if ($failedCommands) {
117+
$summaryContent += @"
118+
119+
<details><summary>Failed</summary>
120+
121+
<p>
122+
123+
$(($failedCommands | ForEach-Object { "- ``$($_.CommandName)`` `n" }) -join '')
124+
125+
</p>
126+
127+
</details>
128+
129+
"@
130+
}
131+
132+
if ($successfulCommands) {
133+
$summaryContent += @"
134+
135+
<details><summary>Succeeded</summary>
115136
116-
| Command | Status |
117-
|---------|--------|
118-
$(($commandResults | ForEach-Object { "| ``$($_.CommandName)`` | $($_.Status) |`n" }) -join '')
137+
<p>
138+
139+
$(($successfulCommands | ForEach-Object { "- ``$($_.CommandName)`` `n" }) -join '')
140+
141+
</p>
142+
143+
</details>
119144
120145
"@
146+
}
121147

122148

123149
$summaryContent | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append

scripts/main.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
Justification = 'Want to just write to the console, not the pipeline.'
44
)]
55
[CmdletBinding()]
6-
param()
6+
param(
7+
[string]$Name = $env:DOCUMENT_PSMODULE_INPUT_Name,
8+
[bool]$ShowSummaryOnSuccess = $env:DOCUMENT_PSMODULE_INPUT_ShowSummaryOnSuccess -eq 'true'
9+
)
710

811
$PSStyle.OutputRendering = 'Ansi'
912

1013
'Microsoft.PowerShell.PlatyPS' | ForEach-Object {
11-
$name = $_
12-
Write-Output "Installing module: $name"
14+
Write-Output "Installing module: $_"
1315
$retryCount = 5
1416
$retryDelay = 10
1517
for ($i = 0; $i -lt $retryCount; $i++) {
1618
try {
17-
Install-PSResource -Name $name -WarningAction SilentlyContinue -TrustRepository -Repository PSGallery
19+
Install-PSResource -Name $_ -WarningAction SilentlyContinue -TrustRepository -Repository PSGallery
1820
break
1921
} catch {
2022
Write-Warning "Installation of $($psResourceParams.Name) failed with error: $_"
@@ -25,7 +27,7 @@ $PSStyle.OutputRendering = 'Ansi'
2527
Start-Sleep -Seconds $retryDelay
2628
}
2729
}
28-
Import-Module -Name $name
30+
Import-Module -Name $_
2931
}
3032

3133
$path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers') | Get-Item | Resolve-Path -Relative
@@ -37,18 +39,16 @@ Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | Resolve-Path -Relative | Fo
3739

3840
Write-Host '::group::Loading inputs'
3941
$env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/'
40-
$moduleName = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Name) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_INPUT_Name
41-
$showSummaryOnSuccess = $env:GITHUB_ACTION_INPUT_ShowSummaryOnSuccess -eq 'true'
4242
$moduleSourceFolderPath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path
4343
$modulesOutputFolderPath = Join-Path -Path . -ChildPath 'outputs/module'
4444
$docsOutputFolderPath = Join-Path -Path . -ChildPath 'outputs/docs'
4545

4646
$params = @{
47-
ModuleName = $moduleName
47+
ModuleName = [string]::IsNullOrEmpty($Name) ? $env:GITHUB_REPOSITORY_NAME : $Name
4848
ModuleSourceFolderPath = $moduleSourceFolderPath
4949
ModulesOutputFolderPath = $modulesOutputFolderPath
5050
DocsOutputFolderPath = $docsOutputFolderPath
51-
ShowSummaryOnSuccess = $showSummaryOnSuccess
51+
ShowSummaryOnSuccess = $ShowSummaryOnSuccess
5252
}
5353

5454
[pscustomobject]$params | Format-List | Out-String

0 commit comments

Comments
 (0)