diff --git a/dist/index.js b/dist/index.js index 6299f2c..5b3b40c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -113290,7 +113290,7 @@ const minimist_1 = __importDefault(__nccwpck_require__(13566)); exports.COVERAGE_DIR = ".coverage"; const run = async (isLocal) => { try { - const workingDirectory = (0, core_1.getInput)("working-directory"); + const workingDirectory = isLocal ? "." : (0, core_1.getInput)("working-directory"); // Check if the working directory is different from the current directory if (workingDirectory && workingDirectory !== process.cwd()) { process.chdir(workingDirectory); @@ -113302,6 +113302,7 @@ const run = async (isLocal) => { const runPrevCoverage = isLocal ? true : (0, core_1.getBooleanInput)("run-prev-coverage"); const runBehindBy = isLocal ? true : (0, core_1.getBooleanInput)("run-behind-by"); const createComment = isLocal ? true : (0, core_1.getBooleanInput)("create-comment"); + const score = isLocal ? "90" : (0, core_1.getInput)("coverage-pass-score"); const octokit = (0, github_1.getOctokit)(token); let prevCoverage; if (runPrevCoverage) { @@ -113316,7 +113317,9 @@ const run = async (isLocal) => { await (0, setup_1.setup)(); const analyzeStr = runAnalyze ? await (0, analyze_1.getAnalyze)() : undefined; const testStr = runTests ? await (0, runTests_1.getTest)(exports.COVERAGE_DIR) : undefined; - const coverageStr = runCoverage ? (0, coverage_1.getCoverage)(prevCoverage, exports.COVERAGE_DIR) : undefined; + const coverageStr = runCoverage + ? (0, coverage_1.getCoverage)(prevCoverage, exports.COVERAGE_DIR, score) + : undefined; const comment = createComment ? (0, comment_1.createComment)(analyzeStr, testStr, coverageStr, behindByStr) : undefined; @@ -113611,9 +113614,16 @@ exports.COV_FAILURE = "⚠️ - Coverage check failed"; * @param coverageDirectory - Directory to store coverage report * @returns Coverage report as a stepResponse object */ -const getCoverage = (prevCoverage, coverageDirectory) => { +const getCoverage = (prevCoverage, coverageDirectory, scoreStr) => { (0, core_1.startGroup)("Checking test coverage"); let response; + let score = 90; + try { + score = parseInt(scoreStr); + } + catch (error) { + console.error("Error parsing score", "Will default to 90", error); + } try { const contents = (0, node_fs_1.readFileSync)(`${coverageDirectory}/lcov.info`, "utf8"); const lcov = (0, lcov_utils_1.parse)(contents); @@ -113624,7 +113634,7 @@ const getCoverage = (prevCoverage, coverageDirectory) => { const arr = Object.values(lcov).map((e) => { const fileName = e.sf; const percent = Math.round((e.lh / e.lf) * 1000) / 10; - const passing = percent > 96 ? "✅" : "⛔️"; + const passing = percent > score ? "✅" : "⛔️"; return `