Skip to content

Commit fb5df75

Browse files
authored
Merge and publish coverage reports (microsoft#6217)
* Upload coverage results * Merge and upload to azdo * News entry
1 parent c1fadb5 commit fb5df75

File tree

9 files changed

+114
-8
lines changed

9 files changed

+114
-8
lines changed

build/.nycrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"extends": "@istanbuljs/nyc-config-typescript",
33
"all": true,
4-
"reporter": ["lcov", "html", "text", "text-summary", "cobertura"],
54
"include": [
65
"src/client/**/*.ts", "src/test/**/*.js",
76
"src/datascience-ui/**/*.ts", "src/datascience-ui/**/*.js"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
steps:
2+
# Generate the coverage reports.
3+
- bash: |
4+
npm run test:cover:report
5+
displayName: 'run test:cover:report'
6+
condition: contains(variables['TestsToRun'], 'testUnitTests')
7+
failOnStderr: false
8+
9+
10+
# Publish Code Coverage Results
11+
- task: PublishCodeCoverageResults@1
12+
displayName: 'Publish test:unittests coverage results'
13+
condition: contains(variables['TestsToRun'], 'testUnitTests')
14+
inputs:
15+
codeCoverageTool: 'cobertura'
16+
summaryFileLocation: "$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml"
17+
reportDirectory: "$(System.DefaultWorkingDirectory)/coverage"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
steps:
2+
- bash: |
3+
printenv
4+
displayName: "Show all env vars"
5+
condition: eq(variables['system.debug'], 'true')
6+
7+
- task: NodeTool@0
8+
displayName: "Use Node $(NodeVersion)"
9+
inputs:
10+
versionSpec: $(NodeVersion)
11+
12+
- task: Npm@1
13+
displayName: "Use NPM $(NpmVersion)"
14+
inputs:
15+
command: custom
16+
verbose: true
17+
customCommand: "install -g npm@$(NpmVersion)"
18+
19+
- task: Npm@1
20+
displayName: "npm ci"
21+
inputs:
22+
command: custom
23+
verbose: true
24+
customCommand: ci
25+
26+
- task: DownloadBuildArtifacts@0
27+
inputs:
28+
buildType: "current"
29+
allowPartiallySucceededBuilds: true
30+
downloadType: "Specific"
31+
itemPattern: "**/.nyc_output/**"
32+
downloadPath: "$(Build.SourcesDirectory)"
33+
displayName: "Restore Coverage Info"
34+
condition: always()
35+
36+
# Now that we have downloaded artificats from `coverage-output-`, copy them
37+
# into the root directory (they'll go under `.nyc_output/...`)
38+
# These are the coverage output files that can be merged and then we can generate a report from them.
39+
# This step results in downloading all individual `./nyc_output` results in coverage
40+
# from all different test outputs.
41+
# Running the process of generating reports, will result in generation of
42+
# reports from all coverage data, i.e. we're basically combining all to generate a single merged report.
43+
- bash: |
44+
cp -r coverage-output-*/ ./
45+
cd ./.nyc_output
46+
ls -dlU .*/ */
47+
ls
48+
displayName: "Copy ./.nyc_output"
49+
condition: always()
50+
51+
- template: generate_upload_coverage.yml

build/ci/templates/test_phases.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,21 @@ steps:
151151
buildPlatform: '$(Agent.Os)-Py$(pythonVersion)'
152152
buildConfiguration: 'UnitTests'
153153

154-
# Publish Code Coverage Results
155-
- task: PublishCodeCoverageResults@1
156-
displayName: 'Publish test:unittests coverage results'
154+
- task: CopyFiles@2
155+
inputs:
156+
sourceFolder: "$(Build.SourcesDirectory)/.nyc_output"
157+
targetFolder: "$(Build.ArtifactStagingDirectory)/nyc/.nyc_output"
158+
displayName: "Copy nyc_output to publish as artificat"
157159
condition: contains(variables['TestsToRun'], 'testUnitTests')
160+
161+
# Upload Code Coverage Results (to be merged later).
162+
- task: PublishBuildArtifacts@1
158163
inputs:
159-
codeCoverageTool: 'cobertura'
160-
summaryFileLocation: "$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml"
161-
reportDirectory: "$(System.DefaultWorkingDirectory)/coverage"
164+
pathtoPublish: "$(Build.ArtifactStagingDirectory)/nyc"
165+
artifactName: 'coverage-output-$(Agent.Os)'
166+
condition: contains(variables['TestsToRun'], 'testUnitTests')
167+
168+
- template: generate_upload_coverage.yml
162169

163170
# Install the requirements for the Python or the system tests. This includes the supporting libs that
164171
# we ship in our extension such as PTVSD and Jedi.

build/ci/vscode-python-ci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,13 @@ jobs:
310310

311311
steps:
312312
- template: templates/test_phases.yml
313+
314+
- job: Coverage
315+
dependsOn:
316+
- CI
317+
pool:
318+
vmImage: "macos-latest"
319+
variables:
320+
TestsToRun: 'testUnitTests'
321+
steps:
322+
- template: templates/merge_upload_coverage.yml

build/ci/vscode-python-nightly-ci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,3 +476,13 @@ jobs:
476476

477477
steps:
478478
- template: templates/test_phases.yml
479+
480+
- job: Coverage
481+
dependsOn:
482+
- Nightly
483+
pool:
484+
vmImage: "macos-latest"
485+
variables:
486+
TestsToRun: 'testUnitTests'
487+
steps:
488+
- template: templates/merge_upload_coverage.yml

build/ci/vscode-python-pr-validation.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,13 @@ jobs:
115115

116116
steps:
117117
- template: templates/test_phases.yml
118+
119+
- job: Coverage
120+
dependsOn:
121+
- PR
122+
pool:
123+
vmImage: "macos-latest"
124+
variables:
125+
TestsToRun: 'testUnitTests'
126+
steps:
127+
- template: templates/merge_upload_coverage.yml

news/3 Code Health/6000.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Merge multiple coverage reports into one.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2178,9 +2178,10 @@
21782178
"postinstall": "node ./node_modules/vscode/bin/install && node ./build/ci/postInstall.js",
21792179
"test": "node ./out/test/standardTest.js && node ./out/test/multiRootTest.js",
21802180
"test:unittests": "mocha --opts ./build/.mocha.unittests.js.opts",
2181-
"test:unittests:cover": "nyc --nycrc-path build/.nycrc mocha --opts ./build/.mocha.unittests.ts.opts",
2181+
"test:unittests:cover": "nyc --silent --no-clean --nycrc-path build/.nycrc mocha --opts ./build/.mocha.unittests.ts.opts",
21822182
"test:functional": "mocha --require source-map-support/register --opts ./build/.mocha.functional.opts",
21832183
"test:functional:cover": "npm run test:functional",
2184+
"test:cover:report": "nyc --nycrc-path build/.nycrc report --reporter=lcov --reporter=text --reporter=html --reporter=text-summary --reporter=cobertura",
21842185
"testDebugger": "node ./out/test/testBootstrap.js ./out/test/debuggerTest.js",
21852186
"testSingleWorkspace": "node ./out/test/testBootstrap.js ./out/test/standardTest.js",
21862187
"testMultiWorkspace": "node ./out/test/testBootstrap.js ./out/test/multiRootTest.js",

0 commit comments

Comments
 (0)