-
Notifications
You must be signed in to change notification settings - Fork 87
67 lines (58 loc) · 2.05 KB
/
build-validation.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Run pester tests
name: build-validation
on:
workflow_dispatch:
workflow_call:
pull_request:
branches: ["main"]
permissions:
contents: read
actions: read
checks: write
pull-requests: write
statuses: write
jobs:
build-validation:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
# This requires all patterns to match so exclusion works
predicate-quantifier: 'every'
filters: |
pwshmodule:
- 'powershell/**'
- "!powershell/Maester.psd1"
- name: Install PowerShell dependencies
if: steps.filter.outputs.pwshmodule == 'true'
shell: pwsh
run: |
Install-Module PSFramework -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber
Install-Module PSModuleDevelopment -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber
Install-Module Microsoft.Graph.Authentication -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber
- name: Run Pester tests
if: steps.filter.outputs.pwshmodule == 'true'
shell: pwsh
run: |
./powershell/tests/pester.ps1
- name: Run Tests using Windows PowerShell
if: runner.os == 'Windows' && steps.filter.outputs.pwshmodule == 'true'
shell: powershell
run: |
# Reuse downloaded modules from pwsh
$env:PSModulePath += ";$HOME\Documents\PowerShell\Modules"
# Remove old test results
Remove-Item -Path TestResults -Recurse -Force -ErrorAction SilentlyContinue
# Run Pester tests on Windows PowerShell
./powershell/tests/pester.ps1
- uses: actions/upload-artifact@v4 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: test-results-${{ runner.os }}
path: TestResults/*.xml