Skip to content

Sync to v2.3.0

Sync to v2.3.0 #16

name: Tests
# Runs the Pester suite across every OS/PowerShell-edition combination the module
# claims to support (PureStorageFlashBladePowerShell.psd1: PowerShellVersion = '5.1'),
# so platform-specific bugs (e.g. a .NET marshaling difference between Windows and
# Linux/macOS) are caught on every push/PR instead of only surfacing much later on
# whichever CI job happens to run on a non-Windows runner.
#
# Two separate jobs rather than one shell-matrixed job: the `shell:` key on a step does
# NOT have access to the `matrix` context (unlike `run:`, `env:`, or a job's own `name:`/
# `runs-on:`) -- confirmed via `gh workflow run`: "Unrecognized named-value: 'matrix'.
# Located at position 1 within expression: matrix.shell". In a workflow, `shell:` must be
# a literal. (Inside a *composite action* `shell:` does accept `${{ inputs.* }}` -- but
# still not `matrix`/`env` -- which is how .github/actions/install-test-modules serves
# both editions from one implementation.)
#
# workflow_call: publish-to-gallery.yml calls this workflow as its test gate, so a
# release only ships after passing on all 4 OS/PowerShell-edition combinations below --
# not just whichever single platform a standalone Pester step would happen to run on.
on:
push:
pull_request:
workflow_dispatch: {}
workflow_call: {}
jobs:
test-pwsh:
name: Test (${{ matrix.os }}, pwsh)
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
# Pinned + cached; see .github/actions/install-test-modules/action.yml for why
# (including why Posh-SSH is needed at all).
- name: Install test dependencies
uses: ./.github/actions/install-test-modules
with:
shell: pwsh
- name: Run Pester tests
shell: pwsh
run: |
Import-Module Pester -MinimumVersion 5.0 -Force
Import-Module Posh-SSH -Force
$cfg = New-PesterConfiguration
$cfg.Run.Path = 'Tests'
$cfg.Run.Exit = $true
$cfg.Output.Verbosity = 'Detailed'
Invoke-Pester -Configuration $cfg
test-windows-powershell-5-1:
name: Test (windows-latest, Windows PowerShell 5.1)
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v7
# Same pinned modules and same cache entry as the pwsh job on this OS -- the saved
# files are edition-independent (Pester 6.0.1 declares PowerShellVersion = '5.1').
# `shell:` is passed explicitly because a composite action has no default shell and
# cannot read `matrix`.
- name: Install test dependencies
uses: ./.github/actions/install-test-modules
with:
shell: powershell
- name: Run Pester tests
shell: powershell
run: |
Import-Module Pester -MinimumVersion 5.0 -Force
Import-Module Posh-SSH -Force
$cfg = New-PesterConfiguration
$cfg.Run.Path = 'Tests'
$cfg.Run.Exit = $true
$cfg.Output.Verbosity = 'Detailed'
Invoke-Pester -Configuration $cfg