Skip to content

Commit 7adf0b3

Browse files
committed
- Added debug disk space reports to code coverage job.
- Removed unnecessary parameters and variables related to code coverage job.
1 parent ec9bbd4 commit 7adf0b3

File tree

2 files changed

+87
-80
lines changed

2 files changed

+87
-80
lines changed

eng/pipelines/common/templates/jobs/ci-code-coverage-job.yml

Lines changed: 86 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,82 @@
33
# The .NET Foundation licenses this file to you under the MIT license. #
44
# See the LICENSE file in the project root for more information. #
55
#################################################################################
6+
7+
# This job processes code coverage reports generated during test runs,
8+
# merges them, generates code coverage reports, publishes them to the
9+
# pipeline, and uploads them to CodeCov.
10+
611
parameters:
12+
13+
# True to include debug steps.
714
- name: debug
815
type: boolean
916
default: false
1017

11-
- name: upload
12-
type: string
13-
default: $(ci_var_uploadTestResult)
14-
15-
- name: poolName
16-
type: string
17-
default: $(defaultHostedPoolName)
18+
# Array of target frameworks to process code coverage for:
19+
#
20+
# e.g. [net462, net8.0, net9.0]
21+
#
22+
- name: targetFrameworks
23+
type: object
1824

19-
- name: image
20-
type: string
21-
default: 'windows-2022'
22-
23-
- name: downloadArtifactsSteps
24-
type: stepList
25-
default: []
25+
# True to upload code coverage results to CodeCov.
26+
- name: upload
27+
type: boolean
28+
default: true
2629

2730
jobs:
2831
- job: CodeCoverage
29-
displayName: 'Merge Code Coverage'
30-
31-
variables:
32-
uploadTestResult: ${{ parameters.upload }}
32+
displayName: Publish Code Coverage
3333

3434
pool:
35-
name: '${{ parameters.poolName }}'
36-
vmImage: ${{ parameters.image }}
35+
name: Azure Pipelines
36+
vmImage: windows-2022
3737

38-
steps:
38+
variables:
39+
netFxDir: $(Build.SourcesDirectory)\coverageNetFx
40+
netCoreDir: $(Build.SourcesDirectory)\coverageNetCore
3941

40-
# We don't need the source code for this job, so suppress checkout.
41-
- checkout: none
42+
steps:
4243

4344
- ${{if eq(parameters.debug, true)}}:
44-
- pwsh: |
45-
Get-ChildItem env: | Sort-Object Name
46-
displayName: 'List Environment Variables [debug]'
45+
- pwsh: Get-Volume
46+
displayName: '[Debug] Show Disk Usage'
47+
48+
- pwsh: 'Get-ChildItem env: | Sort-Object Name'
49+
displayName: '[Debug] List Environment Variables'
4750

4851
- template: ../steps/ensure-dotnet-version.yml@self
4952
parameters:
50-
packageType: 'sdk'
51-
version: '10.0'
53+
packageType: sdk
54+
version: '9.0'
55+
56+
- pwsh: |
57+
dotnet tool install --global dotnet-coverage
58+
dotnet tool install --global dotnet-reportgenerator-globaltool
59+
displayName: Install dotnet tools
60+
61+
- ${{ each targetFramework in parameters.targetFrameworks }}:
62+
- task: DownloadPipelineArtifact@2
63+
displayName: 'Download Coverage Reports [${{ targetFramework }}]'
64+
inputs:
65+
itemPattern: '**\${{ targetFramework }}*'
66+
${{ if startsWith(targetFramework, 'net4') }}:
67+
targetPath: $(netFxDir)
68+
${{ else }}:
69+
targetPath: $(netCoreDir)
5270

53-
- ${{ parameters.downloadArtifactsSteps }}
71+
- ${{if eq(parameters.debug, true)}}:
72+
- pwsh: Get-Volume
73+
displayName: '[Debug] Show Disk Usage'
5474

55-
- ${{ if eq(parameters.debug, true)}}:
56-
- pwsh: |
57-
Get-ChildItem $(Build.SourcesDirectory)\coverageNetFx\ -Recurse -File -Filter *.coverage
58-
displayName: 'List coverageNetFx files [debug]'
75+
- pwsh: Get-ChildItem $(netFxDir) -Recurse -File -Filter *.coverage
76+
displayName: '[Debug] List coverageNetFx files'
5977

