52 lines
1.5 KiB
YAML
52 lines
1.5 KiB
YAML
name: Pester Tests
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
paths:
|
|
- "**/*.ps1"
|
|
- "**/*.psm1"
|
|
- "**/*.psd1"
|
|
push:
|
|
paths:
|
|
- "**/*.ps1"
|
|
- "**/*.psm1"
|
|
- "**/*.psd1"
|
|
|
|
permissions:
|
|
contents: read # Needed to check out the code
|
|
pull-requests: read # Needed to read pull request details
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0
|
|
- name: Install Pester
|
|
run: |
|
|
# Pester 5.x is already included in Windows runners, but ensure latest version
|
|
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 5.0.0
|
|
- name: Run Pester Tests
|
|
run: |
|
|
# Find and run all Pester test files
|
|
$testFiles = Get-ChildItem -Recurse -Filter *.Tests.ps1
|
|
if ($testFiles) {
|
|
Write-Host "Found $($testFiles.Count) test file(s)"
|
|
foreach ($testFile in $testFiles) {
|
|
Write-Host "Running tests in: $($testFile.FullName)"
|
|
}
|
|
|
|
# Run all tests
|
|
$config = New-PesterConfiguration
|
|
$config.Run.Path = $testFiles.FullName
|
|
$config.Run.Exit = $true
|
|
$config.Output.Verbosity = 'Detailed'
|
|
$config.TestResult.Enabled = $true
|
|
|
|
Invoke-Pester -Configuration $config
|
|
} else {
|
|
Write-Host "No Pester test files found."
|
|
}
|