Skip to content

Commit

Permalink
Merge pull request #287 from puppetlabs/use_latest_pdk
Browse files Browse the repository at this point in the history
(CAT-1763) Update PDK version to fix acceptance tests
  • Loading branch information
LukasAud authored Mar 25, 2024
2 parents 0438743 + 8550c32 commit 8bdd229
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 153 deletions.
1 change: 1 addition & 0 deletions .adr-dir
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/adr
15 changes: 15 additions & 0 deletions .github/actions/configure-winrm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# configure-winrm

## Description

## Usage

To trigger this action from within a workflow, call it using the `steps` snippet something like below:

```yaml
jobs:
acceptance:
steps:
- name: Configure WinRM
uses: ./.github/actions/configure-winrm
```
16 changes: 16 additions & 0 deletions .github/actions/configure-winrm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: 'Configure WinRM'
description: 'Configures WinRM'
runs:
using: 'composite'
steps:
- name: Configure WinRM
run: |
Write-Host 'Ensuring WinRM is configured for DSC'
Get-ChildItem WSMan:\localhost\Listener\ -OutVariable Listeners | Format-List * -Force
$HTTPListener = $Listeners | Where-Object -FilterScript { $_.Keys.Contains('Transport=HTTP') }
If ($HTTPListener.Count -eq 0) {
winrm create winrm/config/Listener?Address=*+Transport=HTTP
winrm e winrm/config/listener
}
shell: powershell
27 changes: 27 additions & 0 deletions .github/actions/install-pdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# install-pdk

## Description

## Usage

To trigger this action from within a workflow, call it using the `steps` snippet something like below:

```yaml
jobs:
acceptance:
steps:
- name: Install PDK
uses: ./.github/actions/install-pdk
```
Or if you want to over-ride the default pdk version, then something like:
```yaml
jobs:
acceptance:
steps:
- name: Install PDK
uses: ./.github/actions/install-pdk
with:
pdk_version: 3.0.1.3
```
16 changes: 16 additions & 0 deletions .github/actions/install-pdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: 'Install PDK'
description: 'Installs PDK using Chocolatey'
inputs:
pdk_version:
description: 'PDK version to install'
required: false
default: '3.0.1.3'
runs:
using: 'composite'
steps:
- name: Install PDK
run: |
choco feature disable -n=showDownloadProgress
choco install pdk --version ${{ inputs.pdk_version }} -y
shell: powershell
15 changes: 15 additions & 0 deletions .github/actions/run-acceptance-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# run-acceptance-tests

## Description

## Usage

To trigger this action from within a workflow, call it using the `steps` snippet something like below:

```yaml
jobs:
acceptance:
steps:
- name: Run Acceptance Tests
uses: ./.github/actions/run-acceptance-tests
```
29 changes: 29 additions & 0 deletions .github/actions/run-acceptance-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: 'Run Acceptance Tests'
description: 'Run Acceptance Tests'
runs:
using: 'composite'
steps:
- name: Run Acceptance Tests
run: |
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
Import-Module -Name PSDesiredStateConfiguration -Force
Import-Module -Name .\src\Puppet.Dsc\puppet.dsc.psd1 -Force
$null = Get-Command -Module Puppet.Dsc
$ErrorActionPreference = "Stop"
$TestParameters = @{
TestPath = @((Resolve-Path .\acceptance))
ResultsPath = "${{ matrix.results_file }}"
Tag = "${{ matrix.tag }}"
PwshLibSource = "${{ matrix.pwshlib_source }}"
PwshLibRepo = "${{ matrix.pwshlib_repo }}"
PwshLibReference = "${{ matrix.pwshlib_ref }}"
}
$Results = .\scripts\invoke_tests.ps1 @TestParameters
if ($Results.FailedCount -gt 0) {
throw "$($Results.FailedCount) tests failed."
}
shell: powershell
15 changes: 15 additions & 0 deletions .github/actions/run-unit-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# configure-winrm

## Description

## Usage

To trigger this action from within a workflow, call it using the `steps` snippet something like below:

```yaml
jobs:
acceptance:
steps:
- name: Run Unit Tests
uses: ./.github/actions/run-unit-tests
```
24 changes: 24 additions & 0 deletions .github/actions/run-unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: 'Run Unit Tests'
description: 'Run Unit Tests'
runs:
using: 'composite'
steps:
- name: Run Unit Tests
run: |
Import-Module -Name PSDesiredStateConfiguration -Force
Import-Module -Name .\src\Puppet.Dsc\puppet.dsc.psd1 -Force
$null = Get-Command -Module Puppet.Dsc
$ErrorActionPreference = "Stop"
$ResultsPath = "${{ matrix.results_file }}"
$TestPath = @(
(Resolve-Path .\src\Puppet.Dsc\functions)
(Resolve-Path .\src\Puppet.Dsc\internal\functions)
(Resolve-Path .\src\Puppet.Dsc\tests\general)
)
$Results = .\scripts\invoke_tests.ps1 -TestPath $TestPath -ResultsPath $ResultsPath -Tag ${{ matrix.tag }}
if ($Results.FailedCount -gt 0) {
throw "$($Results.FailedCount) tests failed."
}
shell: powershell
72 changes: 10 additions & 62 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
workflow_dispatch:

