Skip to content

Commit 6e3b4f4

Browse files
authored
Update pipeline used in NetworkingDsc (#297)
1 parent fcffb1f commit 6e3b4f4

3 files changed

Lines changed: 66 additions & 56 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Remove use of prefix.ps1 and suffix.ps1.
1313
- Added testing on Windows Server 2025.
1414
- Updated Test stage to use matrix strategy to reduce code duplication.
15+
- Refactor pipeline to move integration to separate stage, add merge code coverage task.
1516
- `Disk`
1617
- Updated AllocationUnitSize in examples to be a valid UInt32 value instead of a String.
1718

azure-pipelines.yml

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ stages:
5454
publishLocation: 'pipeline'
5555
parallel: true
5656

57-
- stage: Test
57+
- stage: Quality_Test_and_Unit_Test
58+
displayName: 'Quality Test and Unit Test'
5859
dependsOn: Build
5960
jobs:
6061
- job: Test_HQRM
6162
displayName: 'HQRM'
6263
pool:
6364
vmImage: 'windows-latest'
64-
timeoutInMinutes: 0
65+
timeoutInMinutes: '0'
6566
steps:
6667
- task: DownloadPipelineArtifact@2
6768
displayName: 'Download Pipeline Artifact'
@@ -86,28 +87,19 @@ stages:
8687
testRunTitle: 'HQRM'
8788
condition: succeededOrFailed()
8889

89-
- job: Test_Unit_Matrix
90-
displayName: 'Unit Tests'
90+
- job: Test_Unit
91+
displayName: 'Unit'
9192
strategy:
9293
matrix:
93-
Unit_Windows_Server_2019:
94-
osImage: windows-2019
95-
testRunTitle: 'Unit (Windows Server 2019)'
96-
publishArtifact: true # Publish the test artifact for code coverage
97-
Unit_Windows_Server_2022:
98-
osImage: windows-2022
99-
testRunTitle: 'Unit (Windows Server 2022)'
100-
publishArtifact: false
101-
Unit_Windows_Server_2025:
102-
osImage: windows-2025
103-
testRunTitle: 'Unit (Windows Server 2025)'
104-
publishArtifact: false
105-
variables:
106-
testType: Unit
107-
configureWinRM: false
94+
Windows Server 2019:
95+
vmImage: windows-2019
96+
Windows Server 2022:
97+
vmImage: windows-2022
98+
Windows Server 2025:
99+
vmImage: windows-2025
108100
pool:
109-
vmImage: $(osImage)
110-
timeoutInMinutes: 0
101+
vmImage: $(vmImage)
102+
timeoutInMinutes: '0'
111103
steps:
112104
- task: DownloadPipelineArtifact@2
113105
displayName: 'Download Pipeline Artifact'
@@ -117,7 +109,7 @@ stages:
117109
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
118110

119111
- task: PowerShell@2
120-
displayName: 'Run $(testRunTitle) Test'
112+
displayName: 'Run Unit Test'
121113
inputs:
122114
filePath: './build.ps1'
123115
arguments: "-Tasks test -PesterScript 'tests/Unit'"
@@ -128,23 +120,21 @@ stages:
128120
inputs:
129121
testResultsFormat: NUnit
130122
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
131-
testRunTitle: '$(testRunTitle)'
123+
testRunTitle: 'Unit $(vmImage)'
132124
condition: succeededOrFailed()
133125

134126
- task: PublishPipelineArtifact@1
135127
displayName: 'Publish Test Artifact'
136-
condition: eq(variables['publishArtifact'], 'true')
137128
inputs:
138129
targetPath: '$(buildFolderName)/$(testResultFolderName)/'
139-
artifactName: $(testArtifactName)
140-
parallel: true
130+
artifactName: '$(testArtifactName)_$(vmImage)'
141131

142132
- job: Code_Coverage
143133
displayName: 'Publish Code Coverage'
144-
dependsOn: Test_Unit_Matrix
134+
dependsOn: Test_Unit
145135
pool:
146136
vmImage: 'ubuntu-latest'
147-
timeoutInMinutes: 0
137+
timeoutInMinutes: '0'
148138
steps:
149139
- task: DownloadPipelineArtifact@2
150140
displayName: 'Download Pipeline Artifact'
@@ -157,9 +147,16 @@ stages:
157147
displayName: 'Download Test Artifact'
158148
inputs:
159149
buildType: current
160-
artifactName: $(testArtifactName)
161150
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)'
162151

