🩹 [Patch]: Ensure only the selected module version is loaded#74
Open
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Open
🩹 [Patch]: Ensure only the selected module version is loaded#74Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
Conversation
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 started reviewing on behalf of
Marius Storhaug (MariusStorhaug)
July 11, 2026 17:24
View session
There was a problem hiding this comment.
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-PSResourceWithRetryto 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.
| # then import into the global session state so the resolved version is the one every subsequent | ||
| # command (for example Invoke-Pester in exec.ps1) uses, instead of PowerShell auto-loading the | ||
| # highest version available on PSModulePath. | ||
| Remove-Module -Name $Name -Force -ErrorAction SilentlyContinue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the version selected through the
Version/Prereleaseinputs the only version of the module loaded in the session. The helper already imported the resolved version with-Force -Global, but a different version that was already loaded (for example the runner's preinstalled copy, loaded side-by-side) could remain in the session alongside it.Fixed: only the selected module version stays loaded
Install-PSResourceWithRetrynow removes any already-loaded versions of the module from the session before importing the resolved version. This applies to every module the action provisions through the helper (Pester and its helper modules), guaranteeing the run uses exactly the selected version.Technical Details
src/Invoke-Pester.Helpers.psm1: addedRemove-Module -Name $Name -Force -ErrorAction SilentlyContinueimmediately before theImport-Module -RequiredVersion … -Force -Globalstep, and updated the function help to describe it.