Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 7x 5x 3x 7x 7x 7x 1x 6x 6x 6x 3x 2x 1x 1x 3x 1x 2x 1x 1x 1x 2x 1x 1x | 'use strict';
/**
* Quality gate evaluation aligned with ShiftLeft platform rules for pack runs.
* @param {'FAILURE'|'UNSTABLE'} gateFailureSeverity when the gate fails, map to failed vs succeeded-with-issues
* @returns {{ decision: string, taskCompletion: 'succeeded'|'failed'|'succeededWithIssues' }}
*/
function taskCompletionFromInternal(internal) {
if (internal === 'SUCCESS') return 'succeeded';
if (internal === 'UNSTABLE') return 'succeededWithIssues';
return 'failed';
}
function evaluate(
status,
total,
passed,
failed,
error,
successRate,
passThresholdPercent,
failOnErrorTests,
gateFailureSeverity
) {
const normalized = (status || '').trim().toUpperCase();
const gateFail = gateFailureSeverity === 'UNSTABLE' ? 'UNSTABLE' : 'FAILURE';
if (failOnErrorTests && error > 0) {
return { decision: 'GATE_FAIL_ERROR_TESTS', taskCompletion: taskCompletionFromInternal(gateFail) };
}
const sr = Number.isFinite(successRate) ? successRate : computeSuccessRate(total, passed);
const threshold = Number.isFinite(passThresholdPercent) ? passThresholdPercent : 100.0;
if (threshold > 0) {
if (sr + 1e-9 < threshold) {
return { decision: 'GATE_FAIL_THRESHOLD', taskCompletion: taskCompletionFromInternal(gateFail) };
}
Eif (normalized === 'COMPLETED' || normalized === 'FAILED') {
return { decision: 'PASSED', taskCompletion: taskCompletionFromInternal('SUCCESS') };
}
return { decision: 'PASSED', taskCompletion: taskCompletionFromInternal('SUCCESS') };
}
if (normalized === 'FAILED') {
return { decision: 'FAILED', taskCompletion: taskCompletionFromInternal(gateFail) };
}
if (normalized === 'COMPLETED') {
return { decision: 'PASSED', taskCompletion: taskCompletionFromInternal('SUCCESS') };
}
Eif (failed > 0 || error > 0) {
return { decision: 'COMPLETED_WITH_ISSUES', taskCompletion: taskCompletionFromInternal('UNSTABLE') };
}
return { decision: 'OK', taskCompletion: taskCompletionFromInternal('SUCCESS') };
}
function computeSuccessRate(total, passed) {
if (total <= 0) return 0.0;
return Math.round((passed / total) * 10000) / 100.0;
}
module.exports = { evaluate, computeSuccessRate };
|