Skip to content

Update Pester tests #11

Update Pester tests

Update Pester tests #11

Workflow file for this run

name: Pester Tests

Check failure on line 1 in .github/workflows/Pester.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/Pester.yml

Invalid workflow file

(Line: 35, Col: 16): Unrecognized named-value: 'matrix'. Located at position 1 within expression: matrix.psversion, (Line: 42, Col: 16): Unrecognized named-value: 'matrix'. Located at position 1 within expression: matrix.psversion
permissions:
contents: read
on:
push:
branches: [main, dev, master]
pull_request:
branches: [main, dev, master]
workflow_dispatch:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
psversion: [pwsh, powershell]
exclude:
# PowerShell 5.1 (powershell) is only available on Windows
- os: ubuntu-latest
psversion: powershell
- os: macos-latest
psversion: powershell
name: Test on ${{ matrix.os }} with ${{ matrix.psversion == 'pwsh' && 'PowerShell 7.x' || 'PowerShell 5.1' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install required modules
shell: ${{ matrix.psversion }}
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name Pester -MinimumVersion 5.0.0 -Force -SkipPublisherCheck
Install-Module -Name PScribo -MinimumVersion 0.11.1 -Force
- name: Run Pester tests
shell: ${{ matrix.psversion }}
run: |
.\Tests\Invoke-Tests.ps1 -CodeCoverage -OutputFormat NUnitXml
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-${{ matrix.psversion }}
path: testResults.xml
- name: Upload code coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: code-coverage-${{ matrix.os }}-${{ matrix.psversion }}
path: coverage.xml
- name: Upload coverage reports to Codecov
if: always()
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: AsBuiltReport/AsBuiltReport.Core
files: ./coverage.xml
flags: unittests-${{ matrix.os }}-${{ matrix.psversion }}
fail_ci_if_error: false
analyze:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name PSScriptAnalyzer -Force
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$SettingsPath = './.github/workflows/PSScriptAnalyzerSettings.psd1'
if (Test-Path $SettingsPath) {
$Results = Invoke-ScriptAnalyzer -Path ./AsBuiltReport.Core -Recurse -Settings $SettingsPath
} else {
$Results = Invoke-ScriptAnalyzer -Path ./AsBuiltReport.Core -Recurse
}
if ($Results) {
$Results | Format-Table -AutoSize
$Errors = $Results | Where-Object Severity -eq 'Error'
if ($Errors.Count -gt 0) {
exit 1
}
}