Skip to content

🌟 [Major]: Version inputs now configure Pester#71

Draft
Marius Storhaug (MariusStorhaug) wants to merge 6 commits into
mainfrom
feat/68-configurable-pester-version
Draft

🌟 [Major]: Version inputs now configure Pester#71
Marius Storhaug (MariusStorhaug) wants to merge 6 commits into
mainfrom
feat/68-configurable-pester-version

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Jul 8, 2026

Copy link
Copy Markdown
Member

Invoke-Pester now treats Version and Prerelease as Pester controls. Workflows that previously used those inputs to choose the GitHub PowerShell module used by the init bootstrap step must rename them to GitHubVersion and GitHubPrerelease. Workflows that did not set Version or Prerelease keep installing the latest available Pester by default.

Breaking Changes

Version and Prerelease now apply to Pester, not the GitHub PowerShell module used internally during init.

Before this change, a workflow like this selected the GitHub module version:

- uses: PSModule/Invoke-Pester@vPrevious
  with:
    Version: '1.8.0'
    Prerelease: false

After this change, use the GitHub-prefixed inputs for the bootstrap module:

- uses: PSModule/Invoke-Pester@vNext
  with:
    GitHubVersion: '1.8.0'
    GitHubPrerelease: false

Use Version and Prerelease only when selecting the Pester version that should run the test suite:

- uses: PSModule/Invoke-Pester@vNext
  with:
    Version: '[6.0.0,7.0.0)'
    Prerelease: false

New: Pester version selection per workflow

Version accepts NuGet version syntax, including bare exact versions such as 6.0.0, exact-match ranges such as [6.0.0], and bounded ranges such as [5.0.0,6.0.0). When Version is empty, the action installs the latest available Pester version.

Prerelease controls whether prerelease Pester versions are allowed.

Changed: GitHub bootstrap versioning is GitHub-prefixed

The GitHub PowerShell module used by the init bootstrap step remains configurable, but its inputs are now GitHubVersion and GitHubPrerelease so they do not conflict with the action's Pester-focused inputs.

GitHubVersion also documents NuGet version-range syntax and is passed through to the GitHub-Script action's Version input. A bare version stays exact, matching the NuGet/PSResourceGet behavior described in PSModule/GitHub-Script#97.

Changed: Latest remains the default Pester behavior

Existing consumers can omit Version to keep installing the latest available Pester version. Teams that need a cap or exact version can set it in workflow configuration, while per-repository #Requires declarations remain the safety net that fails tests when the loaded Pester does not satisfy the repository's requirement.

Fixed: The loaded Pester version matches the selected version

The action now imports the exact Pester version resolved from the configured constraint. Version reporting also reflects the loaded module, so workflow logs show the Pester version that actually runs the tests.

Technical Details

  • Changed the public action API so Version and Prerelease are owned by Pester.
  • Moved the GitHub module bootstrap controls to GitHubVersion and GitHubPrerelease, then pass them through to PSModule/GitHub-Script as its Version and Prerelease inputs.
  • Updated init and exec phases to read Pester settings from PSMODULE_INVOKE_PESTER_INPUT_Version and PSMODULE_INVOKE_PESTER_INPUT_Prerelease.
  • Updated Install-PSResourceWithRetry to pass -Version, -Prerelease, and -PassThru to Install-PSResource, resolve the installed/satisfying version, and import it globally with Import-Module -RequiredVersion ... -Global -ErrorAction Stop.
  • Updated init/exec version logging from Get-PSResource to Get-Module so logs report the loaded version rather than the highest installed resource.
  • Added Action-Test coverage for a Pester 5.x range ([5.0.0,6.0.0)) and exact Pester 6.0.0; both constraint jobs pass in CI.
  • This supersedes ⚙️ [Maintenance]: Lock Pester to the 6.x major version #70's hardcoded [6.0.0,7.0.0) action-level lock and leaves GUID identity pinning as a later enhancement for 🚀 [Feature]: Install the pinned Pester version — support #Requires-style version constraints on the Version input #68.

