Skip to content

🌟 [Major]: Version and Prerelease inputs now control Pester#71

Merged
Marius Storhaug (MariusStorhaug) merged 10 commits into
mainfrom
feat/68-configurable-pester-version
Jul 9, 2026
Merged

🌟 [Major]: Version and Prerelease inputs now control Pester#71
Marius Storhaug (MariusStorhaug) merged 10 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.
  • Hardened the Pester import to fail fast when Version is set but no satisfying installed version can be resolved, instead of silently importing an unconstrained module; the no-Version fallback now imports with -ErrorAction Stop.
  • 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 Install the Pester version requested by 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 thread README.md Outdated
@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>
…docs

Address Copilot review threads on PR #71:

- Helpers.psm1: when -Version is set but no satisfying installed version resolves, throw instead of silently importing an unconstrained module from PSModulePath (defeats deterministic selection, issue #68). Add -ErrorAction Stop to the unconstrained fallback so a missing module surfaces clearly.

- README.md: the Version and GitHubVersion inputs have no action.yml default; correct the Default column from 'latest' to *(none)* (behavior 'empty installs latest' is already in the description) so users don't literally set Version: latest.

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

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

The repo PSScriptAnalyzer settings (.github/linters/.powershell-psscriptanalyzer.psd1) enforce PSAvoidLongLines with a 150-char max; the new throw line was 199 chars and failed the POWERSHELL super-linter. Shortened to a single 126-char message; the rationale remains in the preceding comment.

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

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

Comment thread src/Invoke-Pester.Helpers.psm1
Comment thread .github/workflows/Action-Test.yml Outdated
Comment thread .github/workflows/Action-Test.yml Outdated
Aligns with the action helper-module naming standard: name the module after the action, not the generic Helpers. Invoke-Pester loads the shared framework Helpers module into the test session, so its own Helpers module was the primary source of the name collision that broke -ModuleName mocking in tested modules. Renames src/Helpers.psm1 to src/Invoke-Pester.Helpers.psm1 and updates the exec.ps1 and init.ps1 imports; keeps the framework Helpers usage (LogGroup). No runtime logic changed. Part of PSModule/Process-PSModule#364.

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

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

@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title 🌟 [Major]: Version inputs now configure Pester 🌟 [Major]: Version and Prerelease inputs now control Pester Jul 9, 2026
Copilot flagged that its should be it is (contraction) in two checkout-step comments; the same typo appears in all 11 test jobs, so corrected every occurrence for consistency.
Copilot AI review requested due to automatic review settings July 9, 2026 12:53

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

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

@MariusStorhaug Marius Storhaug (MariusStorhaug) merged commit 8a4e652 into main Jul 9, 2026
30 checks passed
@MariusStorhaug Marius Storhaug (MariusStorhaug) deleted the feat/68-configurable-pester-version branch July 9, 2026 14:07
Marius Storhaug (MariusStorhaug) added a commit that referenced this pull request Jul 9, 2026
Adds an optional `Guid` input so a workflow can pin Pester by **module
identity (GUID)**, validated at install time. Combined with a
`#Requires` GUID pin in test files, identity is validated **the whole
way** — on the developer's machine and in CI at discovery, and now also
in CI at the action's install step (shifted left, one clear failure
point).

- Fixes #68

## Added: `Guid` input for module-identity pinning

The optional `Guid` input pins Pester by module identity. After
resolving and installing the version, the action validates the loaded
module's GUID and **fails fast** if it does not match — guarding against
a different module named `Pester` on the runner's `PSModulePath`.

```yaml
- uses: PSModule/Invoke-Pester@v5
  with:
    Version: '6.0.0'
    Guid: 'a699dea5-2c73-4616-a270-1f7abb777e71'
```

Validation now happens at every layer:

- **Developer machine / CI at test discovery** — via `#Requires -Modules
@{ ...; GUID = ... }` in test files.
- **CI at the action's init/install step** — via the new `Guid` input
(earliest single point of failure).

## Technical Details

- `action.yml`: new optional `Guid` input, passed to both the init and
exec phases via `PSMODULE_INVOKE_PESTER_INPUT_Guid`.
- `Install-PSResourceWithRetry`: new `-Guid` parameter; after import, it
validates the loaded module's `Guid` and throws a clear error on
mismatch. `Install-PSResource` cannot select by GUID (gallery identity
is name + version), so identity is enforced at import.
- `init.ps1` / `exec.ps1`: read the input and pass `-Guid` through.
- Tests:
- `PesterGuidPin` pins via **both** the `Guid` input and `#Requires`
(validating the whole way).
- `PesterGuidMatch` pins via the `Guid` input only (version-only
`#Requires`), asserting a matching GUID lets the run **succeed**.
- `PesterGuidMismatch` passes a wrong `Guid` and asserts the action
**fails**.
- Docs: README input table updated.
- Verified locally: a correct GUID imports; a wrong GUID throws `Loaded
'Pester' does not match the required GUID ...`.

This closes the last remaining item on #68 — the version-selection core
shipped in #71 (v5.0.0), and this adds the optional GUID identity pin.
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