env:
pdk_version: 2.7.1.0
module_cache: PSFramework, PSDscResources, AccessControlDSC, powershell-yaml, PSScriptAnalyzer
COVERAGE_ENABLED: 'yes'
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Expand Down Expand Up @@ -42,33 +41,11 @@ jobs:
shell: powershell
modules-to-cache: ${{ env.module_cache }}

- name: "configure winrm"
run: |
Write-Host 'Ensuring WinRM is configured for DSC'
Get-ChildItem WSMan:\localhost\Listener\ -OutVariable Listeners | Format-List * -Force
$HTTPListener = $Listeners | Where-Object -FilterScript { $_.Keys.Contains('Transport=HTTP') }
If ($HTTPListener.Count -eq 0) {
winrm create winrm/config/Listener?Address=*+Transport=HTTP
winrm e winrm/config/listener
}
- name: Configure WinRM
uses: ./.github/actions/configure-winrm

- name: "test"
run: |
Import-Module -Name PSDesiredStateConfiguration -Force
Import-Module -Name .\src\Puppet.Dsc\puppet.dsc.psd1 -Force
$null = Get-Command -Module Puppet.Dsc
$ErrorActionPreference = "Stop"
$ResultsPath = "${{ matrix.results_file }}"
$TestPath = @(
(Resolve-Path .\src\Puppet.Dsc\functions)
(Resolve-Path .\src\Puppet.Dsc\internal\functions)
(Resolve-Path .\src\Puppet.Dsc\tests\general)
)
$Results = .\scripts\invoke_tests.ps1 -TestPath $TestPath -ResultsPath $ResultsPath -Tag ${{ matrix.tag }}
if ($Results.FailedCount -gt 0) {
throw "$($Results.FailedCount) tests failed."
}
- name: Run Unit Tests
uses: ./.github/actions/run-unit-tests

- name: Upload coverage reports to Codecov
# Only upload report once per CI run
Expand Down Expand Up @@ -109,40 +86,11 @@ jobs:
shell: powershell
modules-to-cache: ${{ env.module_cache }}

- name: "install pdk"
run: |
choco feature disable -n=showDownloadProgress
choco install pdk --version ${{ env.pdk_version }} -y
- name: "configure winrm"
run: |
Write-Host 'Ensuring WinRM is configured for DSC'
Get-ChildItem WSMan:\localhost\Listener\ -OutVariable Listeners | Format-List * -Force
$HTTPListener = $Listeners | Where-Object -FilterScript { $_.Keys.Contains('Transport=HTTP') }
If ($HTTPListener.Count -eq 0) {
winrm create winrm/config/Listener?Address=*+Transport=HTTP
winrm e winrm/config/listener
}
- name: "test"
run: |
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
Import-Module -Name PSDesiredStateConfiguration -Force
Import-Module -Name .\src\Puppet.Dsc\puppet.dsc.psd1 -Force
$null = Get-Command -Module Puppet.Dsc
- name: Install PDK
uses: ./.github/actions/install-pdk

$ErrorActionPreference = "Stop"
$TestParameters = @{
TestPath = @((Resolve-Path .\acceptance))
ResultsPath = "${{ matrix.results_file }}"
Tag = "${{ matrix.tag }}"
PwshLibSource = "${{ matrix.pwshlib_source }}"
PwshLibRepo = "${{ matrix.pwshlib_repo }}"
PwshLibReference = "${{ matrix.pwshlib_ref }}"
}
- name: Configure WinRM
uses: ./.github/actions/configure-winrm

$Results = .\scripts\invoke_tests.ps1 @TestParameters
if ($Results.FailedCount -gt 0) {
throw "$($Results.FailedCount) tests failed."
}
- name: Run Acceptance Tests
uses: ./.github/actions/run-acceptance-tests
72 changes: 10 additions & 62 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
workflow_dispatch:

env:
pdk_version: 2.7.1.0
module_cache: PSFramework, PSDscResources, AccessControlDSC, powershell-yaml, PSScriptAnalyzer

