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
9 changes: 8 additions & 1 deletion instructions/repository-specific.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@

## Testing

Tests live in `tests/` and use **Pester 5+** syntax.
Tests live in `tests/` and run on **Pester 6.0.0** (pinned exactly in `requirements.psd1`;
see psake/PowerShellBuild#17 for the targeting decision). Write assertions with the classic
`Should -Be` syntax — valid in both Pester 5 and 6 — rather than the Pester 6-only `Should-*`
assertion family, so tests remain backportable. The shipped module's own Pester compatibility

Check warning on line 240 in instructions/repository-specific.instructions.md

View workflow job for this annotation

GitHub Actions / CI / Run Linters

Unknown word (backportable)
floor (5.0.0 in `Test-PSBuildPester`) is a separate contract and is unchanged.

- Always build the module before running Pester directly — running against source can produce
incorrect results. Prefer `./build.ps1 -Task Test` over a raw `Invoke-Pester` call.
Expand Down Expand Up @@ -262,7 +266,7 @@

- Triggers: manual dispatch, GitHub release published
- Runs on: `ubuntu-latest`
- Reads `PSGALLERY_API_KEY` secret, converts to `PSCredential`, runs

Check warning on line 269 in instructions/repository-specific.instructions.md

View workflow job for this annotation

GitHub Actions / CI / Run Linters

Unknown word (PSGALLERY) Suggestions: (psaltery, spaller, psaltry, psalter, psalters)
`./build.ps1 -Task Publish -PSGalleryApiKey $cred -Bootstrap`

## Repo-Specific Conventions
Expand All @@ -280,6 +284,9 @@
- **Script analysis**: PSScriptAnalyzer config is `PowerShellBuild/ScriptAnalyzerSettings.psd1`.
Default severity threshold for build failure is `Error`. Warnings are reported but don't
fail the build.
- **Changelog scope**: `CHANGELOG.md` documents user-facing changes to the shipped module
only. Repository-internal changes — development dependencies, CI workflows, this repo's own
build scripts, or the test suite — do not get changelog entries.
- **Spell-checker ignores**: inline comments — `# spell-checker:ignore MAML PSGALLERY`.

## How Consumers Use This Module
Expand Down Expand Up @@ -340,9 +347,9 @@
| ------------------------- | ---------------------------------------------------- |
| `$env:BHProjectPath` | Repository root directory |
| `$env:BHProjectName` | Module name (from directory structure) |
| `$env:BHPSModulePath` | Path to module source directory |

Check warning on line 350 in instructions/repository-specific.instructions.md

View workflow job for this annotation

GitHub Actions / CI / Run Linters

Unknown word (BHPS) Suggestions: (baps, bops, bhp, BHP, bps)
| `$env:BHPSModuleManifest` | Path to `.psd1` manifest |

Check warning on line 351 in instructions/repository-specific.instructions.md

View workflow job for this annotation

GitHub Actions / CI / Run Linters

Unknown word (BHPS) Suggestions: (baps, bops, bhp, BHP, bps)
| `$env:BHModulePath` | Same as `BHPSModulePath` |

Check warning on line 352 in instructions/repository-specific.instructions.md

View workflow job for this annotation

GitHub Actions / CI / Run Linters

Unknown word (BHPS) Suggestions: (baps, bops, bhp, BHP, bps)
| `$env:BHBuildSystem` | Detected CI system (e.g., `GitHubActions`, `Unknown`)|
| `$env:BHBranchName` | Current git branch |
| `$env:BHCommitMessage` | Latest git commit message |
Expand Down
2 changes: 1 addition & 1 deletion requirements.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}
BuildHelpers = '2.0.16'
Pester = @{
Version = '5.8.0'
Version = '6.0.0'
Parameters = @{
SkipPublisherCheck = $true
}
Expand Down
69 changes: 40 additions & 29 deletions tests/Help.tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Taken with love from @juneb_get_help (https://raw.githubusercontent.com/juneb/PesterTDD/master/Module.Help.Tests.ps1)

Check warning on line 1 in tests/Help.tests.ps1

View workflow job for this annotation

GitHub Actions / CI / Run Linters

Unknown word (juneb) Suggestions: (june, junes, June, Junes, jube)

BeforeDiscovery {
function global:FilterOutCommonParams {
Expand All @@ -8,7 +8,7 @@
$params | Where-Object { $_.Name -notin $commonParams } | Sort-Object -Property Name -Unique
}

$manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest

Check warning on line 11 in tests/Help.tests.ps1

View workflow job for this annotation

GitHub Actions / CI / Run Linters

Unknown word (BHPS) Suggestions: (baps, bops, bhp, BHP, bps)
$outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output'
$outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName
$outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion
Expand Down Expand Up @@ -44,6 +44,8 @@
$commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters
$commandParameterNames = $commandParameters.Name
$helpLinks = $commandHelp.relatedLinks.navigationLink.uri
$helpParameters = global:FilterOutCommonParams -Params $commandHelp.Parameters.Parameter
$helpParameterNames = $helpParameters.Name
}

BeforeAll {
Expand Down Expand Up @@ -77,41 +79,50 @@
($commandHelp.Examples.Example.Remarks | Select-Object -First 1).Text | Should -Not -BeNullOrEmpty
}

It "Help link <_> is valid" -ForEach $helpLinks {
(Invoke-WebRequest -Uri $_ -UseBasicParsing).StatusCode | Should -Be '200'
}

Context "Parameter <_.Name>" -Foreach $commandParameters {

BeforeAll {
$parameter = $_
$parameterName = $parameter.Name
$parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -eq $parameterName
$parameterHelpType = if ($parameterHelp.ParameterValue) { $parameterHelp.ParameterValue.Trim() }
}

# Should be a description for every parameter
It "Has description" {
$parameterHelp.Description.Text | Should -Not -BeNullOrEmpty
}

# Required value in Help should match IsMandatory property of parameter
It "Has correct [mandatory] value" {
$codeMandatory = $_.IsMandatory.toString()
$parameterHelp.Required | Should -Be $codeMandatory
# The if guards around the data-driven blocks below skip generation when the
# collection is empty. Pester 5 skipped empty -ForEach silently; Pester 6 fails
# discovery instead, and these guards keep the v5 behavior on both versions.
if ($helpLinks) {
It "Help link <_> is valid" -ForEach $helpLinks {
(Invoke-WebRequest -Uri $_ -UseBasicParsing).StatusCode | Should -Be '200'
}
}

# Parameter type in help should match code
It "Has correct parameter type" {
$parameterHelpType | Should -Be $parameter.ParameterType.Name
if ($commandParameters) {
Context "Parameter <_.Name>" -Foreach $commandParameters {

BeforeAll {
$parameter = $_
$parameterName = $parameter.Name
$parameterHelp = $commandHelp.parameters.parameter | Where-Object Name -eq $parameterName
$parameterHelpType = if ($parameterHelp.ParameterValue) { $parameterHelp.ParameterValue.Trim() }
}

# Should be a description for every parameter
It "Has description" {
$parameterHelp.Description.Text | Should -Not -BeNullOrEmpty
}

# Required value in Help should match IsMandatory property of parameter
It "Has correct [mandatory] value" {
$codeMandatory = $_.IsMandatory.toString()
$parameterHelp.Required | Should -Be $codeMandatory
}

# Parameter type in help should match code
It "Has correct parameter type" {
$parameterHelpType | Should -Be $parameter.ParameterType.Name
}
}
}

Context "Test <_> help parameter help for <commandName>" -Foreach $helpParameterNames {
if ($helpParameterNames) {
Context "Test <_> help parameter help for <commandName>" -Foreach $helpParameterNames {

# Shouldn't find extra parameters in help.
It "finds help parameter in code: <_>" {
$_ -in $parameterNames | Should -Be $true
# Shouldn't find extra parameters in help.
It "finds help parameter in code: <_>" {
Comment thread
tablackburn marked this conversation as resolved.
$_ -in $commandParameterNames | Should -Be $true
}
Comment thread
tablackburn marked this conversation as resolved.
}
}
}
Loading