Skip to content

🚀 [Minor]: Add optional GUID identity pinning to Pester selection#73

Merged
Marius Storhaug (MariusStorhaug) merged 6 commits into
mainfrom
test/68-guid-pin
Jul 9, 2026
Merged

🚀 [Minor]: Add optional GUID identity pinning to Pester selection#73
Marius Storhaug (MariusStorhaug) merged 6 commits into
mainfrom
test/68-guid-pin

Conversation

@MariusStorhaug

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

Copy link
Copy Markdown
Member

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).

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.

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

New Action-Test job runs a test whose #Requires pins Pester by module identity (GUID) plus version, and asserts the loaded module Guid and Version. Wired into CatchJob needs, aggregated env vars, and Test-ActionResults.ps1. Related to #68.
Copilot AI review requested due to automatic review settings July 9, 2026 16:31
@MariusStorhaug Marius Storhaug (MariusStorhaug) added NoRelease github_actions Pull requests that update GitHub Actions code labels Jul 9, 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

Adds a new CI “Action-Test” job and matching expected-results entry to validate that Pester can be pinned not just by version, but also by module identity (GUID) via a test file #Requires -Modules constraint. This extends the existing version-constraint coverage with a “safety-net” scenario aligned with the GUID pinning discussion in #68.

Changes:

  • Added a new Pester test suite that uses #Requires -Modules with RequiredVersion + GUID and asserts the loaded module’s Guid and Version.
  • Added a new ActionTestPesterGuidPin job to Action-Test.yml and wired it into the CatchJob aggregation.
  • Added the new job’s expected outcome to tests/Test-ActionResults.ps1.

Reviewed changes

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

File Description
tests/Test-ActionResults.ps1 Adds expected results for the new “Pester GUID Pin” Action-Test job.
tests/4-PesterVersionConstraints/PesterGuidPin/PesterVersion.Tests.ps1 New test demonstrating #Requires GUID pinning and validating loaded Pester identity/version.
.github/workflows/Action-Test.yml Adds a new CI job to run the GUID-pin test and exports its results to the aggregator job.

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

New Guid action input validates the loaded Pester module GUID after install (via Import-Module identity check), failing fast at init when a different module named Pester is present. Wired through action.yml, init.ps1 and exec.ps1. The existing PesterGuidPin job now also passes Guid (validating at both install and #Requires layers), and a new PesterGuidMismatch job asserts a wrong GUID fails the action. Documented in README. Related to #68.
Copilot AI review requested due to automatic review settings July 9, 2026 17:42
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title ⚙️ [Maintenance]: Add a Pester GUID-pin test to the version-constraint suite 🚀 [Minor]: Add optional GUID identity pinning to Pester selection Jul 9, 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

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

Comment thread action.yml
Comment thread src/Invoke-Pester.Helpers.psm1
Comment thread tests/4-PesterVersionConstraints/PesterGuidPin/PesterVersion.Tests.ps1 Outdated
Positive counterpart to PesterGuidMismatch: passes the correct Guid via the action input with a version-only (no GUID) #Requires, isolating and proving the matching Guid input lets the run proceed and the tests pass. Wired into CatchJob needs, env vars, and Test-ActionResults.ps1.
Copilot AI review requested due to automatic review settings July 9, 2026 18:10

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 1 comment.

Comment thread src/Invoke-Pester.Helpers.psm1
Address Copilot review on PR #73: validate the exact module returned by Import-Module -PassThru (not the highest loaded version) so a side-by-side load cannot mask a mismatch; parse the Guid with [guid]::TryParse for a clear error on malformed input. The PesterGuidPin and PesterGuidMatch tests now select the expected version explicitly instead of the highest loaded.
Copilot AI review requested due to automatic review settings July 9, 2026 18:19

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 1 comment.

Comment thread src/Invoke-Pester.Helpers.psm1
Address Copilot review on PR #73: the fallback used Get-PSResource, which is the installed-resource query (alias of Get-InstalledPSResource; the gallery cmdlet is Find-PSResource). Switched to the explicit Get-InstalledPSResource so the installed-only intent is unambiguous and to avoid the alias.
Copilot AI review requested due to automatic review settings July 9, 2026 18:31

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 1 comment.

Comment thread .github/workflows/Action-Test.yml
Address Copilot review on PR #73: add ActionTestPesterGuidMismatch to CatchJob.needs so the aggregate/step-summary runs only after the negative job completes. The negative job stays self-asserting (a wrong Guid aborts the action at init, leaving empty Executed/Result that do not fit the success-oriented results table). Clarified the Test-ActionResults description accordingly.
Copilot AI review requested due to automatic review settings July 9, 2026 18:38

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 4ff3319 into main Jul 9, 2026
33 checks passed
@MariusStorhaug Marius Storhaug (MariusStorhaug) deleted the test/68-guid-pin branch July 9, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code Minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install the Pester version requested by the Version input

2 participants