defaults:
Expand Down Expand Up @@ -36,33 +35,11 @@ jobs:
shell: powershell
modules-to-cache: ${{ env.module_cache }}

- name: "configure winrm"
run: |
Write-Host 'Ensuring WinRM is configured for DSC'
Get-ChildItem WSMan:\localhost\Listener\ -OutVariable Listeners | Format-List * -Force
$HTTPListener = $Listeners | Where-Object -FilterScript { $_.Keys.Contains('Transport=HTTP') }
If ($HTTPListener.Count -eq 0) {
winrm create winrm/config/Listener?Address=*+Transport=HTTP
winrm e winrm/config/listener
}
- name: Configure WinRM
uses: ./.github/actions/configure-winrm

- name: "test"
run: |
Import-Module -Name PSDesiredStateConfiguration -Force
Import-Module -Name .\src\Puppet.Dsc\puppet.dsc.psd1 -Force
$null = Get-Command -Module Puppet.Dsc
$ErrorActionPreference = "Stop"
$ResultsPath = "${{ matrix.results_file }}"
$TestPath = @(
(Resolve-Path .\src\Puppet.Dsc\functions)
(Resolve-Path .\src\Puppet.Dsc\internal\functions)
(Resolve-Path .\src\Puppet.Dsc\tests\general)
)
$Results = .\scripts\invoke_tests.ps1 -TestPath $TestPath -ResultsPath $ResultsPath -Tag ${{ matrix.tag }}
if ($Results.FailedCount -gt 0) {
throw "$($Results.FailedCount) tests failed."
}
- name: Run Unit Tests
uses: ./.github/actions/run-unit-tests

acceptance:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -93,40 +70,11 @@ jobs:
shell: powershell
modules-to-cache: ${{ env.module_cache }}

- name: "install pdk"
run: |
choco feature disable -n=showDownloadProgress
choco install pdk --version ${{ env.pdk_version }} -y
- name: "configure winrm"
run: |
Write-Host 'Ensuring WinRM is configured for DSC'
Get-ChildItem WSMan:\localhost\Listener\ -OutVariable Listeners | Format-List * -Force
$HTTPListener = $Listeners | Where-Object -FilterScript { $_.Keys.Contains('Transport=HTTP') }
If ($HTTPListener.Count -eq 0) {
winrm create winrm/config/Listener?Address=*+Transport=HTTP
winrm e winrm/config/listener
}
- name: "test"
run: |
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
Import-Module -Name PSDesiredStateConfiguration -Force
Import-Module -Name .\src\Puppet.Dsc\puppet.dsc.psd1 -Force
$null = Get-Command -Module Puppet.Dsc
- name: Install PDK
uses: ./.github/actions/install-pdk

$ErrorActionPreference = "Stop"
$TestParameters = @{
TestPath = @((Resolve-Path .\acceptance))
ResultsPath = "${{ matrix.results_file }}"
Tag = "${{ matrix.tag }}"
PwshLibSource = "${{ matrix.pwshlib_source }}"
PwshLibRepo = "${{ matrix.pwshlib_repo }}"
PwshLibReference = "${{ matrix.pwshlib_ref }}"
}
- name: Configure WinRM
uses: ./.github/actions/configure-winrm

$Results = .\scripts\invoke_tests.ps1 @TestParameters
if ($Results.FailedCount -gt 0) {
throw "$($Results.FailedCount) tests failed."
}
- name: Run Acceptance Tests
uses: ./.github/actions/run-acceptance-tests
18 changes: 4 additions & 14 deletions .github/workflows/puppetize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
required: false

env:
pdk_version: 2.7.1.0
module_cache: PSFramework, PSDscResources, powershell-yaml

jobs:
Expand Down Expand Up @@ -86,20 +85,11 @@ jobs:
shell: powershell
modules-to-cache: ${{ env.module_cache }}

- name: "install pdk"
run: |
choco feature disable -n=showDownloadProgress
choco install pdk --version ${{ env.pdk_version }} -y
- name: Install PDK
uses: ./.github/actions/install-pdk

- name: "configure winrm"
run: |
Write-Host 'Ensuring WinRM is configured for DSC'
Get-ChildItem WSMan:\localhost\Listener\ -OutVariable Listeners | Format-List * -Force
$HTTPListener = $Listeners | Where-Object -FilterScript { $_.Keys.Contains('Transport=HTTP') }
If ($HTTPListener.Count -eq 0) {
winrm create winrm/config/Listener?Address=*+Transport=HTTP
winrm e winrm/config/listener
}
- name: Configure WinRM
uses: ./.github/actions/configure-winrm

- name: "publish module"
env:
Expand Down
Loading

0 comments on commit 8bdd229

Please sign in to comment.