Add Pester_Version and Pester_Prerelease inputs so consumers can constrain the
installed Pester (NuGet range syntax, e.g. [6.0.0,7.0.0)) while the action keeps
defaulting to the latest version. This removes the need to bake a version lock
into the shared action.

Install-PSResourceWithRetry now installs the version satisfying the constraint
and imports that exact version into the global session state, so the Pester that
runs is deterministic even when the runner ships a different preinstalled Pester
(previously PowerShell auto-loaded the highest version on PSModulePath). The
'test kit versions' output now reports the imported version via Get-Module.

Relates to #68. Supersedes #70.
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title 🚀 [Feature]: Make the Pester version configurable (default latest) 🚀 [Feature]: Workflows can choose the Pester version Jul 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds workflow-configurable Pester version selection to the PSModule/Invoke-Pester GitHub Action, while keeping the default behavior of installing the latest Pester when no constraint is provided. It wires new action inputs through to the init/exec phases, updates the install/import logic to load the resolved module version deterministically, and adds CI coverage for both a Pester 5.x range and an exact Pester 6.0.0 pin.

Changes:

  • Added PesterVersion and PesterPrerelease inputs and propagated them via PSMODULE_INVOKE_PESTER_INPUT_* environment variables.
  • Updated Install-PSResourceWithRetry to install with optional version/prerelease constraints and import the resolved module version globally.
  • Added Action-Test workflow jobs and test suites validating a Pester 5.x range constraint and an exact Pester 6.0.0 constraint.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
action.yml Adds new inputs and passes them into init/exec environment variables.
src/init.ps1 Installs/imports Pester using the new inputs; logs loaded Pester via Get-Module.
src/exec.ps1 Mirrors init behavior for exec/eval phases; logs loaded Pester via Get-Module.
src/Helpers.psm1 Extends installer helper to pass -Version/-Prerelease, resolve installed version, and import deterministically.
README.md Documents the new inputs and the deterministic import behavior.
.github/workflows/Action-Test.yml Adds CI jobs to validate Pester version range/exact constraints.
tests/Test-ActionResults.ps1 Aggregates new Action-Test job results into the summary table.
tests/4-PesterVersionConstraints/Pester5Range/PesterVersion.Tests.ps1 New test verifying a resolved Pester 5.x version satisfies bounds.
tests/4-PesterVersionConstraints/Pester6Exact/PesterVersion.Tests.ps1 New test verifying exact Pester 6.0.0 is loaded.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Helpers.psm1
Comment on lines +1374 to +1379
if ($resolved) {
Write-Output "Importing module: $Name $($resolved.Version)"
Import-Module -Name $Name -RequiredVersion $resolved.Version -Force -Global -ErrorAction Stop
} else {
Import-Module -Name $Name -Force -Global
}
Comment thread README.md Outdated
Comment on lines +264 to +268
| **Input** | **Description** | **Default** |
|--------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
| `Path` | Path to where tests are located or a configuration file. | *(none)* |
| `PesterVersion` | Version of Pester to install (NuGet range, e.g. `[6.0.0,7.0.0)` for any 6.x). Empty installs the latest version. | `latest` |
| `PesterPrerelease` | Allow installing prerelease versions of Pester. | `false` |
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title 🚀 [Feature]: Workflows can choose the Pester version 🌟 [Major]: Version inputs now configure Pester Jul 9, 2026
Bumps
[PSModule/GitHub-Script](https://github.com/PSModule/GitHub-Script) from
1.8.0 to 1.9.0.

- Pin: `8083ec1f733f00357ee4d0db0c6056686e483bc0` (`# v1.9.0`)
- Release notes:
https://github.com/PSModule/GitHub-Script/releases/tag/v1.9.0

Co-authored-by: Marius Storhaug <Marius.Storhaug@dnb.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants