Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
979f75e
🩹 [Patch]: Add additional notes and controls to `Set-PSModuleTest` fu…
MariusStorhaug Oct 5, 2025
dfc2e26
🩹 [Patch]: Add linting step for documentation in Action-Test workflow
MariusStorhaug Oct 5, 2025
d33423b
🩹 [Patch]: Fix lint documentation path in Action-Test workflow
MariusStorhaug Oct 5, 2025
2772e54
🩹 [Patch]: Fix lint documentation path and update workspace variable …
MariusStorhaug Oct 5, 2025
7c18e2f
🩹 [Patch]: Remove unused DEFAULT_BRANCH environment variable from Act…
MariusStorhaug Oct 5, 2025
8c023f7
🩹 [Patch]: Remove ENABLE_GITHUB_ACTIONS_GROUP_TITLE and RUN_LOCAL env…
MariusStorhaug Oct 5, 2025
cc53996
🩹 [Patch]: Ensure fetch-depth is set to 0 in checkout step of Action-…
MariusStorhaug Oct 5, 2025
c0bffe9
🩹 [Patch]: Add persist-credentials, DEFAULT_BRANCH, ENABLE_GITHUB_ACT…
MariusStorhaug Oct 5, 2025
e9ac75f
🩹 [Patch]: Add step to list files in the Action-Test workflow
MariusStorhaug Oct 5, 2025
503c423
🩹 [Patch]: Refine file listing command and update FILTER_REGEX_INCLUD…
MariusStorhaug Oct 5, 2025
2a6f7aa
🩹 [Patch]: Remove unnecessary environment variables from Lint documen…
MariusStorhaug Oct 5, 2025
754b7d3
🩹 [Patch]: Add VALIDATE_ALL_CODEBASE environment variable to Lint doc…
MariusStorhaug Oct 5, 2025
5863d5e
🩹 [Patch]: Update permissions and refine Lint documentation environme…
MariusStorhaug Oct 5, 2025
bccd912
🩹 [Patch]: Remove unnecessary environment variables and update FILTER…
MariusStorhaug Oct 5, 2025
c71db9d
🩹 [Patch]: Add VALIDATE_ALL_CODEBASE environment variable to Lint doc…
MariusStorhaug Oct 5, 2025
aff7358
🩹 [Patch]: Refine Lint documentation step by adding missing environme…
MariusStorhaug Oct 5, 2025
6dcceb9
🩹 [Patch]: Refactor Lint documentation step by updating DEFAULT_WORKS…
MariusStorhaug Oct 5, 2025
7d624a8
🩹 [Patch]: Add 'Get changes' step to Action-Test workflow and clean u…
MariusStorhaug Oct 5, 2025
4a586da
🩹 [Patch]: Remove VALIDATE_ALL_CODEBASE environment variable from Lin…
MariusStorhaug Oct 5, 2025
e526310
🩹 [Patch]: Add LOG_LEVEL environment variable to Lint documentation s…
MariusStorhaug Oct 5, 2025
b9be1e6
🩹 [Patch]: Update Lint step to include log file upload and remove LOG…
MariusStorhaug Oct 5, 2025
b5bcd82
🩹 [Patch]: Add DEFAULT_BRANCH environment variable to Lint documentat…
MariusStorhaug Oct 5, 2025
82c4484
🩹 [Patch]: Remove git status command and streamline documentation upd…
MariusStorhaug Oct 5, 2025
2df9bf0
🩹 [Patch]: Refactor Get changes step to use GitHub Script action for …
MariusStorhaug Oct 5, 2025
16b246f
🩹 [Patch]: Comment out RUN_LOCAL and DEFAULT_BRANCH environment varia…
MariusStorhaug Oct 5, 2025
51b6643
🩹 [Patch]: Refactor Get changes step to include logging for file list…
MariusStorhaug Oct 5, 2025
ab29008
🩹 [Patch]: Update Build-PSModuleDocumentation to use New-MarkdownComm…
MariusStorhaug Oct 5, 2025
a7c4cae
🩹 [Patch]: Import module with verbose output during documentation gen…
MariusStorhaug Oct 5, 2025
42b2077
🩹 [Patch]: Add debug flag to New-MarkdownCommandHelp for enhanced tro…
MariusStorhaug Oct 5, 2025
7e58bbe
🩹 [Patch]: Enhance New-MarkdownCommandHelp invocation with explicit d…
MariusStorhaug Oct 5, 2025
2cb6082
🩹 [Patch]: Refactor Build-PSModuleDocumentation to enhance command pr…
MariusStorhaug Oct 6, 2025
70ce267
🩹 [Patch]: Fix output folder variable reference in command processing…
MariusStorhaug Oct 6, 2025
6b865bc
🩹 [Patch]: Add DESCRIPTION section to PSModuleTest functions for impr…
MariusStorhaug Oct 6, 2025
1a6dc34
🩹 [Patch]: Fix frontmatter title in markdown files by updating 'title…
MariusStorhaug Oct 6, 2025
922dede
🩹 [Patch]: Remove jscpd configuration file and update Linter workflow…
MariusStorhaug Oct 6, 2025
ce3a00c
🩹 [Patch]: Add jscpd configuration file to enable code duplication ch…
MariusStorhaug Oct 6, 2025
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
25 changes: 24 additions & 1 deletion .github/workflows/Action-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}
permissions:
contents: read # to checkout the repo
statuses: write # to create commit status

