Skip to content

Commit

Permalink
Merge pull request #541 from TheJumpCloud/SA-3499_GHA_Matrix_Test
Browse files Browse the repository at this point in the history
SA-3499: GHA Matrix for Pester Tests
  • Loading branch information
jworkmanjc authored Nov 2, 2023
2 parents f11a43a + caf4d19 commit 9b55e85
Show file tree
Hide file tree
Showing 59 changed files with 1,543 additions and 1,001 deletions.
70 changes: 67 additions & 3 deletions .github/workflows/powershell-module-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ jobs:
- name: Install dependencies
if: steps.cacher.outputs.cache-hit != 'true'
shell: pwsh
env:
PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }}
PESTER_ORGID: ${{ secrets.PESTER_ORGID }}
PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }}
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Expand All @@ -103,6 +107,7 @@ jobs:
Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force
}
}
Validate-Module:
needs: ["Setup-Build-Dependancies", "Check-PR-Labels"]
runs-on: ubuntu-latest
Expand All @@ -121,10 +126,45 @@ jobs:
shell: pwsh
run: |
. "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation
Test-Module:
Setup-Org:
needs: ["Setup-Build-Dependancies", "Check-PR-Labels"]
runs-on: ubuntu-latest
name: Setup Org Upload Variable Artifact
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
PowerShell
- uses: actions/cache@v3
with:
path: "/home/runner/.local/share/powershell/Modules/"
key: PS-Dependancies
- name: Setup Org Variables
shell: pwsh
env:
PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }}
PESTER_ORGID: ${{ secrets.PESTER_ORGID }}
PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }}
run: |
# Setup Org
# $variableArray = New-Object System.Collections.Generic.List[PSCustomObject]
# Load Get-Config.ps1
. "./PowerShell/Deploy/Get-Config.ps1"
Write-Host ('[status] Setting up org')
$variables = . ("./PowerShell/JumpCloud Module/Tests/SetupOrg.ps1") -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY"
$variables | ConvertTo-Json -Depth 10 | Out-File -FilePath /home/runner/.local/share/powershell/Modules/PesterVariables.json
- uses: actions/upload-artifact@v3
with:
name: jumpcloud-vars
path: /home/runner/.local/share/powershell/Modules/PesterVariables.json
Test-Module:
needs: ["Setup-Build-Dependancies", "Check-PR-Labels", "Setup-Org"]
runs-on: ubuntu-latest
timeout-minutes: 75
strategy:
fail-fast: false
matrix:
job_group: [0, 1, 2]
name: Run Pester Tests and Upload Results
steps:
- uses: actions/checkout@v4
Expand All @@ -135,14 +175,36 @@ jobs:
with:
path: "/home/runner/.local/share/powershell/Modules/"
key: PS-Dependancies
- uses: actions/download-artifact@v3
with:
name: jumpcloud-vars
- name: Test PWSH Module
shell: pwsh
env:
PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }}
PESTER_ORGID: ${{ secrets.PESTER_ORGID }}
PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }}
run: |
. "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ExcludeTagList "ModuleValidation", "JCDeployment", "MSP", "JCModule" -IncludeTagList "*" -RequiredModulesRepo "PSGallery"
# Setup Variables for Pester Run
$env:job_group = ${{ matrix.job_group }}
$PesterParams = Get-Content -Raw ${{ github.workspace }}/PesterVariables.json | ConvertFrom-JSON
write-host "[status] Importing $($PesterParams.count) variables from SetupOrg"
$PesterParams | Foreach-Object {
if ($_.Name){
Write-Host ("[status] Setting variable $($_.Name) with value $($_.Value)")
Set-Variable -Name $_.Name -Value $_.Value -Scope Global
}
}
Set-Variable -Name PesterParams_ApiKey -Value "$env:PESTER_APIKEY" -Scope Global
# Import JC Module
Import-Module "${{github.workspace}}/PowerShell/JumpCloud Module/JumpCloud.psd1"
# Authenticate to JC Org
Connect-JCOnline -JumpCloudApiKey:("$env:PESTER_APIKEY") -force | Out-Null
# Invoke Pester
. "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -ExcludeTagList "ModuleValidation", "JCDeployment", "MSP", "JCModule" -IncludeTagList "*" -RequiredModulesRepo "PSGallery"
Test-Module-MSP:
needs: ["Setup-Build-Dependancies", "Check-PR-Labels"]
runs-on: ubuntu-latest
Expand All @@ -163,4 +225,6 @@ jobs:
PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }}
PESTER_PROVIDER_ID: ${{ secrets.PESTER_PROVIDER_ID }}
run: |
. "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ExcludeTagList "None" -IncludeTagList "MSP" -RequiredModulesRepo "PSGallery"
Set-Variable -Name PesterParams_ApiKeyMsp -Value "$env:PESTER_MSP_APIKEY" -Scope Global
. "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ProviderID "$env:PESTER_PROVIDER_ID" -RequiredModulesRepo "PSGallery" -MSP
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/scripts/automation/Radius/Config.ps1
/scripts/automation/Radius/users.json
__pycache__/
*.pyc
*.pyc
# Ignore PWSH CSV Import/Update Files:
# /PowerShell/JumpCloud Module/Tests/Csv_Files/import/*
# /PowerShell/JumpCloud Module/Tests/Csv_Files/update/*
217 changes: 109 additions & 108 deletions PowerShell/JumpCloud Module/JumpCloud.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,157 +3,158 @@
#
# Generated by: JumpCloud Solutions Architect Team
#
# Generated on: 10/19/2023
# Generated on: 11/2/2023
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'JumpCloud.psm1'
# Script module or binary module file associated with this manifest.
RootModule = 'JumpCloud.psm1'