60-
- pwsh: |
61-
Get-ChildItem $(Build.SourcesDirectory)\coverageNetCore\ -Recurse -File -Filter *.coverage
62-
displayName: 'List coverageNetCore files [debug]'
78+
- pwsh: Get-ChildItem $(netCoreDir) -Recurse -File -Filter *.coverage
79+
displayName: '[Debug] List coverageNetCore files'
6380

6481
- pwsh: |
65-
dotnet tool install --global dotnet-coverage
66-
6782
function MergeFiles {
6883
param(
6984
[string]$InputDirectoryPath,
@@ -103,39 +118,35 @@ jobs:
103118
}
104119
}
105120
106-
MergeFiles -InputDirectoryPath "$(Build.SourcesDirectory)\coverageNetFx\" -OutputDirectoryName "coverageNetFxXml"
107-
MergeFiles -InputDirectoryPath "$(Build.SourcesDirectory)\coverageNetCore\" -OutputDirectoryName "coverageNetCoreXml"
121+
MergeFiles -InputDirectoryPath "$(netFxDir)" -OutputDirectoryName "coverageNetFxXml"
122+
MergeFiles -InputDirectoryPath "$(netCoreDir)" -OutputDirectoryName "coverageNetCoreXml"
108123
109-
# dir coverageNetFxXml\
110-
# dir coverageNetCoreXml\
111-
112-
Write-Host "Clean up disk ... [removing coverageNetFx & coverageNetCore]"
113-
114-
Remove-Item $(Build.SourcesDirectory)\coverageNetFx -Recurse -Force
115-
Remove-Item $(Build.SourcesDirectory)\coverageNetCore -Recurse -Force
124+
Write-Host "Removing original coverage files..."
125+
Remove-Item $(netFxDir) -Recurse -Force
126+
Remove-Item $(netCoreDir) -Recurse -Force
127+
displayName: Convert coverage files to xml
116128
117-
displayName: 'Convert coverage files to xml'
129+
- ${{if eq(parameters.debug, true)}}:
130+
- pwsh: Get-Volume
131+
displayName: '[Debug] Show Disk Usage'
118132

119-
- ${{ if eq(parameters.debug, true)}}:
120133
- pwsh: |
121134
dir coverageNetFxXml\
122135
dir coverageNetCoreXml\
123-
displayName: 'List converted files [debug]'
136+
displayName: '[Debug] List converted files'
124137
125138
- pwsh: |
126-
dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
127-
128139
$jobs = @()
129140
$jobs += Start-ThreadJob -ScriptBlock {
130-
& tools\reportgenerator "-reports:coverageNetFxXml\*.coveragexml" "-targetdir:coveragereportNetFx" "-reporttypes:Cobertura;" "-assemblyfilters:+microsoft.data.sqlclient.dll" "-sourcedirs:$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\netfx\src;$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\src" "-classfilters:+Microsoft.Data.*"
141+
& reportgenerator "-reports:coverageNetFxXml\*.coveragexml" "-targetdir:coveragereportNetFx" "-reporttypes:Cobertura;" "-assemblyfilters:+microsoft.data.sqlclient.dll" "-sourcedirs:$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\netfx\src;$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\src" "-classfilters:+Microsoft.Data.*"
131142
}
132143
133144
$jobs += Start-ThreadJob -ScriptBlock {
134-
& tools\reportgenerator "-reports:coverageNetCoreXml\*.coveragexml" "-targetdir:coveragereportAddOns" "-reporttypes:Cobertura;" "-assemblyfilters:+microsoft.data.sqlclient.alwaysencrypted.azurekeyvaultprovider.dll" "-sourcedirs:$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\add-ons\AzureKeyVaultProvider" "-classfilters:+Microsoft.Data.*"
145+
& reportgenerator "-reports:coverageNetCoreXml\*.coveragexml" "-targetdir:coveragereportNetCore" "-reporttypes:Cobertura;" "-assemblyfilters:+microsoft.data.sqlclient.dll" "-sourcedirs:$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\netcore\src;$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\src" "-classfilters:+Microsoft.Data.*"
135146
}
136147
137148
$jobs += Start-ThreadJob -ScriptBlock {
138-
& tools\reportgenerator "-reports:coverageNetCoreXml\*.coveragexml" "-targetdir:coveragereportNetCore" "-reporttypes:Cobertura;" "-assemblyfilters:+microsoft.data.sqlclient.dll" "-sourcedirs:$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\netcore\src;$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\src" "-classfilters:+Microsoft.Data.*"
149+
& reportgenerator "-reports:coverageNetCoreXml\*.coveragexml" "-targetdir:coveragereportAddOns" "-reporttypes:Cobertura;" "-assemblyfilters:+microsoft.data.sqlclient.alwaysencrypted.azurekeyvaultprovider.dll" "-sourcedirs:$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\add-ons\AzureKeyVaultProvider" "-classfilters:+Microsoft.Data.*"
139150
}
140151
141152
Write-Host "Running ReportGenerator..."
@@ -144,20 +155,28 @@ jobs:
144155
foreach ($job in $jobs) {
145156
Receive-Job -Job $job -Wait -AutoRemoveJob
146157
}
147-
displayName: 'Run ReportGenerator'
158+
159+
Write-Host "Removing merged XML files..."
160+
Remove-Item coverageNetFxXml -Recurse -Force
161+
Remove-Item coverageNetCoreXml -Recurse -Force
162+
displayName: Run ReportGenerator
163+
164+
- ${{if eq(parameters.debug, true)}}:
165+
- pwsh: Get-Volume
166+
displayName: '[Debug] Show Disk Usage'
148167

