Skip to content

Commit 6987a50

Browse files
CopilotTrenly
andcommitted
Add GitHub Actions workflow for running Pester tests
Co-authored-by: Trenly <12611259+Trenly@users.noreply.github.com>
1 parent 6f90fb8 commit 6987a50

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/pesterTests.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Pester Tests
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- master
7+
paths:
8+
- "**/*.ps1"
9+
- "**/*.psm1"
10+
- "**/*.psd1"
11+
push:
12+
paths:
13+
- "**/*.ps1"
14+
- "**/*.psm1"
15+
- "**/*.psd1"
16+
17+
permissions:
18+
contents: read # Needed to check out the code
19+
pull-requests: read # Needed to read pull request details
20+
21+
jobs:
22+
test:
23+
runs-on: windows-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
- name: Install Pester
28+
run: |
29+
# Pester 5.x is already included in Windows runners, but ensure latest version
30+
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -MinimumVersion 5.0.0
31+
- name: Run Pester Tests
32+
run: |
33+
# Find and run all Pester test files
34+
$testFiles = Get-ChildItem -Recurse -Filter *.Tests.ps1
35+
if ($testFiles) {
36+
Write-Host "Found $($testFiles.Count) test file(s)"
37+
foreach ($testFile in $testFiles) {
38+
Write-Host "Running tests in: $($testFile.FullName)"
39+
}
40+
41+
# Run all tests
42+
$config = New-PesterConfiguration
43+
$config.Run.Path = $testFiles.FullName
44+
$config.Run.Exit = $true
45+
$config.Output.Verbosity = 'Detailed'
46+
$config.TestResult.Enabled = $true
47+
48+
Invoke-Pester -Configuration $config
49+
} else {
50+
Write-Host "No Pester test files found."
51+
}

0 commit comments

Comments
 (0)