forked from jpogran/PuppetDscBuilder
-
Notifications
You must be signed in to change notification settings - Fork 12
137 lines (120 loc) · 4.37 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
pdk_version: 3.0.0
module_cache: PSFramework, PSDscResources, AccessControlDSC, powershell-yaml, PSScriptAnalyzer
COVERAGE_ENABLED: 'yes'
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
defaults:
run:
shell: powershell
jobs:
spec:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2022]
tag: [General, Unit]
include:
- tag: General
results_file: General.Results.xml
- tag: Unit
results_file: Unit.Results.xml
steps:
- name: "checkout"
uses: actions/checkout@v3
- name: "install modules"
uses: potatoqualitee/[email protected]
with:
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
}
acceptance:
runs-on: ${{ matrix.os }}
needs: "spec"
strategy:
fail-fast: false
matrix:
os: [windows-2022]
tag: [Basic]
pwshlib_source: [forge, git]
include:
- pwshlib_source: forge
pwshlib_repo: "puppetlabs/pwshlib"
pwshlib_ref: "latest" # Change to a specific version if desired
results_file: Acceptance.Forge.Results.xml
- pwshlib_source: git
pwshlib_repo: "https://github.com/puppetlabs/ruby-pwsh.git" # Change to another fork if desired
pwshlib_ref: main # Change to another branch if desired
results_file: Acceptance.Git.Results.xml
steps:
- name: "checkout"
uses: actions/checkout@v3
- name: "install modules"
uses: potatoqualitee/[email protected]
with:
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
echo "C:\Program Files\Puppet Labs\DevelopmentKit\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
# refreshenv
- 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: Install Winget
# shell: pwsh
# run: |
# winget || iwr -useb https://aka.ms/winget/install | iex
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.6
- name: "setup pre-requisite native gems"
run: |
pdk bundle exec gem install racc -v '~> 1.4.0'
pdk bundle exec gem install nkf -v '~> 0.2.0'
- 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
$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."
}