# Version number of this module.
ModuleVersion = '2.8.1'
# Version number of this module.
ModuleVersion = '2.8.2'

# Supported PSEditions
# CompatiblePSEditions = @()
# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = '31c023d1-a901-48c4-90a3-082f91b31646'
# ID used to uniquely identify this module
GUID = '31c023d1-a901-48c4-90a3-082f91b31646'

# Author of this module
Author = 'JumpCloud Solutions Architect Team'
# Author of this module
Author = 'JumpCloud Solutions Architect Team'

# Company or vendor of this module
CompanyName = 'JumpCloud'
# Company or vendor of this module
CompanyName = 'JumpCloud'

# Copyright statement for this module
Copyright = '(c) JumpCloud. All rights reserved.'
# Copyright statement for this module
Copyright = '(c) JumpCloud. All rights reserved.'

# Description of the functionality provided by this module
Description = 'PowerShell functions to manage a JumpCloud Directory-as-a-Service'
# Description of the functionality provided by this module
Description = 'PowerShell functions to manage a JumpCloud Directory-as-a-Service'

# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '4.0'
# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '4.0'

# Name of the PowerShell host required by this module
# PowerShellHostName = ''
# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @('JumpCloud.SDK.DirectoryInsights',
'JumpCloud.SDK.V1',
'JumpCloud.SDK.V2')
# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @('JumpCloud.SDK.DirectoryInsights',
'JumpCloud.SDK.V1',
'JumpCloud.SDK.V2')

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget',
'Add-JCRadiusReplyAttribute', 'Add-JCSystemGroupMember',
'Add-JCSystemUser', 'Add-JCUserGroupMember', 'Backup-JCOrganization',
'Connect-JCOnline', 'Copy-JCAssociation', 'Get-JCAssociation',
'Get-JCBackup', 'Get-JCCommand', 'Get-JCCommandResult',
'Get-JCCommandTarget', 'Get-JCEvent', 'Get-JCEventCount', 'Get-JCGroup',
'Get-JCOrganization', 'Get-JCPolicy', 'Get-JCPolicyResult',
'Get-JCPolicyTargetGroup', 'Get-JCPolicyTargetSystem',
'Get-JCRadiusReplyAttribute', 'Get-JCRadiusServer', 'Get-JCSystem',
'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights',
'Get-JCSystemUser', 'Get-JCUser', 'Get-JCUserGroupMember',
'Import-JCCommand', 'Import-JCMSPFromCSV', 'Import-JCUsersFromCSV',
'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand',
'New-JCDeploymentTemplate', 'New-JCImportTemplate',
'New-JCMSPImportTemplate', 'New-JCPolicy', 'New-JCRadiusServer',
'New-JCSystemGroup', 'New-JCUser', 'New-JCUserGroup',
'Remove-JCAssociation', 'Remove-JCCommand', 'Remove-JCCommandResult',
'Remove-JCCommandTarget', 'Remove-JCPolicy',
'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer',
'Remove-JCSystem', 'Remove-JCSystemGroup',
'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser',
'Remove-JCUserGroup', 'Remove-JCUserGroupMember',
'Send-JCPasswordReset', 'Set-JCCommand', 'Set-JCOrganization',
'Set-JCPolicy', 'Set-JCRadiusReplyAttribute', 'Set-JCRadiusServer',
'Set-JCSettingsFile', 'Set-JCSystem', 'Set-JCSystemUser', 'Set-JCUser',
'Set-JCUserGroupLDAP', 'Update-JCModule', 'Update-JCMSPFromCSV',
'Update-JCUsersFromCSV'
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget',
'Add-JCRadiusReplyAttribute', 'Add-JCSystemGroupMember',
'Add-JCSystemUser', 'Add-JCUserGroupMember', 'Backup-JCOrganization',
'Connect-JCOnline', 'Copy-JCAssociation', 'Get-JCAssociation',
'Get-JCBackup', 'Get-JCCommand', 'Get-JCCommandResult',
'Get-JCCommandTarget', 'Get-JCEvent', 'Get-JCEventCount', 'Get-JCGroup',
'Get-JCOrganization', 'Get-JCPolicy', 'Get-JCPolicyResult',
'Get-JCPolicyTargetGroup', 'Get-JCPolicyTargetSystem',
'Get-JCRadiusReplyAttribute', 'Get-JCRadiusServer', 'Get-JCSystem',
'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights',
'Get-JCSystemUser', 'Get-JCUser', 'Get-JCUserGroupMember',
'Import-JCCommand', 'Import-JCMSPFromCSV', 'Import-JCUsersFromCSV',
'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand',
'New-JCDeploymentTemplate', 'New-JCImportTemplate',
'New-JCMSPImportTemplate', 'New-JCPolicy', 'New-JCRadiusServer',
'New-JCSystemGroup', 'New-JCUser', 'New-JCUserGroup',
'Remove-JCAssociation', 'Remove-JCCommand', 'Remove-JCCommandResult',
'Remove-JCCommandTarget', 'Remove-JCPolicy',
'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer',
'Remove-JCSystem', 'Remove-JCSystemGroup',
'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser',
'Remove-JCUserGroup', 'Remove-JCUserGroupMember',
'Send-JCPasswordReset', 'Set-JCCommand', 'Set-JCOrganization',
'Set-JCPolicy', 'Set-JCRadiusReplyAttribute', 'Set-JCRadiusServer',
'Set-JCSettingsFile', 'Set-JCSystem', 'Set-JCSystemUser', 'Set-JCUser',
'Set-JCUserGroupLDAP', 'Update-JCModule', 'Update-JCMSPFromCSV',
'Update-JCUsersFromCSV'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = '*'
# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = 'New-JCAssociation'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = 'New-JCAssociation'

