Automatically install Pester if needed unless using -SkipPesterCheck #388
Workflow file for this run
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
# 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@v3 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
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: Install PowerShell dependencies (Windows PowerShell) | |
if: runner.os == 'Windows' && steps.filter.outputs.pwshmodule == 'true' | |
shell: powershell | |
run: | | |
Set-PSRepository PSGallery -InstallationPolicy Trusted | |
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: | | |
# 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@v3 # upload test results | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: test-results | |
path: TestResults/*.xml |