Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5 #4

Merged
merged 17 commits into from
Nov 21, 2022
Prev Previous commit
Next Next commit
Format improvements
  • Loading branch information
carmocca committed Nov 15, 2022
commit fc807c6d07b115253ad6a215e3ad7daf7dc62161
21 changes: 13 additions & 8 deletions dist/check-group/core/generate_progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.commentOnPr = exports.generateProgressDetailsMarkdown = exports.generateProgressDetailsCLI = void 0;
var statusToMark = function (check, checksStatusLookup) {
if (check in checksStatusLookup) {
if (checksStatusLookup[check] == "success") {
if (checksStatusLookup[check] === "success") {
return "✅";
}
if (checksStatusLookup[check] == "failure") {
if (checksStatusLookup[check] === "failure") {
return "❌";
}
if (checksStatusLookup[check] === "cancelled") {
return "🚫";
}
}
else {
return "⌛";
Expand Down Expand Up @@ -86,13 +89,13 @@ var generateProgressDetailsMarkdown = function (subprojects, postedChecks) {
var progress = "## Groups summary\n";
subprojects.forEach(function (subproject) {
progress += "### ".concat(subproject.id, "\n");
progress += "| Check ID | Status |\n";
progress += "| -------- | ------ |\n";
progress += "| Check ID | Status | |\n";
progress += "| -------- | ------ | --- |\n";
subproject.checks.forEach(function (check) {
var mark = statusToMark(check.id, postedChecks);
var status = (check.id in postedChecks) ? postedChecks[check.id] : 'no_status';
status = status || 'undefined';
progress += "| ".concat(check.id, " | ").concat(mark, ": ").concat(status, " |\n");
progress += "| ".concat(check.id, " | ").concat(status, " | ").concat(mark, " |\n");
});
progress += "\n";
});
Expand All @@ -107,17 +110,19 @@ function formPrComment(conclusion, inputs, subprojects, postedChecks) {
parsedConclusion = parsedConclusion.charAt(0).toUpperCase() + parsedConclusion.slice(1);
var hasFailed = conclusion === "has_failure";
var conclusionEmoji = (conclusion === "all_passing") ? "🟢" : (hasFailed) ? "🔴" : "🟡";
var failedMesage = ("\n> This job will need to be re-run to merge your PR."
var failedMesage = ("\n**\u26A0\uFE0F This job will need to be re-run to merge your PR."
+ " If you do not have write access to the repository you can ask ".concat(inputs.maintainers, " to re-run it for you.")
+ " If you have any other questions, you can reach out to ".concat(inputs.owner, " for help."));
+ " If you push a new commit, all of CI will re-trigger."
+ " If you have any other questions, you can reach out to ".concat(inputs.owner, " for help.**"));
var progressDetails = (0, exports.generateProgressDetailsMarkdown)(subprojects, postedChecks);
return (PR_COMMENT_START
+ "\n# \u26A1 Required checks status: ".concat(parsedConclusion, " ").concat(conclusionEmoji)
+ ((hasFailed) ? failedMesage : "")
+ ((subprojects.length) ? "\n".concat(progressDetails) : "\nNo groups match the files changed in this PR.")
+ "\n\n---"
+ "\nThis comment was automatically generated and updates for ".concat(inputs.timeout, " minutes ")
+ "every ".concat(inputs.interval, " seconds."));
+ "every ".concat(inputs.interval, " seconds.")
+ "\n\nThank you for your contribution! 💜");
}
function getPrComment(context) {
return __awaiter(this, void 0, void 0, function () {
Expand Down
19 changes: 12 additions & 7 deletions src/check-group/core/generate_progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ const statusToMark = (
checksStatusLookup: Record<string, string>,
): string => {
if (check in checksStatusLookup) {
if (checksStatusLookup[check] == "success") {
if (checksStatusLookup[check] === "success") {
return "✅";
}
if (checksStatusLookup[check] == "failure") {
if (checksStatusLookup[check] === "failure") {
return "❌";
}
if (checksStatusLookup[check] === "cancelled") {
return "🚫";
}
} else {
return "⌛";
}
Expand Down Expand Up @@ -63,13 +66,13 @@ export const generateProgressDetailsMarkdown = (
let progress = "## Groups summary\n";
subprojects.forEach((subproject) => {
progress += `### ${subproject.id}\n`;
progress += "| Check ID | Status |\n";
progress += "| -------- | ------ |\n";
progress += "| Check ID | Status | |\n";
progress += "| -------- | ------ | --- |\n";
subproject.checks.forEach((check) => {
const mark = statusToMark(check.id, postedChecks);
let status = (check.id in postedChecks) ? postedChecks[check.id] : 'no_status'
status = status || 'undefined';
progress += `| ${check.id} | ${mark}: ${status} |\n`;
progress += `| ${check.id} | ${status} | ${mark} |\n`;
});
progress += "\n";
});
Expand All @@ -91,9 +94,10 @@ function formPrComment(
const hasFailed = conclusion === "has_failure"
const conclusionEmoji = (conclusion === "all_passing") ? "🟢": (hasFailed) ? "🔴" : "🟡"
const failedMesage = (
`\n> This job will need to be re-run to merge your PR.`
`\n**⚠️ This job will need to be re-run to merge your PR.`
+ ` If you do not have write access to the repository you can ask ${inputs.maintainers} to re-run it for you.`
+ ` If you have any other questions, you can reach out to ${inputs.owner} for help.`
+ " If you push a new commit, all of CI will re-trigger."
+ ` If you have any other questions, you can reach out to ${inputs.owner} for help.**`
)
const progressDetails = generateProgressDetailsMarkdown(subprojects, postedChecks)
return (
Expand All @@ -104,6 +108,7 @@ function formPrComment(
+ "\n\n---"
+ `\nThis comment was automatically generated and updates for ${inputs.timeout} minutes `
+ `every ${inputs.interval} seconds.`
+ "\n\nThank you for your contribution! 💜"
)
}

Expand Down