diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index eb0ce1e96..57c5774f2 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -35,6 +35,7 @@ jobs: - shell: pwsh run: | . "./PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery + needs: [Validate-Module, clone] Validate-Module: runs-on: ubuntu-latest timeout-minutes: 10 @@ -46,3 +47,44 @@ jobs: - shell: pwsh run: | . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation + needs: setup-build-dependancies + setup-build-dependancies: + runs-on: ubuntu-latest + timeout-minutes: 90 + steps: + - uses: actions/checkout@v4 + - name: Setup PowerShell Module Cache + id: cacher + uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - name: Install dependencies + if: steps.cacher.outputs.cache-hit != 'true' + shell: pwsh + run: | + Set-PSRepository PSGallery -InstallationPolicy Trusted + + If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { + Write-Host ('[status]Installing package provider NuGet'); + Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force + } + + $PSDependencies = @{ + 'PowerShellGet' = @{Repository = 'PSGallery'; RequiredVersion = '3.0.12-beta' } + 'PackageManagement' = @{Repository = 'PSGallery'; RequiredVersion = '1.4.8.1' } + 'PSScriptAnalyzer' = @{Repository = 'PSGallery'; RequiredVersion = '1.19.1' } + 'PlatyPS' = @{Repository = 'PSGallery'; RequiredVersion = '0.14.2' } + 'AWS.Tools.Common' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } + 'AWS.Tools.CodeArtifact' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } + 'JumpCloud.SDK.V1' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.35'} + 'JumpCloud.SDK.V2' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.39'} + 'JumpCloud.SDK.DirectoryInsights' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.23'} + } + + foreach ($RequiredModule in $PSDependencies.Keys) { + If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { + Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force + } + }