CI: added coverage artifacts.

This commit is contained in:
Richard Moore 2020-08-23 19:39:57 -04:00
parent bb8e77dc70
commit 28dbcfc38c
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
3 changed files with 135 additions and 42 deletions

@ -21,7 +21,9 @@ jobs:
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: npm ci - run: npm ci
- run: npm run build-all - run: npm run build-all
- run: npm run test-node - run: npm run test-node
@ -40,7 +42,9 @@ jobs:
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: 12.x node-version: 12.x
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: npm ci - run: npm ci
- run: npm run build-all - run: npm run build-all
- run: npm run test-browser-${{ matrix.module }} - run: npm run test-browser-${{ matrix.module }}
@ -58,7 +62,24 @@ jobs:
- uses: actions/setup-node@v1 - uses: actions/setup-node@v1
with: with:
node-version: 12.x node-version: 12.x
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: npm ci - run: npm ci
- run: npm run build-all - run: npm run build-all
- run: npm run test-coverage - run: npm run test-coverage
- name: Upload Coverage Summary
uses: actions/upload-artifact@v2
with:
name: coverage-summary
path: ./output/summary.txt
- name: Tar files
run: tar -cvf ./output/coverage.tar ./output/lcov-report/
- name: Upload Coverage
uses: actions/upload-artifact@v2
with:
name: coverage-complete
path: ./output/coverage.tar

