Skip to content

docs(examples): ship share-creation examples; scrub lab hostname from… #15

docs(examples): ship share-creation examples; scrub lab hostname from…

docs(examples): ship share-creation examples; scrub lab hostname from… #15

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". `shell:` must be a literal.
on:
push:
pull_request:
workflow_dispatch: {}
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@v4
- name: Install test dependencies
shell: pwsh
run: |
Install-Module -Name Pester -MinimumVersion 5.0 -Force -SkipPublisherCheck -Scope CurrentUser
# Posh-SSH is an optional runtime dependency (see Private/Get-PfbApiTokenViaSsh.ps1),
# but Get-PfbApiTokenViaSsh.Tests.ps1 mocks its cmdlets (New-SSHSession, etc.) --
# Pester can only mock a command that's resolvable, so it must be installed here
# even though the module under test never actually opens an SSH connection.
Install-Module -Name Posh-SSH -Force -SkipPublisherCheck -Scope CurrentUser
- 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@v4
- name: Install test dependencies
shell: powershell
run: |
# Some older Windows PowerShell 5.1 hosts default to TLS 1.0/1.1, which
# PowerShell Gallery rejects -- force TLS 1.2 before hitting it.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name Pester -MinimumVersion 5.0 -Force -SkipPublisherCheck -Scope CurrentUser
Install-Module -Name Posh-SSH -Force -SkipPublisherCheck -Scope CurrentUser
- 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