149168
- task: PublishCodeCoverageResults@2
150-
displayName: 'Publish code coverage from netcore'
169+
displayName: Publish code coverage results
151170
inputs:
152171
summaryFileLocation: '*\Cobertura.xml'
153172

154-
- pwsh: |
155-
#download Codecov CLI
156-
$ProgressPreference = 'SilentlyContinue'
157-
Invoke-WebRequest -Uri https://cli.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
158-
159-
./codecov --verbose upload-process --fail-on-error -t $(CODECOV_TOKEN) -f "coveragereportNetFx\Cobertura.xml" -F netfx
160-
./codecov --verbose upload-process --fail-on-error -t $(CODECOV_TOKEN) -f "coveragereportNetCore\Cobertura.xml" -F netcore
161-
./codecov --verbose upload-process --fail-on-error -t $(CODECOV_TOKEN) -f "coveragereportAddOns\Cobertura.xml" -F addons
162-
displayName: 'Upload to CodeCov'
163-
condition: and(succeeded(), eq(variables['uploadTestResult'], 'true'))
173+
- ${{if eq(parameters.upload, true)}}:
174+
- pwsh: |
175+
#download Codecov CLI
176+
$ProgressPreference = 'SilentlyContinue'
177+
Invoke-WebRequest -Uri https://cli.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
178+
179+
./codecov --verbose upload-process --fail-on-error -t $(CODECOV_TOKEN) -f "coveragereportNetFx\Cobertura.xml" -F netfx
180+
./codecov --verbose upload-process --fail-on-error -t $(CODECOV_TOKEN) -f "coveragereportNetCore\Cobertura.xml" -F netcore
181+
./codecov --verbose upload-process --fail-on-error -t $(CODECOV_TOKEN) -f "coveragereportAddOns\Cobertura.xml" -F addons
182+
displayName: Upload to CodeCov

eng/pipelines/dotnet-sqlclient-ci-core.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ variables:
9696
- name: artifactName
9797
value: Artifacts
9898

99-
- name: defaultHostedPoolName
100-
value: 'Azure Pipelines'
101-
10299
stages:
103100
- stage: build_nugets
104101
displayName: 'Build NuGet Packages'
@@ -161,16 +158,7 @@ stages:
161158
- template: common/templates/jobs/ci-code-coverage-job.yml@self
162159
parameters:
163160
debug: ${{ parameters.debug }}
164-
downloadArtifactsSteps:
165-
- ${{ each targetFramework in parameters.codeCovTargetFrameworks }}:
166-
- task: DownloadPipelineArtifact@2
167-
displayName: 'Download Coverage Reports [${{ targetFramework }}]'
168-
inputs:
169-
itemPattern: '**\${{ targetFramework }}*'
170-
${{ if contains(targetFramework, 'net4') }}:
171-
targetPath: '$(Build.SourcesDirectory)\coverageNetFx'
172-
${{ else }}:
173-
targetPath: '$(Build.SourcesDirectory)\coverageNetCore'
161+
targetFrameworks: ${{ parameters.codeCovTargetFrameworks }}
174162

175163
# test stages configurations
176164
# self hosted SQL Server on Windows

0 commit comments

Comments
 (0)