Run Pester Tests #67
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Pester Tests | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: [ main ] | |
types: [ opened, synchronize, reopened ] | |
jobs: | |
test: | |
name: Validate module integrity | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install PowerShell dependencies | |
shell: pwsh | |
run: | | |
Set-PSRepository PSGallery -InstallationPolicy Trusted | |
Install-Module powershell-yaml, PSScriptAnalyzer -Force | |
- name: Run PSScriptAnalyzer | |
shell: pwsh | |
run: | | |
Invoke-ScriptAnalyzer -Path .\src -Settings PSGallery -Recurse -ReportSummary -Severity Error | |
- name: Run Tests using Windows PowerShell | |
if: runner.os == 'Windows' | |
shell: powershell | |
run: | | |
# Reuse downloaded modules from pwsh | |
$env:PSModulePath += ";$HOME\Documents\PowerShell\Modules" | |
$config = New-PesterConfiguration -Hashtable @{TestResult = @{Enabled = $true }; Run = @{Exit = $false }; Output = @{ Verbosity = 'Detailed' }} | |
Invoke-Pester -Configuration $config | |
- name: Run Tests using PowerShell | |
shell: pwsh | |
run: | | |
$config = New-PesterConfiguration -Hashtable @{TestResult = @{Enabled = $true }; Run = @{Exit = $false }; Output = @{ Verbosity = 'Detailed' }} | |
Invoke-Pester -Configuration $config | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Pester-Tests | |
path: testResults.xml |