Skip to content

Commit b769f55

Browse files
authored
Coverage reporting in codecove & in VSTS (1st pass) (#2059)
- Add cobertura reports to the coverage config - Add new gulp task to inline code coverage report CSS - Change mocha reporter id an env var MOCHA_CI_REPORTER_ID
1 parent 7a90e86 commit b769f55

8 files changed

Lines changed: 247 additions & 9 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ bin/**
2020
obj/**
2121
.pytest_cache
2222
tmp/**
23+
.python-version

coverconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"json",
1212
"html",
1313
"lcov",
14-
"lcovonly"
14+
"lcovonly",
15+
"cobertura"
1516
],
1617
"verbose": false
1718
}

gulpfile.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
/* jshint node: true */
7+
/* jshint esversion: 6 */
8+
69
'use strict';
710

811
const gulp = require('gulp');
@@ -29,6 +32,7 @@ const os = require('os');
2932
const _ = require('lodash');
3033
const nativeDependencyChecker = require('node-has-native-dependencies');
3134
const flat = require('flat');
35+
const inlinesource = require('gulp-inline-source');
3236

3337
/**
3438
* Hygiene works by creating cascading subsets of all our files and
@@ -118,12 +122,22 @@ gulp.task('cover:enable', () => {
118122
gulp.task('cover:disable', () => {
119123
return gulp.src("./coverconfig.json")
120124
.pipe(jeditor((json) => {
121-
json.enabled = true;
125+
json.enabled = false;
122126
return json;
123127
}))
124128
.pipe(gulp.dest("./out", { 'overwrite': true }));
125129
});
126130

131+
/**
132+
* Inline CSS into the coverage report for better visualizations on
133+
* the VSTS report page for code coverage.
134+
*/
135+
gulp.task('inlinesource', () => {
136+
return gulp.src('./coverage/lcov-report/*.html')
137+
.pipe(inlinesource({attribute: false}))
138+
.pipe(gulp.dest('./coverage/lcov-report-inline'));
139+
});
140+
127141
function hasNativeDependencies() {
128142
let nativeDependencies = nativeDependencyChecker.check(path.join(__dirname, 'node_modules'));
129143
if (!Array.isArray(nativeDependencies) || nativeDependencies.length === 0) {

package-lock.json

Lines changed: 219 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,8 @@
19031903
"clean": "gulp clean",
19041904
"clean:ptvsd": "gulp clean:ptvsd",
19051905
"cover:enable": "gulp cover:enable",
1906-
"debugger-coverage": "gulp debugger-coverage"
1906+
"debugger-coverage": "gulp debugger-coverage",
1907+
"cover:inlinesource": "gulp inlinesource"
19071908
},
19081909
"dependencies": {
19091910
"arch": "2.1.0",
@@ -1987,6 +1988,7 @@
19871988
"gulp-debounced-watch": "^1.0.4",
19881989
"gulp-filter": "^5.1.0",
19891990
"gulp-gitmodified": "^1.1.1",
1991+
"gulp-inline-source": "^3.2.0",
19901992
"gulp-json-editor": "^2.2.2",
19911993
"gulp-sourcemaps": "^2.6.4",
19921994
"gulp-typescript": "^4.0.1",

src/test/ciConstants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ export const MOCHA_CI_REPORTFILE: string = MOCHA_REPORTER_JUNIT && process.env.M
2222
process.env.MOCHA_CI_REPORTFILE : './junit-out.xml';
2323
export const MOCHA_CI_PROPERTIES: string = MOCHA_REPORTER_JUNIT && process.env.MOCHA_CI_PROPERTIES !== undefined ?
2424
process.env.MOCHA_CI_PROPERTIES : '';
25-
25+
export const MOCHA_CI_REPORTER_ID: string = MOCHA_REPORTER_JUNIT && process.env.MOCHA_CI_REPORTER_ID !== undefined ?
26+
process.env.MOCHA_CI_REPORTER_ID : 'mocha-junit-reporter';
2627
export const IS_CI_SERVER_TEST_DEBUGGER = process.env.IS_CI_SERVER_TEST_DEBUGGER === '1';

0 commit comments

Comments
 (0)