Skip to content

Commit

Permalink
chore(automated): Lint commit and format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Aug 22, 2024
1 parent 4ba5f0d commit e201e54
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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 `<tr><td>${fileName}</td><td>${percent}%</td><td>${passing}</td></tr>`;
});
(0, core_2.debug)(`Coverage at ${totalPercent}%`);
Expand Down

0 comments on commit e201e54

Please sign in to comment.