gweinjc is testing PowerShell with Pester! #9
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
name: Pester Test Demo | |
run-name: ${{ github.actor }} is testing PowerShell with Pester! | |
on: | |
push: | |
branches: [ SA-3457_GHA-TEST ] | |
jobs: | |
setup-pester-environment: | |
runs-on: windows-latest | |
timeout-minutes: 90 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Pester Environment (pwsh) | |
env: | |
XAPIKEY_PESTER: ${{ secrets.XAPIKEY_PESTER }} | |
run: | | |
#TEST | |
Write-host $PSVersionTable.PSVersion.Major $PSVersionTable.PSRemotingProtocolVersion.Minor | |
Set-PSRepository psgallery -InstallationPolicy trusted | |
Install-Module -Name Pester -RequiredVersion 5.0.4 -confirm:$false -Force | |
# Load DefineEnvironment | |
. "./PowerShell/JumpCloud Module/Tests/DefineEnvironment.ps1" -JumpCloudApiKey $env:XAPIKEY_PESTER -JumpCloudApiKeyMsp $env:XAPIKEY_PESTER -RequiredModulesRepo "PSGallery" | |
# Load private functions | |
Write-Host ('[status]Load private functions: ' + "$PSScriptRoot/../Private/*.ps1") | |
Get-ChildItem -Path:("$PSScriptRoot/../Private/*.ps1") -Recurse | ForEach-Object { . $_.FullName } | |
# Load HelperFunctions | |
Write-Host ('[status]Load HelperFunctions: ' + "$PSScriptRoot/HelperFunctions.ps1") | |
. ("$PSScriptRoot/HelperFunctions.ps1") | |
Write-Host ('[status]Setting up org: ' + "$PSScriptRoot/SetupOrg.ps1") | |
. "./PowerShell/JumpCloud Module/Tests/SetupOrg.ps1" -JumpCloudApiKey $env:XAPIKEY_PESTER -JumpCloudApiKeyMsp $env:XAPIKEY_PESTER | |
shell: pwsh | |
Get-JCUsers-Test: | |
needs: setup-pester-environment | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 90 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Get-JCUsers Tests (pwsh) | |
env: | |
XAPIKEY_PESTER: ${{ secrets.XAPIKEY_PESTER }} | |
run: | | |
Write-host $PSVersionTable.PSVersion.Major $PSVersionTable.PSRemotingProtocolVersion.Minor | |
Set-PSRepository psgallery -InstallationPolicy trusted | |
Install-Module -Name Pester -RequiredVersion 5.0.4 -confirm:$false -Force | |
Import-Module "$PSScriptRoot/../JumpCloud.psd1" | |
$matrixOS = "${{ matrix.os }}" | |
switch ($matrixOS) { | |
ubuntu-latest { | |
Invoke-Pester -Path "/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1" | |
} | |
macos-latest { | |
Invoke-Pester -Path "/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1" | |
} | |
windows-latest { | |
Invoke-Pester -Path "/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1" | |
} | |
} | |
shell: pwsh |