Skip to content
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
35 changes: 32 additions & 3 deletions .github/workflows/Action-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,12 +41,22 @@ 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:
Name: PSModuleTest
WorkingDirectory: tests/srcTestRepo
ShowSummaryOnSuccess: true

- name: Lint documentation
uses: super-linter/super-linter/slim@v8.1.0
Expand All @@ -56,3 +66,22 @@ jobs:
VALIDATE_NATURAL_LANGUAGE: true
VALIDATE_ALL_CODEBASE: true
USE_FIND_ALGORITHM: true

ActionTestWithSummary:
name: Action-Test - [With Summary]
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:
Name: PSModuleTest
WorkingDirectory: tests/srcTestRepo
ShowSummaryOnSuccess: true
12 changes: 6 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
44 changes: 35 additions & 9 deletions scripts/helpers/Build-PSModuleDocumentation.ps1
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -95,7 +95,7 @@
$hasFailures = $failedCommands.Count -gt 0
$shouldShowSummary = $hasFailures -or $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'
Expand All @@ -111,13 +111,39 @@
|---------|---------|
| $successCount | $failureCount |
## Command status
"@

if ($failedCommands) {
$summaryContent += @"
<details><summary>Failed</summary>
<p>
$(($failedCommands | ForEach-Object { "- ``$($_.CommandName)`` `n" }) -join '')
</p>
</details>
"@
}

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


$summaryContent | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
Expand Down
18 changes: 9 additions & 9 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
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'

'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: $_"
Expand All @@ -25,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
Expand All @@ -37,18 +39,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
Expand Down
Loading