jobs:
ActionTestDefault:
Expand All @@ -24,6 +26,9 @@
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
persist-credentials: false
fetch-depth: 0

- name: Upload module artifact
uses: actions/upload-artifact@v4
Expand All @@ -38,3 +43,21 @@
with:
Name: PSModuleTest
WorkingDirectory: tests/srcTestRepo

- name: Get changes
uses: PSModule/GitHub-Script@v1
with:
Script: |
LogGroup "List files" {
Get-ChildItem -Recurse -File | Select-Object -ExpandProperty FullName | Sort-Object
}
LogGroup "Commit changes" {
git add tests/srcTestRepo/outputs/docs/
git commit -m "Update documentation"
}
- name: Lint documentation
uses: super-linter/super-linter/slim@7bba2eeb89d01dc9bfd93c497477a57e72c83240 # v8.2.0
env:
GITHUB_TOKEN: ${{ github.token }}
VALIDATE_MARKDOWN: true
3 changes: 3 additions & 0 deletions .github/workflows/Linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v5
with:
persist-credentials: false
fetch-depth: 0

- name: Lint code base
Expand All @@ -30,3 +31,5 @@ jobs:
VALIDATE_JSON_PRETTIER: false
VALIDATE_MARKDOWN_PRETTIER: false
VALIDATE_YAML_PRETTIER: false
VALIDATE_BIOME_FORMAT: false
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
46 changes: 40 additions & 6 deletions scripts/helpers/Build-PSModuleDocumentation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,32 @@

Write-Host '::group::Build docs - Generate markdown help - Raw'
Install-PSModule -Path $ModuleOutputFolder
Write-Host ($ModuleName | Get-Module)
$null = New-MarkdownHelp -Module $ModuleName -OutputFolder $DocsOutputFolder -Force -Verbose
$moduleInfo = Import-Module -Name $ModuleName -Force -PassThru

# Get all exported commands from the module
$commands = $moduleInfo.ExportedCommands.Values | Where-Object { $_.CommandType -ne 'Alias' }

Write-Host "Found $($commands.Count) commands to process"

foreach ($command in $commands) {
try {
Write-Host "$($command.Name)" -NoNewline
$params = @{
CommandInfo = $command
OutputFolder = $docsOutputFolder
Encoding = 'utf8'
ProgressAction = 'SilentlyContinue'
ErrorAction = 'Stop'
Force = $true
}
$null = New-MarkdownCommandHelp @params
Write-Host ' - ✓' -ForegroundColor Green
} catch {
Write-Host ' - ✗' -ForegroundColor Red
$_
}
}

Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
$fileName = $_.Name
Write-Host "::group:: - [$fileName]"
Expand Down Expand Up @@ -88,30 +112,40 @@

