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
6 changes: 5 additions & 1 deletion .github/actions/Get-PesterCodeCoverage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ Summary:

## Requirements

1. **Pester Code Coverage Reports**
1. **Pester 6.1 Code Coverage Reports**

Preceding steps must generate JSON coverage reports named `*-CodeCoverage*.json`
from the Pester 6.1 `CodeCoverage` result object. The action consumes
`CoveragePercent`, `CoveragePercentTarget`, `CommandsMissed`,
`CommandsExecuted`, and `FilesAnalyzed` plus their count properties.

2. **GitHub CLI**
The action uses `gh run download` to fetch artifacts from the current workflow run
Expand Down
5 changes: 3 additions & 2 deletions .github/actions/Test-PSModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ inputs:
required: false
CodeCoverage_OutputFormat:
description: |
Format to use for code coverage report. Possible values: JaCoCo, CoverageGutters, Cobertura
Format to use for code coverage report. Possible values in Pester 6.1: JaCoCo or Cobertura.
required: false
CodeCoverage_OutputPath:
description: |
Expand Down Expand Up @@ -113,7 +113,7 @@ inputs:
required: false
CodeCoverage_UseBreakpoints:
description: |
EXPERIMENTAL: When false, use Profiler based tracer to do CodeCoverage instead of using breakpoints.
When false, use the profiler-based tracer instead of breakpoints for code coverage.
required: false
CodeCoverage_SingleHitBreakpoints:
description: |
Expand Down Expand Up @@ -288,6 +288,7 @@ runs:
with:
Debug: ${{ inputs.Debug }}
Verbose: ${{ inputs.Verbose }}
Version: '[6.1.0,7.0.0)'
GitHubVersion: ${{ inputs.Version }}
GitHubPrerelease: ${{ inputs.Prerelease }}
WorkingDirectory: ${{ inputs.WorkingDirectory }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if ($hasClassExporter) {


# Run-phase setup — recompute from $Path so that It/Context blocks can use these variables.
# Pester v5 Discovery and Run are separate executions. The script-scope variables above drive
# Pester 6 Discovery and Run are separate executions. The script-scope variables above drive
# -Skip and -ForEach during Discovery. This BeforeAll recomputes the same values for the Run
# phase, where It blocks actually execute. The duplication is intentional and required.
BeforeAll {
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/Test-Actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,33 @@ jobs:
- name: Install test dependencies
shell: pwsh
run: |
Install-PSResource -Name Pester -Version '[5.7.1,6.0.0)' -Repository PSGallery -TrustRepository
Install-PSResource -Name Pester -Version '[6.1.0,7.0.0)' -Repository PSGallery -TrustRepository
Install-PSResource -Name PSSemVer -Repository PSGallery -TrustRepository
Install-PSResource -Name GitHub -Version '[0.43.1,0.44.0)' -Repository PSGallery -TrustRepository

- name: Run action unit tests
shell: pwsh
run: |
$configuration = New-PesterConfiguration
$configuration.Run.Shuffle = $true
$configuration.Run.ShuffleSeed = 42
$configuration.Run.Parallel = $true
$configuration.Run.ParallelThrottleLimit = 2
$configuration.Debug.ShowStartMarkers = $true

$expectedOptions = @{
'Run.Shuffle' = $configuration.Run.Shuffle.Value
'Run.ShuffleSeed' = $configuration.Run.ShuffleSeed.Value -eq 42
'Run.Parallel' = $configuration.Run.Parallel.Value
'Run.ParallelThrottleLimit' = $configuration.Run.ParallelThrottleLimit.Value -eq 2
'Debug.ShowStartMarkers' = $configuration.Debug.ShowStartMarkers.Value
}
foreach ($option in $expectedOptions.GetEnumerator()) {
if (-not $option.Value) {
throw "Pester 6.1 configuration option [$($option.Key)] was not applied."
}
}

$testPaths = Get-ChildItem -Path '.github/actions' -Directory |
ForEach-Object { Join-Path -Path $_.FullName -ChildPath 'tests' } |
Where-Object { Test-Path -Path $_ }
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/Test-ModuleLocal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ jobs:
uses: PSModule/Invoke-Pester@4ff33199141fdf22568990b6107fe3148ae93a1c # v5.1.0
with:
Debug: ${{ fromJson(inputs.Settings).Debug }}
Prerelease: ${{ fromJson(inputs.Settings).Prerelease }}
Verbose: ${{ fromJson(inputs.Settings).Verbose }}
Version: ${{ fromJson(inputs.Settings).Version }}
Version: '[6.1.0,7.0.0)'
GitHubVersion: ${{ fromJson(inputs.Settings).Version }}
GitHubPrerelease: ${{ fromJson(inputs.Settings).Prerelease }}
TestResult_TestSuiteName: ${{ matrix.TestName }}-${{ matrix.OSName }}
TestResult_Enabled: true
CodeCoverage_Enabled: true
Expand Down
19 changes: 14 additions & 5 deletions docs/content/guides/writing-module-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,24 @@ been built and imported.

## Pester version

Module test files declare a Pester **6.x** requirement at the top of each `*.Tests.ps1`:
Module test files declare a Pester **6.1.x** requirement at the top of each `*.Tests.ps1`:

```powershell
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.*' }
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.1.0'; MaximumVersion = '6.*' }
```

This is a convention module authors add, not something the pipeline injects. The
[Invoke-Pester](https://github.com/PSModule/Invoke-Pester) action installs a matching `6.x`, so minor and patch updates
flow in automatically while a new major stays a deliberate, reviewed change.
This is a convention module authors add. Process-PSModule pins its reusable
[Invoke-Pester](https://github.com/PSModule/Invoke-Pester) action runs to the
`[6.1.0,7.0.0)` range, so patch updates flow in automatically while a new
major stays a deliberate, reviewed change.

Pester 6.1 adds opt-in controls for shuffled and parallel file execution
(`Run.Shuffle`, `Run.ShuffleSeed`, `Run.Parallel`, and
`Run.ParallelThrottleLimit`) and diagnostic start markers
(`Debug.ShowStartMarkers`). These controls are available when invoking Pester
directly with `New-PesterConfiguration`. Process-PSModule's reusable action will
expose them after the coordinated `PSModule/Invoke-Pester` action adds matching
inputs; the current v5.1.0 action contract does not accept them.

## Test discovery

Expand Down
2 changes: 1 addition & 1 deletion docs/content/reference/powershell-module-standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Process-PSModule derives `TestName` from the file's basename before the first do
Each `*.Tests.ps1` file must declare the Pester 6 requirement:

```powershell
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.*' }
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.1.0'; MaximumVersion = '6.*' }
```

Tests run against the built module artifact installed locally, across a multi-OS matrix (Linux, macOS, Windows). The full suite must also remain runnable locally without mandatory cloud resources, special access, or secrets that cannot be mocked.
Expand Down
Loading