From 54a34ce94a7228862a8ca9a624dd0e14a172f625 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 18:49:40 +0200 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20check=20to?= =?UTF-8?q?=20ensure=20step=20summary=20is=20empty=20after=20Action-Test?= =?UTF-8?q?=20execution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 2191713..a48f3a7 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -46,7 +46,15 @@ jobs: with: Name: PSModuleTest WorkingDirectory: tests/srcTestRepo - ShowSummaryOnSuccess: true + + - name: Check step summary is empty + shell: pwsh + run: | + $summary = Get-Content $env:GITHUB_STEP_SUMMARY -Raw + if ($summary.Trim() -ne '') { + throw "Step summary is not empty: $summary" + } + Write-Host "Step summary is empty as expected." - name: Lint documentation uses: super-linter/super-linter/slim@v8.1.0 From acc77164f46fd915e94592a85a9d0613e9946377 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 18:54:15 +0200 Subject: [PATCH 2/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20check=20?= =?UTF-8?q?for=20step=20summary=20to=20use=20IsNullOrEmpty=20for=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index a48f3a7..c94f8ae 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -51,7 +51,7 @@ jobs: shell: pwsh run: | $summary = Get-Content $env:GITHUB_STEP_SUMMARY -Raw - if ($summary.Trim() -ne '') { + if ([string]::IsNullOrEmpty($summary)) { throw "Step summary is not empty: $summary" } Write-Host "Step summary is empty as expected." From 42f0e9dfe9869e327dfae851b134927faebc8fbd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 18:57:01 +0200 Subject: [PATCH 3/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20logging=20f?= =?UTF-8?q?or=20step=20summary=20check=20to=20improve=20visibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index c94f8ae..98a50c1 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -51,6 +51,8 @@ jobs: shell: pwsh run: | $summary = Get-Content $env:GITHUB_STEP_SUMMARY -Raw + Write-Host "Step summary:" + Write-Host "[$summary]" if ([string]::IsNullOrEmpty($summary)) { throw "Step summary is not empty: $summary" } From e9ee8b97424980b087dcb432500a378c90bb8aa8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 18:59:27 +0200 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20check=20?= =?UTF-8?q?for=20step=20summary=20to=20improve=20clarity=20and=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 98a50c1..62d58ee 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -53,7 +53,7 @@ jobs: $summary = Get-Content $env:GITHUB_STEP_SUMMARY -Raw Write-Host "Step summary:" Write-Host "[$summary]" - if ([string]::IsNullOrEmpty($summary)) { + if (-not [string]::IsNullOrEmpty($summary)) { throw "Step summary is not empty: $summary" } Write-Host "Step summary is empty as expected." From ec5ece33295ad27145b9416363ec8d56057514f0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 19:11:38 +0200 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20Action-Test?= =?UTF-8?q?=20job=20with=20summary=20check=20to=20ensure=20step=20summary?= =?UTF-8?q?=20is=20not=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 62d58ee..8b4b671 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -66,3 +66,39 @@ jobs: VALIDATE_NATURAL_LANGUAGE: true VALIDATE_ALL_CODEBASE: true USE_FIND_ALGORITHM: true + + ActionTestWithSummary: + name: Action-Test - [With Summary] + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v5 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Upload module artifact + uses: actions/upload-artifact@v4 + with: + name: module + path: tests/srcTestRepo/outputs/module + if-no-files-found: error + retention-days: 1 + + - name: Action-Test + uses: ./ + with: + Name: PSModuleTest + WorkingDirectory: tests/srcTestRepo + ShowSummaryOnSuccess: true + + - name: Check step summary is not empty + shell: pwsh + run: | + $summary = Get-Content $env:GITHUB_STEP_SUMMARY -Raw + Write-Host "Step summary:" + Write-Host "[$summary]" + if ([string]::IsNullOrEmpty($summary)) { + throw "Step summary is empty, but expected not to be." + } + Write-Host "Step summary is not empty as expected." From 64f127063fe515abf5baf25e271287e61cfb9882 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 19:17:33 +0200 Subject: [PATCH 6/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Rearrange=20jobs?= =?UTF-8?q?=20in=20Action-Test=20workflow=20for=20better=20structure=20and?= =?UTF-8?q?=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 8b4b671..f6e7ff0 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -23,8 +23,8 @@ permissions: statuses: write # to create commit status jobs: - ActionTestDefault: - name: Action-Test - [Default] + UploadArtifact: + name: Upload Artifact runs-on: ubuntu-latest steps: - name: Checkout repo @@ -41,6 +41,17 @@ jobs: if-no-files-found: error retention-days: 1 + ActionTestDefault: + name: Action-Test - [Default] + runs-on: ubuntu-latest + needs: UploadArtifact + steps: + - name: Checkout repo + uses: actions/checkout@v5 + with: + persist-credentials: false + fetch-depth: 0 + - name: Action-Test uses: ./ with: @@ -70,6 +81,7 @@ jobs: ActionTestWithSummary: name: Action-Test - [With Summary] runs-on: ubuntu-latest + needs: UploadArtifact steps: - name: Checkout repo uses: actions/checkout@v5 @@ -77,13 +89,6 @@ jobs: persist-credentials: false fetch-depth: 0 - - name: Upload module artifact - uses: actions/upload-artifact@v4 - with: - name: module - path: tests/srcTestRepo/outputs/module - if-no-files-found: error - retention-days: 1 - name: Action-Test uses: ./ From bc91d8330ba0e5c203b0190360979ee8dc84f9f9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 19:22:49 +0200 Subject: [PATCH 7/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20redundan?= =?UTF-8?q?t=20step=20summary=20checks=20and=20update=20input=20variable?= =?UTF-8?q?=20handling=20in=20action=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 22 --------- action.yml | 12 ++--- .../helpers/Build-PSModuleDocumentation.ps1 | 46 +++++++++++++++---- scripts/main.ps1 | 11 +++-- 4 files changed, 48 insertions(+), 43 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index f6e7ff0..2d2959a 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -58,17 +58,6 @@ jobs: Name: PSModuleTest WorkingDirectory: tests/srcTestRepo - - name: Check step summary is empty - shell: pwsh - run: | - $summary = Get-Content $env:GITHUB_STEP_SUMMARY -Raw - Write-Host "Step summary:" - Write-Host "[$summary]" - if (-not [string]::IsNullOrEmpty($summary)) { - throw "Step summary is not empty: $summary" - } - Write-Host "Step summary is empty as expected." - - name: Lint documentation uses: super-linter/super-linter/slim@v8.1.0 env: @@ -96,14 +85,3 @@ jobs: Name: PSModuleTest WorkingDirectory: tests/srcTestRepo ShowSummaryOnSuccess: true - - - name: Check step summary is not empty - shell: pwsh - run: | - $summary = Get-Content $env:GITHUB_STEP_SUMMARY -Raw - Write-Host "Step summary:" - Write-Host "[$summary]" - if ([string]::IsNullOrEmpty($summary)) { - throw "Step summary is empty, but expected not to be." - } - Write-Host "Step summary is not empty as expected." diff --git a/action.yml b/action.yml index 1cd094f..1b3d4fd 100644 --- a/action.yml +++ b/action.yml @@ -9,14 +9,14 @@ inputs: Name: description: Name of the module to process. required: false - WorkingDirectory: - description: The working directory where the script will run from. - required: false - default: '.' ShowSummaryOnSuccess: description: Show GitHub Step Summary even when all commands succeed. required: false default: 'false' + WorkingDirectory: + description: The working directory where the script will run from. + required: false + default: '.' runs: using: composite @@ -27,8 +27,8 @@ runs: - name: Document-PSModule shell: pwsh env: - GITHUB_ACTION_INPUT_Name: ${{ inputs.Name }} - GITHUB_ACTION_INPUT_ShowSummaryOnSuccess: ${{ inputs.ShowSummaryOnSuccess }} + DOCUMENT_PSMODULE_INPUT_Name: ${{ inputs.Name }} + DOCUMENT_PSMODULE_INPUT_ShowSummaryOnSuccess: ${{ inputs.ShowSummaryOnSuccess }} working-directory: ${{ inputs.WorkingDirectory }} run: | # Build-PSModuleDocumentation diff --git a/scripts/helpers/Build-PSModuleDocumentation.ps1 b/scripts/helpers/Build-PSModuleDocumentation.ps1 index 9ad6e60..9beb829 100644 --- a/scripts/helpers/Build-PSModuleDocumentation.ps1 +++ b/scripts/helpers/Build-PSModuleDocumentation.ps1 @@ -1,10 +1,10 @@ function Build-PSModuleDocumentation { <# - .SYNOPSIS - Builds a module. + .SYNOPSIS + Builds a module. - .DESCRIPTION - Builds a module. + .DESCRIPTION + Builds a module. #> [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( @@ -93,9 +93,9 @@ $failedCommands = $commandResults | Where-Object { $_.Status -eq 'Failed' } $successfulCommands = $commandResults | Where-Object { $_.Status -eq 'Success' } $hasFailures = $failedCommands.Count -gt 0 - $shouldShowSummary = $hasFailures -or $ShowSummaryOnSuccess + $shouldShowSummary = $ShowSummaryOnSuccess - # Generate summary if there are failures OR if ShowSummaryOnSuccess is enabled + # Generate summary if ShowSummaryOnSuccess is enabled if ($shouldShowSummary) { $statusIcon = $hasFailures ? '❌' : '✅' $statusText = $hasFailures ? 'Failed' : 'Succeeded' @@ -111,13 +111,39 @@ |---------|---------| | $successCount | $failureCount | -## Command status +"@ + + if ($failedCommands) { + $summaryContent += @" + +
Failed + +

+ +$(($failedCommands | ForEach-Object { "- ``$($_.CommandName)`` `n" }) -join '') + +

+ +
+ +"@ + } + + if ($successfulCommands) { + $summaryContent += @" + +
Succeeded -| Command | Status | -|---------|--------| -$(($commandResults | ForEach-Object { "| ``$($_.CommandName)`` | $($_.Status) |`n" }) -join '') +

+ +$(($successfulCommands | ForEach-Object { "- ``$($_.CommandName)`` `n" }) -join '') + +

+ +
"@ + } $summaryContent | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 6557d1c..a4bcfdd 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -3,7 +3,10 @@ Justification = 'Want to just write to the console, not the pipeline.' )] [CmdletBinding()] -param() +param( + [string]$Name = $env:DOCUMENT_PSMODULE_INPUT_Name, + [bool]$ShowSummaryOnSuccess = $env:DOCUMENT_PSMODULE_INPUT_ShowSummaryOnSuccess -eq 'true' +) $PSStyle.OutputRendering = 'Ansi' @@ -37,18 +40,16 @@ Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | Resolve-Path -Relative | Fo Write-Host '::group::Loading inputs' $env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/' -$moduleName = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Name) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_INPUT_Name -$showSummaryOnSuccess = $env:GITHUB_ACTION_INPUT_ShowSummaryOnSuccess -eq 'true' $moduleSourceFolderPath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path $modulesOutputFolderPath = Join-Path -Path . -ChildPath 'outputs/module' $docsOutputFolderPath = Join-Path -Path . -ChildPath 'outputs/docs' $params = @{ - ModuleName = $moduleName + ModuleName = [string]::IsNullOrEmpty($Name) ? $env:GITHUB_REPOSITORY_NAME : $Name ModuleSourceFolderPath = $moduleSourceFolderPath ModulesOutputFolderPath = $modulesOutputFolderPath DocsOutputFolderPath = $docsOutputFolderPath - ShowSummaryOnSuccess = $showSummaryOnSuccess + ShowSummaryOnSuccess = $ShowSummaryOnSuccess } [pscustomobject]$params | Format-List | Out-String From cf6e867b85b7b1615fe8e5e6955be63c3032ebcf Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 19:28:07 +0200 Subject: [PATCH 8/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20summary?= =?UTF-8?q?=20display=20logic=20to=20show=20summary=20based=20on=20failure?= =?UTF-8?q?=20status=20or=20success=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Build-PSModuleDocumentation.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Build-PSModuleDocumentation.ps1 b/scripts/helpers/Build-PSModuleDocumentation.ps1 index 9beb829..e6387c7 100644 --- a/scripts/helpers/Build-PSModuleDocumentation.ps1 +++ b/scripts/helpers/Build-PSModuleDocumentation.ps1 @@ -93,7 +93,7 @@ $failedCommands = $commandResults | Where-Object { $_.Status -eq 'Failed' } $successfulCommands = $commandResults | Where-Object { $_.Status -eq 'Success' } $hasFailures = $failedCommands.Count -gt 0 - $shouldShowSummary = $ShowSummaryOnSuccess + $shouldShowSummary = $hasFailures -or $ShowSummaryOnSuccess # Generate summary if ShowSummaryOnSuccess is enabled if ($shouldShowSummary) { From 83acd44d3ecf0b6a0b462c876df90ea78a79a7e2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 19:51:36 +0200 Subject: [PATCH 9/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Simplify=20module?= =?UTF-8?q?=20installation=20logic=20by=20removing=20unnecessary=20variabl?= =?UTF-8?q?e=20assignments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index a4bcfdd..d9a1d87 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -11,13 +11,12 @@ param( $PSStyle.OutputRendering = 'Ansi' 'Microsoft.PowerShell.PlatyPS' | ForEach-Object { - $name = $_ - Write-Output "Installing module: $name" + Write-Output "Installing module: $_" $retryCount = 5 $retryDelay = 10 for ($i = 0; $i -lt $retryCount; $i++) { try { - Install-PSResource -Name $name -WarningAction SilentlyContinue -TrustRepository -Repository PSGallery + Install-PSResource -Name $_ -WarningAction SilentlyContinue -TrustRepository -Repository PSGallery break } catch { Write-Warning "Installation of $($psResourceParams.Name) failed with error: $_" @@ -28,7 +27,7 @@ $PSStyle.OutputRendering = 'Ansi' Start-Sleep -Seconds $retryDelay } } - Import-Module -Name $name + Import-Module -Name $_ } $path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers') | Get-Item | Resolve-Path -Relative