Interop
PowerShell Parity
This page documents how PowerShell 7.4 LTS / 7.5+ support is exercised in CI and what specifically is verified. Closes the docs slice of #860.
What ships
| File | Role |
|---|---|
dot_config/powershell/Microsoft.PowerShell_profile.ps1.tmpl | The dotfiles PowerShell profile. Deployed to $PROFILE (resolves to ~/.config/powershell/Microsoft.PowerShell_profile.ps1 on Linux/macOS; Documents\PowerShell\Microsoft.PowerShell_profile.ps1 on Windows). |
scripts/qa/powershell-contract.ps1 | The runtime contract. Renders the template, dot-sources it, asserts required function shims exist, runs PSScriptAnalyzer. |
tests/unit/install/test_powershell_profile_syntax.sh | Static-syntax test runnable on Linux/macOS via pwsh when present; falls back to brace-balance + textual invariants when not. |
What's verified
On every Linux/macOS PR (tests/unit/install/...)
- Profile file exists at the expected path.
- Defines the
dotfunction shim so PowerShell users invoke the same CLI as Unix shells. - Sets
XDG_CONFIG_HOME(matches Unix XDG conventions for~/.config/powershelldiscoverability). - Brace count balances (
{vs}). - If
pwshis installed locally, parses the rendered template viaSystem.Management.Automation.Language.Parserand fails on any parse error.
On windows-latest runner via reliability-gate.yml
The powershell-contract job runs scripts/qa/powershell-contract.ps1 which does:
- Renders the template via
chezmoi execute-templateso any chezmoi data references (e.g.{{ .dotfiles_version }}) resolve to real values before parsing. - Dot-sources the rendered profile and asserts no exception is thrown during load.
- Asserts the required function shims are defined after load:
dot,d,ll,la,cat. - Runs PSScriptAnalyzer at
Errorseverity. Warnings surface but don't fail the gate (tightenable later).
Exit non-zero on any failure. The job is in the reliability-summary required-checks list so a broken PowerShell profile blocks merge.
Running locally
On Linux/macOS
# Static test — runs in any context.
# Full contract — needs pwsh + chezmoi installed.
On Windows
.\scripts\qa\powershell-contract.ps1
Known limitations
- The contract doesn't currently exercise PowerShell-specific runtime semantics (e.g. PSDrive providers, custom completion). Those are a follow-up.
- Function shims are smoke-tested by name only — we check that
Get-Command dotresolves to a function, not that it actually invokes the right binary. A richer integration test that creates a fakedotbinary and confirms the shim invokes it correctly is a future hardening step. - macOS is not in the matrix because
pwshisn't pre-installed on GitHub macOS runners. The Linux/macOS static test runs on every PR via the existing test suite; full pwsh validation is Windows-only to keep the matrix small.
When to update this page
- The PowerShell profile gains a new function → add it to the
RequiredFunctionsarray inpowershell-contract.ps1AND to the list above. - A static-test invariant is added → document it in the "What's verified on every PR" list.
- The PSScriptAnalyzer severity is tightened from
ErrortoWarning→ update the relevant bullet here.
References
- PowerShell 7 docs
- PSScriptAnalyzer rule reference
.github/workflows/reliability-gate.yml— Windows job definition.- Issue #860.