152+
- task: PowerShell@2
153+
name: merge
154+
displayName: 'Merge Code Coverage files'
155+
inputs:
156+
filePath: './build.ps1'
157+
arguments: '-tasks merge'
158+
pwsh: true
159+
163160
- task: PublishCodeCoverageResults@1
164161
displayName: 'Publish Code Coverage to Azure DevOps'
165162
inputs:
@@ -171,26 +168,23 @@ stages:
171168
bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml"
172169
displayName: 'Upload to Codecov.io'
173170
174-
- job: Test_Integration_Matrix
175-
displayName: 'Integration Tests'
171+
- stage: Integration_Test
172+
displayName: 'Integration Test'
173+
dependsOn: Quality_Test_and_Unit_Test
174+
jobs:
175+
- job: Test_Integration
176+
displayName: 'Integration'
176177
strategy:
177178
matrix:
178-
Integration_Windows_Server_2019:
179-
osImage: windows-2019
180-
testRunTitle: 'Integration (Windows Server 2019)'
181-
Integration_Windows_Server_2022:
182-
osImage: windows-2022
183-
testRunTitle: 'Integration (Windows Server 2022)'
184-
Integration_Windows_Server_2025:
185-
osImage: windows-2025
186-
testRunTitle: 'Integration (Windows Server 2025)'
187-
variables:
188-
testType: Integration
189-
configureWinRM: true
190-
publishArtifact: false
179+
Windows Server 2019:
180+
vmImage: windows-2019
181+
Windows Server 2022:
182+
vmImage: windows-2022
183+
Windows Server 2025:
184+
vmImage: windows-2025
191185
pool:
192-
vmImage: $(osImage)
193-
timeoutInMinutes: 0
186+
vmImage: $(vmImage)
187+
timeoutInMinutes: '0'
194188
steps:
195189
- task: DownloadPipelineArtifact@2
196190
displayName: 'Download Pipeline Artifact'
@@ -199,17 +193,17 @@ stages:
199193
artifactName: $(buildArtifactName)
200194
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'
201195

202-
# Integration tests need WinRM
203196
- task: PowerShell@2
197+
name: configureWinRM
204198
displayName: 'Configure WinRM'
205-
condition: eq(variables['configureWinRM'], 'true')
206199
inputs:
207-
targetType: inline
208-
script: winrm quickconfig -quiet
200+
targetType: 'inline'
201+
script: 'winrm quickconfig -quiet'
209202
pwsh: false
210203

211204
- task: PowerShell@2
212-
displayName: 'Run $(testRunTitle) Test'
205+
name: test
206+
displayName: 'Run Integration Test'
213207
inputs:
214208
filePath: './build.ps1'
215209
arguments: "-Tasks test -PesterScript 'tests/Integration' -CodeCoverageThreshold 0"
@@ -218,13 +212,15 @@ stages:
218212
- task: PublishTestResults@2
219213
displayName: 'Publish Test Results'
220214
inputs:
221-
testResultsFormat: NUnit
215+
testResultsFormat: 'NUnit'
222216
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
223-
testRunTitle: '$(testRunTitle)'
217+
testRunTitle: 'Integration $(testRunTitle)'
224218
condition: succeededOrFailed()
225219

226220
- stage: Deploy
227-
dependsOn: Test
221+
dependsOn:
222+
- Quality_Test_and_Unit_Test
223+
- Integration_Test
228224
condition: |
229225
and(
230226
succeeded(),

build.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ BuildWorkflow:
3030

3131
test:
3232
- Pester_Tests_Stop_On_Fail
33+
- Convert_Pester_Coverage
3334
- Pester_If_Code_Coverage_Under_Threshold
3435

36+
merge:
37+
- Merge_CodeCoverage_Files
38+
3539
publish:
3640
- publish_module_to_gallery
3741
- Publish_Release_To_GitHub
@@ -89,7 +93,6 @@ Pester:
8993
- tests/Unit
9094
ExcludeTag:
9195
Tag:
92-
CodeCoverageOutputFile: JaCoCo_coverage.xml
9396
CodeCoverageOutputFileEncoding: ascii
9497
CodeCoverageThreshold: 80
9598

@@ -104,7 +107,6 @@ Pester:
104107
CIFormat: Auto
105108
CodeCoverage:
106109
CoveragePercentTarget: 80
107-
OutputPath: JaCoCo_coverage.xml
108110
OutputEncoding: ascii
109111
UseBreakpoints: false
110112
TestResult:
@@ -113,6 +115,17 @@ Pester:
113115
ExcludeFromCodeCoverage:
114116
- Modules/DscResource.Common
115117

118+
####################################################
119+
# Code Coverage Configuration #
120+
####################################################
121+
122+
CodeCoverage:
123+
# Filename of the file that will be outputted by the task Merge_CodeCoverage_Files.
124+
CodeCoverageMergedOutputFile: JaCoCo_coverage.xml
125+
# File pattern used to search for files under the ./output/testResults folder
126+
# by task Merge_CodeCoverage_Files.
127+
CodeCoverageFilePattern: Codecov*.xml
128+
116129
####################################################
117130
# Pester Configuration (DscResource.Test) #
118131
####################################################

0 commit comments

Comments
 (0)