From 6378c8af81f049013e536111d11985b360b12f2e Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Wed, 2 Aug 2023 11:49:37 +0100 Subject: [PATCH 1/2] (maint) - Update PDK Install --- .github/workflows/ci.yml | 2 +- .github/workflows/puppetize.yml | 8 +++++--- .github/workflows/repuppetize.yml | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fdaacfc9..f8ec6ffc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: workflow_dispatch: env: - pdk_version: 2.5.0.0 + pdk_version: 3.0.0.0 module_cache: PSFramework, PSDscResources, AccessControlDSC, powershell-yaml, PSScriptAnalyzer defaults: diff --git a/.github/workflows/puppetize.yml b/.github/workflows/puppetize.yml index 63dab8fd..61948f3c 100644 --- a/.github/workflows/puppetize.yml +++ b/.github/workflows/puppetize.yml @@ -9,7 +9,7 @@ on: required: false env: - pdk_version: 2.7.1.0 + pdk_version: 3.0.0.0 module_cache: Puppet.Dsc, PSFramework, PSDscResources, powershell-yaml jobs: @@ -87,13 +87,15 @@ jobs: env: FORGE_TOKEN: ${{ secrets.FORGE_API_TOKEN }} run: | + Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 + refreshenv Import-Module -Name PSDesiredStateConfiguration -Force - Import-Module -Name Puppet.Dsc -Force + Import-Module -Name ./src/Puppet.Dsc -Force $null = Get-Command PDK, Publish-NewDscModuleVersion $PublishParameters = @{ ForgeNameSpace = 'dsc' - Name = '${{ matrix.module_name }}' + Name = '${{ matrix.module }}' OnlyNewer = $true MaxBuildCount = 1 } diff --git a/.github/workflows/repuppetize.yml b/.github/workflows/repuppetize.yml index 2f841300..26531673 100644 --- a/.github/workflows/repuppetize.yml +++ b/.github/workflows/repuppetize.yml @@ -10,7 +10,7 @@ on: required: false env: - pdk_version: 2.5.0.0 + pdk_version: 3.0.0.0 module_cache: Puppet.Dsc, PSFramework, PSDscResources, powershell-yaml jobs: From 0610aa0e9d2bbb2f90d8b06a3319c19d608600ca Mon Sep 17 00:00:00 2001 From: jordanbreen28 Date: Thu, 24 Aug 2023 17:28:28 +0100 Subject: [PATCH 2/2] (maint) - add bundle install function --- .../functions/New-PuppetDscModule.ps1 | 3 +- .../internal/functions/Install-Gems.ps1 | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/Puppet.Dsc/internal/functions/Install-Gems.ps1 diff --git a/src/Puppet.Dsc/functions/New-PuppetDscModule.ps1 b/src/Puppet.Dsc/functions/New-PuppetDscModule.ps1 index bc3f4712..7b552866 100644 --- a/src/Puppet.Dsc/functions/New-PuppetDscModule.ps1 +++ b/src/Puppet.Dsc/functions/New-PuppetDscModule.ps1 @@ -169,7 +169,8 @@ Function New-PuppetDscModule { # Generate REFERENCE.md file for the Puppet module from the auto-generated types for each DSC resource Write-PSFMessage -Message 'Writing the reference documentation for the Puppet module' Set-PSModulePath -Path $InitialPsModulePath - Add-PuppetReferenceDocumentation -PuppetModuleFolderPath $PuppetModuleRootFolderDirectory -verbose + Install-Gems -PuppetModuleFolderPath $PuppetModuleRootFolderDirectory -Verbose + Add-PuppetReferenceDocumentation -PuppetModuleFolderPath $PuppetModuleRootFolderDirectory -Verbose If ($PassThru) { # Return the folder containing the puppetized module diff --git a/src/Puppet.Dsc/internal/functions/Install-Gems.ps1 b/src/Puppet.Dsc/internal/functions/Install-Gems.ps1 new file mode 100644 index 00000000..887c2934 --- /dev/null +++ b/src/Puppet.Dsc/internal/functions/Install-Gems.ps1 @@ -0,0 +1,31 @@ +function Install-Gems { + <# + .SYNOPSIS + Install required gems + .DESCRIPTION + Installs required gems as specified in the Gemfile. + .PARAMETER PuppetModuleFolderPath + The path, relative or literal, to the Puppet module's root folder. + #> + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + $PuppetModuleFolderPath + ) + # verify required gems installed + begin { + $PuppetModuleFolderPath = Resolve-Path -Path $PuppetModuleFolderPath -ErrorAction Stop + $Command = 'pdk bundle install' + } + process { + Try { + $ErrorActionPreference = 'Stop' + Invoke-PdkCommand -Path $PuppetModuleFolderPath -Command $Command -SuccessFilterScript { + $_ -match 'gems now installed' + } + } Catch { + $PSCmdlet.ThrowTerminatingError($PSItem) + } + } + end {} +}