Skip to content

Commit

Permalink
feat: improve anotation message (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
satoren authored Aug 23, 2021
1 parent 452cac6 commit 12ba55c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 46 deletions.
60 changes: 31 additions & 29 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10024,20 +10024,20 @@ const showAnnotations = async (compareFileData) => {
);

fileLinesWithChangedFiles.forEach(({ file, lines }) => {
const linesToDisplay = lines.map((line) =>
Array.isArray(line) ? line.join("-") : line
);

const linesWord = linesToDisplay.length === 1 ? "line is" : "lines are";

const formattedLines = linesToDisplay.join(", ");

const message = `file=${file}::${formattedLines} ${linesWord} not covered with tests`;

// NOTE: consider an option to show lines directly by attaching 'line' param
// Need to fix the issue where we consider 'empty line' as covered line
// Empty lines should not interapt uncovered interval
core.info(`::${showAnnotationsInput} ${message}`);
lines.forEach((line) => {
const message = () => {
if (Array.isArray(line)) {
return `file=${file},line=${line[0]},endLine=${
line[line.length - 1]
}::${line.join("-")} lines are not covered with tests`;
}
return `file=${file},line=${line}::${line} line is not covered with tests`;
};
// NOTE: consider an option to show lines directly by attaching 'line' param
// Need to fix the issue where we consider 'empty line' as covered line
// Empty lines should not interapt uncovered interval
core.info(`::${showAnnotationsInput} ${message()}`);
});
});
}
};
Expand Down Expand Up @@ -10572,111 +10572,111 @@ module.exports = JSON.parse('{"name":"axios","version":"0.21.1","description":"P
/***/ ((module) => {

"use strict";
module.exports = require("assert");;
module.exports = require("assert");

/***/ }),

/***/ 8614:
/***/ ((module) => {

"use strict";
module.exports = require("events");;
module.exports = require("events");

/***/ }),

/***/ 5747:
/***/ ((module) => {

"use strict";
module.exports = require("fs");;
module.exports = require("fs");

/***/ }),

/***/ 8605:
/***/ ((module) => {

"use strict";
module.exports = require("http");;
module.exports = require("http");

/***/ }),

/***/ 7211:
/***/ ((module) => {

"use strict";
module.exports = require("https");;
module.exports = require("https");

/***/ }),

/***/ 1631:
/***/ ((module) => {

"use strict";
module.exports = require("net");;
module.exports = require("net");

/***/ }),

/***/ 2087:
/***/ ((module) => {

"use strict";
module.exports = require("os");;
module.exports = require("os");

/***/ }),

/***/ 5622:
/***/ ((module) => {

"use strict";
module.exports = require("path");;
module.exports = require("path");

/***/ }),

/***/ 2413:
/***/ ((module) => {

"use strict";
module.exports = require("stream");;
module.exports = require("stream");

/***/ }),

/***/ 4016:
/***/ ((module) => {

"use strict";
module.exports = require("tls");;
module.exports = require("tls");

/***/ }),

/***/ 3867:
/***/ ((module) => {

"use strict";
module.exports = require("tty");;
module.exports = require("tty");

/***/ }),

/***/ 8835:
/***/ ((module) => {

"use strict";
module.exports = require("url");;
module.exports = require("url");

/***/ }),

/***/ 1669:
/***/ ((module) => {

"use strict";
module.exports = require("util");;
module.exports = require("util");

/***/ }),

/***/ 8761:
/***/ ((module) => {

"use strict";
module.exports = require("zlib");;
module.exports = require("zlib");

/***/ })

Expand Down Expand Up @@ -10715,7 +10715,9 @@ module.exports = require("zlib");;
/************************************************************************/
/******/ /* webpack/runtime/compat */
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";/************************************************************************/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
Expand Down
28 changes: 14 additions & 14 deletions src/features/showAnnotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ const showAnnotations = async (compareFileData) => {
);

fileLinesWithChangedFiles.forEach(({ file, lines }) => {
const linesToDisplay = lines.map((line) =>
Array.isArray(line) ? line.join("-") : line
);

const linesWord = linesToDisplay.length === 1 ? "line is" : "lines are";

const formattedLines = linesToDisplay.join(", ");

const message = `file=${file}::${formattedLines} ${linesWord} not covered with tests`;

// NOTE: consider an option to show lines directly by attaching 'line' param
// Need to fix the issue where we consider 'empty line' as covered line
// Empty lines should not interapt uncovered interval
core.info(`::${showAnnotationsInput} ${message}`);
lines.forEach((line) => {
const message = () => {
if (Array.isArray(line)) {
return `file=${file},line=${line[0]},endLine=${
line[line.length - 1]
}::${line.join("-")} lines are not covered with tests`;
}
return `file=${file},line=${line}::${line} line is not covered with tests`;
};
// NOTE: consider an option to show lines directly by attaching 'line' param
// Need to fix the issue where we consider 'empty line' as covered line
// Empty lines should not interapt uncovered interval
core.info(`::${showAnnotationsInput} ${message()}`);
});
});
}
};
Expand Down
6 changes: 3 additions & 3 deletions tests/features/showAnnotations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe("features/showAnnotations", () => {
assert.isTrue(mergeFileLinesWithChangedFiles.calledOnce);
assert.isTrue(info.calledTwice);
assert.deepEqual(info.secondCall.args, [
`::warning file=${filename}::${line} line is not covered with tests`
`::warning file=${filename},line=${line}::${line} line is not covered with tests`
]);
});

Expand Down Expand Up @@ -111,9 +111,9 @@ describe("features/showAnnotations", () => {
assert.isTrue(getChangedFiles.calledOnce);
assert.isTrue(uncoveredFileLinesByFileNames.calledOnce);
assert.isTrue(mergeFileLinesWithChangedFiles.calledOnce);
assert.isTrue(info.calledTwice);
assert.equal(info.callCount, 4);
assert.deepEqual(info.secondCall.args, [
`::warning file=${filename}::1-4, 8, 45-50 lines are not covered with tests`
`::warning file=${filename},line=1,endLine=4::1-4 lines are not covered with tests`
]);
});
});
Expand Down

0 comments on commit 12ba55c

Please sign in to comment.