Skip to content

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

Open
Marius Storhaug (MariusStorhaug) wants to merge 1 commit 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 1 commit into
mainfrom
fix/ensure-single-loaded-module-version

Conversation

@MariusStorhaug

Copy link
Copy Markdown
Member

Makes the version selected through the Version/Prerelease inputs 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-PSResourceWithRetry now 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: added Remove-Module -Name $Name -Force -ErrorAction SilentlyContinue immediately before the Import-Module -RequiredVersion … -Force -Global step, and updated the function help to describe it.
  • 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.

# 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
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