Write-Host '::group::Build docs - Structure markdown files to match source files'
$PublicFunctionsFolder = Join-Path $ModuleSourceFolder.FullName 'functions\public' | Get-Item
Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object {
$moduleDocsFolder = Join-Path $DocsOutputFolder.FullName $ModuleName
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable $moduleDocsFolder is calculated twice (lines 115 and 141) with the same logic. Consider calculating it once at the beginning of the function to avoid code duplication.

Copilot uses AI. Check for mistakes.
Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
$file = $_
$relPath = [System.IO.Path]::GetRelativePath($DocsOutputFolder.FullName, $file.FullName)
$relPath = [System.IO.Path]::GetRelativePath($moduleDocsFolder, $file.FullName)
Write-Host " - $relPath"
Write-Host " Path: $file"

# find the source code file that matches the markdown file
$scriptPath = Get-ChildItem -Path $PublicFunctionsFolder -Recurse -Force | Where-Object { $_.Name -eq ($file.BaseName + '.ps1') }
Write-Host " PS1 path: $scriptPath"
$docsFilePath = ($scriptPath.FullName).Replace($PublicFunctionsFolder.FullName, $DocsOutputFolder.FullName).Replace('.ps1', '.md')
$docsFilePath = ($scriptPath.FullName).Replace($PublicFunctionsFolder.FullName, $moduleDocsFolder).Replace('.ps1', '.md')
Write-Host " MD path: $docsFilePath"
$docsFolderPath = Split-Path -Path $docsFilePath -Parent
$null = New-Item -Path $docsFolderPath -ItemType Directory -Force
Move-Item -Path $file.FullName -Destination $docsFilePath -Force
}

Write-Host '::group::Build docs - Fix frontmatter title'
Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
$content = Get-Content -Path $_.FullName -Raw
# Replace 'title:' with 'ms.title:' in frontmatter only (between --- markers)
$content = $content -replace '(?s)^(---.*?)title:(.*?---)', '$1ms.title:$2'
$content | Set-Content -Path $_.FullName
}

Write-Host '::group::Build docs - Move markdown files from source files to docs'
$moduleDocsFolder = Join-Path $DocsOutputFolder.FullName $ModuleName
Get-ChildItem -Path $PublicFunctionsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
$file = $_
$relPath = [System.IO.Path]::GetRelativePath($PublicFunctionsFolder.FullName, $file.FullName)
Write-Host " - $relPath"
Write-Host " Path: $file"

$docsFilePath = ($file.FullName).Replace($PublicFunctionsFolder.FullName, $DocsOutputFolder.FullName)
$docsFilePath = ($file.FullName).Replace($PublicFunctionsFolder.FullName, $moduleDocsFolder)
Write-Host " MD path: $docsFilePath"
$docsFolderPath = Split-Path -Path $docsFilePath -Parent
$null = New-Item -Path $docsFolderPath -ItemType Directory -Force
Expand Down
2 changes: 1 addition & 1 deletion scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ param()

$PSStyle.OutputRendering = 'Ansi'

'platyPS' | ForEach-Object {
'Microsoft.PowerShell.PlatyPS' | ForEach-Object {
$name = $_
Write-Output "Installing module: $name"
$retryCount = 5
Expand Down
18 changes: 18 additions & 0 deletions tests/srcTestRepo/outputs/module/PSModuleTest/PSModuleTest.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ function Get-PSModuleTest {
.SYNOPSIS
Performs tests on a module.

.DESCRIPTION
Performs tests on a module.

.EXAMPLE
Test-PSModule -Name 'World'

Expand All @@ -282,6 +285,9 @@ function New-PSModuleTest {
.SYNOPSIS
Performs tests on a module.

.DESCRIPTION
Performs tests on a module.

.EXAMPLE
Test-PSModule -Name 'World'

Expand Down Expand Up @@ -310,10 +316,19 @@ function Set-PSModuleTest {
.SYNOPSIS
Performs tests on a module.

.DESCRIPTION
Performs tests on a module.

.EXAMPLE
Test-PSModule -Name 'World'

"Hello, World!"

.NOTES
Controls:
- :q : Quit
- :q! : Quit without saving
- :wq : Save and quit
Comment on lines +328 to +331
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .NOTES section contains vim editor commands that don't appear relevant to a PowerShell function named 'Set-PSModuleTest'. These controls should either be removed or replaced with appropriate notes about the function's behavior, dependencies, or usage.

Suggested change
Controls:
- :q : Quit
- :q! : Quit without saving
- :wq : Save and quit
This function outputs a greeting to the specified name. No additional dependencies.

Copilot uses AI. Check for mistakes.
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSUseShouldProcessForStateChangingFunctions', '', Scope = 'Function',
Expand All @@ -338,6 +353,9 @@ function Test-PSModuleTest {
.SYNOPSIS
Performs tests on a module.

.DESCRIPTION
Performs tests on a module.

.EXAMPLE
Test-PSModule -Name 'World'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
Test-PSModule -Name 'World'
"Hello, World!"
.NOTES
Controls:
- :q : Quit
- :q! : Quit without saving
- :wq : Save and quit
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSUseShouldProcessForStateChangingFunctions', '', Scope = 'Function',
Expand Down
Loading