Skip to content

feat(ci): add a Windows PowerShell 5.1 Pester leg - #212

Merged
kurone-kito merged 6 commits into
masterfrom
issue/166-feat-ci-add-windows-powershell-5-1
Jul 24, 2026
Merged

feat(ci): add a Windows PowerShell 5.1 Pester leg#212
kurone-kito merged 6 commits into
masterfrom
issue/166-feat-ci-add-windows-powershell-5-1

Conversation

@kurone-kito

@kurone-kito kurone-kito commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #166.

The Pester matrix only ran Linux pwsh and Windows pwsh, both of
which define $IsWindows as a real boolean, so the PS5.1 bug class
($IsWindows is $null) was structurally undetectable. PS5.1 is a
real execution surface: the profile loader is wired into the
WindowsPowerShell Documents directory.

  • Adds powershell51-tests to the CI matrix, running under the inbox
    Windows PowerShell shell (not pwsh), asserting the major version
    is 5, installing Pester 5 (inbox 3.4 cannot run this suite), and
    running the same tests/powershell/ entry point. Kept advisory
    (not in the ruleset's required-check set) until it proves stable.
  • Fixes 6 Unix-only-test -Skip: guards that were not PS5.1-null-safe:
    under PS5.1 $IsWindows is $null, so -Skip:($IsWindows -eq $true) evaluates to "not skipped" and Unix-only tests would run and
    fail on Windows. Converted to -Skip:($IsWindows -ne $false),
    matching the pattern 30-mise.Tests.ps1 already uses for its Unix
    Describe block (02-cargo.Tests.ps1 line 12,
    secret-status.Tests.ps1 lines 95/110/159/178/213).

Test plan

  • Ran the two touched spec files plus the full tests/powershell/
    suite under this box's pwsh (PS7) — 202/207 pass, the 5
    remaining failures are pre-existing non-Windows-local failures
    unrelated to this change (PSReadLine/OnIdle mocks, tailscale
    serve mock)
  • npx markdownlint-cli2 "**/*.md" — 0 issues
  • Workflow YAML parses (npx js-yaml)
  • New powershell51-tests job runs green on this PR and echoes
    $PSVersionTable.PSVersion.Major -eq 5 — verified from CI, no
    local Windows PowerShell 5.1 available to pre-check

🤖 Generated with Claude Code

https://claude.ai/code/session_01Dz1GQ6a5w3RPxbU1mxsdP1

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when writing deployment state and generated configuration files by consistently using UTF-8 encoding without a byte-order mark.
    • Preserved expected file formatting, including trailing newlines, across supported environments.
  • Tests

    • Added automated coverage for Windows PowerShell 5.1.
    • Improved cross-platform validation for path handling, secret deployment, profile generation, and authorization key management.

The Pester matrix only ran Linux pwsh and Windows pwsh, both of which
define $IsWindows as a real boolean, so the PS5.1 bug class ($IsWindows
is $null) was structurally undetectable. PS5.1 is a real execution
surface: the profile loader is wired into the WindowsPowerShell
Documents directory.

- Add powershell51-tests to the CI matrix, running under the inbox
  Windows PowerShell shell (not pwsh), asserting the major version is
  5, installing Pester 5 (inbox 3.4 cannot run this suite), and running
  the same tests/powershell/ entry point. Kept advisory (not in the
  ruleset's required-check set) until it proves stable.
- Fix 6 Unix-only-test -Skip: guards that were not PS5.1-null-safe:
  under PS5.1 $IsWindows is $null, so -Skip:($IsWindows -eq $true)
  evaluates to "not skipped" and Unix-only tests would run and fail on
  Windows. Converted to -Skip:($IsWindows -ne $false), matching the
  pattern 30-mise.Tests.ps1 already uses for its Unix Describe block.
Copilot AI review requested due to automatic review settings July 24, 2026 12:36
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kurone-kito, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a6669c44-95e9-46b9-8bc9-e10118e56184

📥 Commits

Reviewing files that changed from the base of the PR and between dcfa078 and 1a412c0.

📒 Files selected for processing (6)
  • .cspell.config.yml
  • .github/workflows/test.yml
  • tests/powershell/30-mise.Tests.ps1
  • tests/powershell/secret-deploy-state.Tests.ps1
  • tests/powershell/secret-status.Tests.ps1
  • tests/powershell/signing-resolve.Tests.ps1
📝 Walkthrough

Walkthrough

The pull request adds a Windows PowerShell 5.1 Pester CI job, updates platform guards for PS5.1 semantics, replaces several PowerShell file writes with explicit UTF-8 .NET writes, and changes test path construction to nested Join-Path calls.

Changes

PowerShell 5.1 compatibility

Layer / File(s) Summary
Explicit filesystem encoding and paths
home/dot_local/bin/..., tests/powershell/fixtures/*, tests/powershell/generate-authorized-keys.Tests.ps1, tests/powershell/signing-resolve.Tests.ps1
Scripts and fixtures now use resolved filesystem paths and explicit UTF-8-without-BOM writes.
PS5.1-safe platform guards
tests/powershell/02-cargo.Tests.ps1, tests/powershell/secret-status.Tests.ps1
Pester skip expressions now handle the $IsWindows value exposed by Windows PowerShell 5.1.
Windows PowerShell 5.1 CI job
.github/workflows/test.yml
Adds a Windows PowerShell 5.1 job that verifies the runtime, ensures Pester 5, and runs tests/powershell/.
Nested test path construction
tests/powershell/25-deploy-secret-files.Tests.ps1, tests/powershell/secret-deploy-state.Tests.ps1, tests/powershell/secret-status.Tests.ps1, tests/powershell/signing-resolve.Tests.ps1
Test paths are rebuilt with nested Join-Path calls.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant WindowsPowerShell51
  participant Pester
  participant PowerShellTests
  GitHubActions->>WindowsPowerShell51: Start powershell51-tests
  WindowsPowerShell51->>WindowsPowerShell51: Verify PowerShell major version 5
  WindowsPowerShell51->>Pester: Ensure Pester 5
  WindowsPowerShell51->>Pester: Invoke Pester tests/powershell/
  Pester->>PowerShellTests: Execute tests
Loading

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a Windows PowerShell 5.1 Pester CI leg.
Description check ✅ Passed The description includes a summary, linked issue reference, and test plan, and it satisfies the minimal template requirements.
Linked Issues check ✅ Passed The changes match #166 by adding the PS5.1 CI job, installing Pester 5, validating major version 5, and fixing PS5.1 skip and path issues.
Out of Scope Changes check ✅ Passed The fixture and path/encoding updates are in scope because they address PS5.1 compatibility issues called out by the issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue/166-feat-ci-add-windows-powershell-5-1

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 advisory CI job that runs the existing PowerShell Pester suite under Windows PowerShell 5.1 to catch $IsWindows -eq $null regressions, and updates Unix-only -Skip: guards in Pester tests to be PS5.1-null-safe.

Changes:

  • Add a powershell51-tests job to .github/workflows/test.yml using shell: powershell and verifying PS major version is 5.
  • Update Unix-only Pester -Skip: expressions to -Skip:($IsWindows -ne $false) so they correctly skip on PS5.1 where $IsWindows is $null.
  • Keep the new PS5.1 leg advisory (not required) while it stabilizes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/test.yml Adds an advisory Windows PowerShell 5.1 Pester job to extend CI coverage to PS5.1 semantics.
tests/powershell/secret-status.Tests.ps1 Makes Unix-only It/Describe blocks PS5.1-null-safe via updated -Skip: guards.
tests/powershell/02-cargo.Tests.ps1 Makes the Unix-only Describe block PS5.1-null-safe via updated -Skip: guard.

Comment thread .github/workflows/test.yml Outdated
The new powershell51-tests CI job (#166) failed on real Windows
PowerShell 5.1: Join-Path only accepts two positional path segments
there (PS7 added variadic support), and the utf8NoBOM encoding
literal used with Set-Content is PS6+ only.

- Nest Join-Path calls where more than two segments were joined.
- Replace `Set-Content -Encoding utf8NoBOM` with
  [System.IO.File]::WriteAllText plus a BOM-less UTF8Encoding, which
  works unchanged on PS5.1.
- Resolve PS provider paths (e.g. TestDrive:\...) to real filesystem
  paths before handing them to [System.IO.File], since .NET I/O APIs
  don't understand PowerShell drives.

Scope is limited to files actually exercised by tests. The same
utf8NoBOM literal remains in three .tmpl scripts that render but
never execute under any current test (git-profiles,
authorized-keys, and the SSH key deploy script); left untouched
pending a follow-up issue. The SSH key deploy template in
particular is security-sensitive and should not be changed without
a dedicated review.
Copilot AI review requested due to automatic review settings July 24, 2026 13:05
cspell flags this fake AWS access key ID once a PR touches the file
it lives in, since incremental checks scan the whole file, not just
the diff. It is a documented placeholder, not a real credential.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

Copilot AI review requested due to automatic review settings July 24, 2026 13:10

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/test.yml:
- Line 128: Update the actions/checkout step in the PowerShell test job to set
persist-credentials to false, keeping the existing checkout behavior unchanged
unless a later step explicitly requires authenticated Git operations.

In `@tests/powershell/25-deploy-secret-files.Tests.ps1`:
- Around line 51-59: Add a narrowly scoped cspell ignore directive for the
fixture token “AKIAEXAMPLE” near its use in the test assertion within the
deployment test. Keep the ignore limited to this test fixture rather than adding
a broad dictionary entry, and preserve the existing content validation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 30037f46-2a0a-46ba-aac5-25c935028333

📥 Commits

Reviewing files that changed from the base of the PR and between b5c886f and dcfa078.

📒 Files selected for processing (10)
  • .github/workflows/test.yml
  • home/dot_local/bin/executable_secret-deploy-state.ps1
  • tests/powershell/02-cargo.Tests.ps1
  • tests/powershell/25-deploy-secret-files.Tests.ps1
  • tests/powershell/fixtures/generate-authorized-keys.ps1
  • tests/powershell/fixtures/generate-git-profiles.ps1
  • tests/powershell/generate-authorized-keys.Tests.ps1
  • tests/powershell/secret-deploy-state.Tests.ps1
  • tests/powershell/secret-status.Tests.ps1
  • tests/powershell/signing-resolve.Tests.ps1

Comment thread .github/workflows/test.yml
Comment thread tests/powershell/25-deploy-secret-files.Tests.ps1

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread .github/workflows/test.yml
GitHub Actions' powershell/pwsh shell steps default
$ErrorActionPreference to Stop. Windows PowerShell 5.1 wraps a
redirected native process's stderr lines as ErrorRecord objects, so
under that combination the expected non-zero-exit output from the
pwsh subprocesses spawned by secret-deploy-state and secret-status
tests was promoted into a terminating exception instead of landing
in the captured $output. Set $ErrorActionPreference = 'Continue'
locally in both harness helpers before the capture.

Also skip-guard the 30-mise "calls reshim" test on PS5.1: its
Set-Item Function: mock doesn't record the call there, but the
script's own `& $miseCommand reshim` line has nothing PS6+-only
about it, so this reads as a mock scope-capture quirk rather than a
real incompatibility -- left for follow-up rather than guessed at
blind.
Copilot AI review requested due to automatic review settings July 24, 2026 13:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

- Set persist-credentials: false on the leg's checkout step; it only
  needs a working tree, never authenticated git operations.
- Force-import Pester 5+ before Invoke-Pester: PSModulePath can list
  the inbox Pester 3.4 module ahead of the CurrentUser-scoped
  install, and auto-loading would silently pick the wrong major
  version instead of guaranteeing Pester 5+.
Copilot AI review requested due to automatic review settings July 24, 2026 13:30
@kurone-kito

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread tests/powershell/signing-resolve.Tests.ps1 Outdated
Comment thread .github/workflows/test.yml
- Enable TLS 1.2 before Install-Module in the PS5.1 leg: PS5.1's
  .NET default protocol set can exclude it, and PSGallery requires
  it. Mirrors the existing workaround in
  55-setup-editors.ps1.tmpl's vim-plug bootstrap.
- signing-resolve.Tests.ps1: WriteAllText writes $Matches[1] exactly
  as captured, unlike the Set-Content it replaced, which always
  appended a trailing newline. Append one explicitly so the
  rendered gitconfig fixture keeps its previous shape.
Copilot AI review requested due to automatic review settings July 24, 2026 13:37
@kurone-kito

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

@kurone-kito
kurone-kito merged commit ff3a713 into master Jul 24, 2026
14 checks passed
@kurone-kito
kurone-kito deleted the issue/166-feat-ci-add-windows-powershell-5-1 branch July 24, 2026 13:43
@kurone-kito

Copy link
Copy Markdown
Owner Author

F4 Cleanup Evidence

Field Value
Status applied
Applied 2
Failed 0
Skipped 18
Permission-blocked 0
Notes associated review threads are missing IDD accept/reject dispositions; known review-bot regular comment lacks a completed-review signal; review has no associated review threads; review thread is missing an IDD accept/reject disposition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ci): add a Windows PowerShell 5.1 Pester leg

2 participants