# DSC resources to export from this module
# DscResourcesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()
# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()
# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory'
# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'JumpCloud','DaaS','Jump','Cloud','Directory'

# A URL to the license for this module.
LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE'
# A URL to the license for this module.
LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/TheJumpCloud/support/wiki'
# A URL to the main website for this project.
ProjectUri = 'https://github.com/TheJumpCloud/support/wiki'

# A URL to an icon representing this module.
IconUri = 'https://avatars1.githubusercontent.com/u/4927461?s=200&v=4'
# A URL to an icon representing this module.
IconUri = 'https://avatars1.githubusercontent.com/u/4927461?s=200&v=4'

# ReleaseNotes of this module
ReleaseNotes = 'https://git.io/jc-pwsh-releasenotes'
# ReleaseNotes of this module
ReleaseNotes = 'https://git.io/jc-pwsh-releasenotes'

# Prerelease string of this module
# Prerelease = ''
# Prerelease string of this module
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false

# External dependent modules of this module
# ExternalModuleDependencies = @()
# External dependent modules of this module
# ExternalModuleDependencies = @()

} # End of PSData hashtable
} # End of PSData hashtable

} # End of PrivateData hashtable
} # End of PrivateData hashtable

# HelpInfo URI of this module
HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki'
# HelpInfo URI of this module
HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki'

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Function Add-JCAssociation {
$FunctionParameters = [ordered]@{ }
# Add input parameters from function in to hash table and filter out unnecessary parameters
$PSBoundParameters.GetEnumerator() | Where-Object { -not [System.String]::IsNullOrEmpty($_.Value) } | ForEach-Object { $FunctionParameters.Add($_.Key, $_.Value) | Out-Null }
# Check if the type is in param block or a dynamic type
# Add action
($FunctionParameters).Add('Action', $Action) | Out-Null
# Run the command
Expand Down
Loading

0 comments on commit 9b55e85

Please sign in to comment.