@ -2,35 +2,63 @@
'use strict'; 'use strict';
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
// Maximum time in seconds to suppress output // Maximum time in seconds to suppress output
var MAX_DELAY = 30; var MAX_DELAY = 60;
function getTime() { function getTime() {
return (new Date()).getTime(); return (new Date()).getTime();
} }
function ReporterKeepAlive(runner) { var stdoutWrite = process.stdout.write.bind(process.stdout);
var suites = 0; var logOut = "";
var fails = 0; var capturing = false;
var errors = []; function log(message) {
var stdoutWrite = process.stdout.write.bind(process.stdout); if (message == null) {
//process.stdout.write = function(buffer: string | Uint8Array, cb?: (err?: Error) => void): boolean { message = "";
}
if (capturing) {
logOut += message;
}
else {
console.log(message);
}
}
function captureLog(initialLog) {
capturing = true;
if (initialLog == null) {
initialLog = "";
}
logOut = initialLog;
process.stdout.write = function () { process.stdout.write = function () {
var args = []; var args = [];
for (var _i = 0; _i < arguments.length; _i++) { for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i]; args[_i] = arguments[_i];
} }
return stdoutWrite("*"); logOut += "*";
return true;
}; };
}
function releaseLog() {
capturing = false;
var result = logOut;
process.stdout.write = stdoutWrite;
logOut = "";
return result;
}
function ReporterKeepAlive(runner) {
var suites = 0;
var fails = 0;
var errors = [];
// Catch anything attempting to write to the consolea
captureLog();
// Force Output; Keeps the console output alive with periodic updates // Force Output; Keeps the console output alive with periodic updates
var lastOutput = getTime(); var lastOutput = getTime();
function forceOutput() { function forceOutput() {
if (((getTime() - lastOutput) / 1000) > MAX_DELAY) { if (((getTime() - lastOutput) / 1000) > MAX_DELAY) {
log("."); var currentLog = releaseLog();
console.log("# Keep Alive: " + currentLog);
captureLog();
lastOutput = getTime();
} }
} }
var timer = setInterval(forceOutput, 1000); var timer = setInterval(forceOutput, 1000);
function log(message) {
stdoutWrite(message);
lastOutput = getTime();
}
runner.on('suite', function (suite) { runner.on('suite', function (suite) {
suites++; suites++;
fails = 0; fails = 0;
@ -40,23 +68,30 @@ function ReporterKeepAlive(runner) {
suites--; suites--;
log("]"); log("]");
if (suites === 0) { if (suites === 0) {
process.stdout.write = stdoutWrite; // Reset standard output
var currentLog = releaseLog();
if (logOut.length) {
console.log("# Keep Alive: " + currentLog);
}
// Stop the keep-alive poller
clearTimeout(timer); clearTimeout(timer);
console.log(""); // Dump out any errors encountered
console.log("#");
if (errors.length) { if (errors.length) {
console.log("---------------"); console.log("# ---------------");
errors.forEach(function (error, index) { errors.forEach(function (error, index) {
if (index > 0) { if (index > 0) {
console.log(""); console.log("#");
} }
console.log(error); error.toString().split("\n").forEach(function (line) {
console.log("# " + line);
});
}); });
} }
console.log("---------------"); console.log("# ---------------");
} }
}); });
runner.on('test', function (test) { runner.on('test', function (test) {
forceOutput();
}); });
runner.on('fail', function (test, error) { runner.on('fail', function (test, error) {
fails++; fails++;
@ -66,7 +101,6 @@ function ReporterKeepAlive(runner) {
} }
}); });
runner.on('pass', function (test) { runner.on('pass', function (test) {
forceOutput();
}); });
runner.on('pending', function (test) { runner.on('pending', function (test) {
log("?"); log("?");

@ -3,7 +3,7 @@
'use strict'; 'use strict';
// Maximum time in seconds to suppress output // Maximum time in seconds to suppress output
const MAX_DELAY = 30; const MAX_DELAY = 60;
function getTime(): number { function getTime(): number {
return (new Date()).getTime(); return (new Date()).getTime();
@ -19,31 +19,61 @@ interface Runner {
on(event: string, callback: (...args: Array<any>) => void): Runner; on(event: string, callback: (...args: Array<any>) => void): Runner;
} }
const stdoutWrite = process.stdout.write.bind(process.stdout);
let logOut = "";
let capturing = false;
function log(message?: string): void {
if (message == null) { message = ""; }
if (capturing) {
logOut += message;
} else {
console.log(message);
}
}
function captureLog(initialLog?: string): void {
capturing = true;
if (initialLog == null) { initialLog = ""; }
logOut = initialLog
process.stdout.write = function(...args: Array<any>): boolean {
logOut += "*";
return true;
}
}
function releaseLog(): string {
capturing = false;
const result = logOut;
process.stdout.write = stdoutWrite;
logOut = "";
return result;
}
export function ReporterKeepAlive(runner: Runner) { export function ReporterKeepAlive(runner: Runner) {
let suites = 0; let suites = 0;
let fails = 0; let fails = 0;
const errors: Array<string> = [ ]; const errors: Array<string> = [ ];
const stdoutWrite = process.stdout.write.bind(process.stdout); // Catch anything attempting to write to the consolea
//process.stdout.write = function(buffer: string | Uint8Array, cb?: (err?: Error) => void): boolean { captureLog();
process.stdout.write = function(...args: Array<any>): boolean {
return stdoutWrite("*");
}
// Force Output; Keeps the console output alive with periodic updates // Force Output; Keeps the console output alive with periodic updates
let lastOutput = getTime(); let lastOutput = getTime();
function forceOutput() { function forceOutput() {
if (((getTime() - lastOutput) / 1000) > MAX_DELAY) { if (((getTime() - lastOutput) / 1000) > MAX_DELAY) {
log("."); let currentLog = releaseLog();
console.log(`# Keep Alive: ${ currentLog }`);
captureLog();
lastOutput = getTime();
} }
} }
const timer = setInterval(forceOutput, 1000); const timer = setInterval(forceOutput, 1000);
function log(message: string): void {
stdoutWrite(message);
lastOutput = getTime();
}
runner.on('suite', function(suite: Suite) { runner.on('suite', function(suite: Suite) {
suites++; suites++;
fails = 0; fails = 0;
@ -55,22 +85,32 @@ export function ReporterKeepAlive(runner: Runner) {
log("]"); log("]");
if (suites === 0) { if (suites === 0) {
process.stdout.write = stdoutWrite; // Reset standard output
const currentLog = releaseLog();
if (logOut.length) {
console.log(`# Keep Alive: ${ currentLog }`);
}
// Stop the keep-alive poller
clearTimeout(timer); clearTimeout(timer);
console.log("")
// Dump out any errors encountered
console.log("#")
if (errors.length) { if (errors.length) {
console.log("---------------") console.log("# ---------------")
errors.forEach((error, index) => { errors.forEach((error, index) => {
if (index > 0) { console.log(""); } if (index > 0) { console.log("#"); }
console.log(error); error.toString().split("\n").forEach((line) => {
console.log(`# ${ line }`);
});
}); });
} }
console.log("---------------") console.log("# ---------------")
} }
}); });
runner.on('test', function(test) { runner.on('test', function(test) {
forceOutput();
}); });
runner.on('fail', function(test, error) { runner.on('fail', function(test, error) {
@ -82,8 +122,6 @@ export function ReporterKeepAlive(runner: Runner) {
}); });
runner.on('pass', function(test) { runner.on('pass', function(test) {
forceOutput();
}); });
runner.on('pending', function(test) { runner.on('pending', function(test) {