Skip to content

🩹 [Patch]: Ensure only the selected module version is loaded#74

Open
Marius Storhaug (MariusStorhaug) wants to merge 3 commits into
mainfrom
fix/ensure-single-loaded-module-version
Open

🩹 [Patch]: Ensure only the selected module version is loaded#74
Marius Storhaug (MariusStorhaug) wants to merge 3 commits into
mainfrom
fix/ensure-single-loaded-module-version

Conversation

@MariusStorhaug

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

Copy link
Copy Markdown
Member

Makes the version selected through the Version/Prerelease inputs the only version of the module that is installed and loaded in the session, for every module the action provisions through Install-PSResourceWithRetry (Pester and its helper modules).

Fixed: only the selected module version is loaded

Install-PSResourceWithRetry now:

  • Resolves the exact installed version that satisfies the request, honoring Prerelease — when prerelease versions are not requested it never resolves to one, with a stable-wins tie-breaker when a stable and a prerelease share the same base version (uses the PSResourceGet Prerelease string).
  • Fails fast when a requested version constraint cannot be satisfied, before mutating session state.
  • Removes every already-loaded instance of the module (Get-Module -Name $Name -All | Remove-Module) so no side-by-side version remains.
  • Imports the resolved version with -RequiredVersion … -Force -Global so the loaded module is deterministic rather than whatever PowerShell auto-loads from PSModulePath.

Technical Details

  • src/Invoke-Pester.Helpers.psm1: prerelease-aware resolution (filter + tie-breaker), fail-fast before unload, remove-all-instances, and updated function help.
  • No input or interface changes.

Install-PSResourceWithRetry now removes any already-loaded versions of the module from the session before importing the resolved version, so the selected version is the only one loaded (not a side-by-side or runner-preinstalled copy).

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 tightens module determinism for the GitHub Action by ensuring that the module version resolved via the Version/Prerelease inputs is the only version loaded in the current PowerShell session.

Changes:

  • Updates Install-PSResourceWithRetry to remove already-loaded module versions before importing the resolved version.
  • Adjusts comment-based help text to reflect the “only loaded version” behavior.

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

Comment thread src/Invoke-Pester.Helpers.psm1 Outdated

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 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/Invoke-Pester.Helpers.psm1 Outdated
…n prerelease-aware

Per PR review: use 'Get-Module -Name \ -All | Remove-Module' so every loaded instance (all versions, including nested) is removed before import; and when Prerelease is not requested, exclude prerelease candidates from resolution and add a stable-wins tie-breaker so a prerelease is never selected over a stable of the same base version.
Copilot AI review requested due to automatic review settings July 12, 2026 09:59

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 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread src/Invoke-Pester.Helpers.psm1
Comment thread src/Invoke-Pester.Helpers.psm1
Comment thread src/Invoke-Pester.Helpers.psm1
…ore unloading

Filter/sort on the PSResourceGet 'Prerelease' string (present on both Install-PSResource and Get-InstalledPSResource output) instead of IsPrerelease; and move the unresolvable-constraint throw before Get-Module|Remove-Module so session state is not mutated when the function is going to fail.
Copilot AI review requested due to automatic review settings July 12, 2026 10:20

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 1 out of 1 changed files in this pull request and generated no new comments.

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 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread src/Invoke-Pester.Helpers.psm1
Comment thread src/Invoke-Pester.Helpers.psm1
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