From 9fb3b174c37ddf2074d1148bfa594a997360618f Mon Sep 17 00:00:00 2001 From: Brian Ingenito <28159742+bingenito@users.noreply.github.com> Date: Tue, 9 Jul 2019 15:06:47 -0400 Subject: [PATCH] Fix code codcov integration (#258) * Update codecov to 3.5.0 * Strip 'build' dir from source maps in coverage file --- .gulp/tasks/tests.js | 60 ++++++++++++++++++++++++++------------------ .travis.yml | 2 +- package-lock.json | 21 ++++++++++++---- package.json | 2 +- 4 files changed, 54 insertions(+), 31 deletions(-) diff --git a/.gulp/tasks/tests.js b/.gulp/tasks/tests.js index b75c988a..523c9359 100644 --- a/.gulp/tasks/tests.js +++ b/.gulp/tasks/tests.js @@ -2,6 +2,7 @@ var jasmine = require('gulp-jasmine'), istanbul = require('gulp-istanbul'), + replace = require('gulp-replace'), remap = require('remap-istanbul/lib/gulpRemapIstanbul'), instanbulEnforcer = require('gulp-istanbul-enforcer'); @@ -10,38 +11,49 @@ module.exports = function (gulp, config) { return gulp.src(config.test.coverage.src) .pipe(istanbul({ includeUntested: true })) .pipe(istanbul.hookRequire()) - .on('finish', function () { + .on('finish', () => { + + // Run jasmine under istanbul gulp.src(config.test.src) .pipe(jasmine({ verbose: true, errorOnFail: true, includeStackTrace: false })) .pipe(istanbul.writeReports({ dir: config.test.coverage.dest, reporters: ['json'] })) - .on('end', remapCoverageFiles) - .on('finish', function () { - gulp.src('.') - .pipe(instanbulEnforcer({ - coverageDirectory: config.test.coverage.dest, - rootDirectory: '', - thresholds: { - statements: config.test.coverage.threshold || 80 + + // Take js coverage json and remap to typescript. Output html and text + .on('end', () => { + return gulp.src(config.test.coverage.coverageFile) + .pipe(remap({ + reports: { + 'json': config.test.coverage.coverageFile, // overwrite js based json with ts remapped version + 'html': config.test.coverage.dest, + 'lcovonly': config.test.coverage.lcovFile, + 'text': null } - })); - }); - }); + })) - /** Take js coverage json and remap to typescript. Output html and text */ - function remapCoverageFiles() { - return gulp.src(config.test.coverage.coverageFile) - .pipe(remap({ - reports: { - 'json': config.test.coverage.coverageFile, // overwrite js based json with ts remapped version - 'html': config.test.coverage.dest, - 'lcovonly': config.test.coverage.lcovFile, - 'text': null - } - })); - }; + // Remove staging build directory in code coverage for correct file mapping + .on('finish', function () { + return gulp.src(config.test.coverage.coverageFile) + .pipe(replace(/\\\\build\\\\src/mg, '\\\\src')) // windows + .pipe(replace(/\/build\/src/mg, '/src')) // unix) + .pipe(gulp.dest(config.test.coverage.dest)) + + // Enforce statement coverage threshold based on config or if not defined 80% + .on('finish', function () { + return gulp.src('.') + .pipe(instanbulEnforcer({ + coverageDirectory: config.test.coverage.dest, + rootDirectory: '', + thresholds: { + statements: config.test.coverage.threshold || 80 + } + })); + }); + }) + }) + }); }; } diff --git a/.travis.yml b/.travis.yml index 36f3058f..d75198ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,4 +33,4 @@ deploy: skip_cleanup: true on: tags: true - branch: master \ No newline at end of file + branch: master diff --git a/package-lock.json b/package-lock.json index 59a3c350..bb55658f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2392,15 +2392,15 @@ "dev": true }, "codecov": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.1.0.tgz", - "integrity": "sha512-aWQc/rtHbcWEQLka6WmBAOpV58J2TwyXqlpAQGhQaSiEUoigTTUk6lLd2vB3kXkhnDyzyH74RXfmV4dq2txmdA==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.5.0.tgz", + "integrity": "sha512-/OsWOfIHaQIr7aeZ4pY0UC1PZT6kimoKFOFYFNb6wxo3iw12nRrh+mNGH72rnXxNsq6SGfesVPizm/6Q3XqcFQ==", "dev": true, "requires": { "argv": "^0.0.2", "ignore-walk": "^3.0.1", - "js-yaml": "^3.12.0", - "request": "^2.87.0", + "js-yaml": "^3.13.1", + "teeny-request": "^3.11.3", "urlgrey": "^0.4.4" } }, @@ -9483,6 +9483,17 @@ "yallist": "^3.0.2" } }, + "teeny-request": { + "version": "3.11.3", + "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-3.11.3.tgz", + "integrity": "sha512-CKncqSF7sH6p4rzCgkb/z/Pcos5efl0DmolzvlqRQUNcpRIruOhY9+T1FsIlyEbfWd7MsFpodROOwHYh2BaXzw==", + "dev": true, + "requires": { + "https-proxy-agent": "^2.2.1", + "node-fetch": "^2.2.0", + "uuid": "^3.3.2" + } + }, "temp-dir": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-1.0.0.tgz", diff --git a/package.json b/package.json index e7c73324..fe072927 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "dependencies": {}, "devDependencies": { - "codecov": "^3.0.0", + "codecov": "^3.5.0", "dts-bundle": "^0.7.3", "gulp": "^4.0.0", "gulp-clean": "^0.4.0",