From 31f2dfc28cf84fca87daab10c9476715a0e94e88 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 21 Nov 2022 22:46:12 +0100 Subject: [PATCH 1/7] expand MD report --- src/check-group/core/generate_progress.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/check-group/core/generate_progress.ts b/src/check-group/core/generate_progress.ts index b2e12a39..5239493c 100644 --- a/src/check-group/core/generate_progress.ts +++ b/src/check-group/core/generate_progress.ts @@ -97,7 +97,12 @@ export const generateProgressDetailsMarkdown = ( subprojectCheckStatus[check] = status }); // get the aggregated status of all statuses in the subproject - const subprojectEmoji: string = Object.values(subprojectCheckStatus).every(v => v === "success") ? "🟢" : "🔴" + let subprojectEmoji: string = "❓" + if (Object.values(subprojectCheckStatus).filter(v => v === "failure").length > 0) { + subprojectEmoji = "❌"; + } else if (Object.values(subprojectCheckStatus).every(v => v === "success")) { + subprojectEmoji = "✅"; + } // generate the markdown table progress += "
\n\n" progress += `${subprojectEmoji} ${subproject.id}\n\n`; From 922dfc7b2e2019aa44aefc1f2ef8dee917a82fe9 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 21 Nov 2022 22:57:52 +0100 Subject: [PATCH 2/7] time --- src/check-group/core/generate_progress.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/check-group/core/generate_progress.ts b/src/check-group/core/generate_progress.ts index 5239493c..19440d49 100644 --- a/src/check-group/core/generate_progress.ts +++ b/src/check-group/core/generate_progress.ts @@ -97,7 +97,7 @@ export const generateProgressDetailsMarkdown = ( subprojectCheckStatus[check] = status }); // get the aggregated status of all statuses in the subproject - let subprojectEmoji: string = "❓" + let subprojectEmoji: string = "⌛" if (Object.values(subprojectCheckStatus).filter(v => v === "failure").length > 0) { subprojectEmoji = "❌"; } else if (Object.values(subprojectCheckStatus).every(v => v === "success")) { From 5518acc80bd52ce958a8be162923ad37be3d0748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Tue, 22 Nov 2022 01:21:17 +0100 Subject: [PATCH 3/7] Fix logic --- src/check-group/core/generate_progress.ts | 24 ++++--- .../core/satisfy_expected_checks.ts | 62 +++++++------------ 2 files changed, 35 insertions(+), 51 deletions(-) diff --git a/src/check-group/core/generate_progress.ts b/src/check-group/core/generate_progress.ts index 19440d49..c27f1f7d 100644 --- a/src/check-group/core/generate_progress.ts +++ b/src/check-group/core/generate_progress.ts @@ -1,5 +1,6 @@ import { CheckResult, CheckRunData, SubProjConfig } from "../types"; import { Context } from "probot"; +import { getCheckResult } from "./satisfy_expected_checks"; const statusToMark = ( @@ -90,30 +91,27 @@ export const generateProgressDetailsMarkdown = ( ): string => { let progress = "## Groups summary\n"; subprojects.forEach((subproject) => { - // create a map of the relevant checks with their status - let subprojectCheckStatus: Record = {} - subproject.checks.forEach((check) => { - let status = (check in postedChecks) ? postedChecks[check].conclusion : 'no_status' - subprojectCheckStatus[check] = status - }); // get the aggregated status of all statuses in the subproject - let subprojectEmoji: string = "⌛" - if (Object.values(subprojectCheckStatus).filter(v => v === "failure").length > 0) { - subprojectEmoji = "❌"; - } else if (Object.values(subprojectCheckStatus).every(v => v === "success")) { - subprojectEmoji = "✅"; + const checkResult = getCheckResult(subproject.checks, postedChecks) + let subprojectEmoji: string; + if (checkResult === "all_passing") { + subprojectEmoji = "🟢"; + } else if (checkResult === "has_failure") { + subprojectEmoji = "🔴"; + } else { + subprojectEmoji = "🟡"; } // generate the markdown table progress += "
\n\n" progress += `${subprojectEmoji} ${subproject.id}\n\n`; progress += "| Check ID | Status | |\n"; progress += "| -------- | ------ | --- |\n"; - for (const [check, status] of Object.entries(subprojectCheckStatus)) { + subproject.checks.forEach((check) => { const link = statusToLink(check, postedChecks); const status = parseStatus(check, postedChecks); const mark = statusToMark(check, postedChecks); progress += `| ${link} | ${status} | ${mark} |\n`; - } + }) progress += "\n
\n\n"; }); return progress; diff --git a/src/check-group/core/satisfy_expected_checks.ts b/src/check-group/core/satisfy_expected_checks.ts index 3a661eec..e461e322 100644 --- a/src/check-group/core/satisfy_expected_checks.ts +++ b/src/check-group/core/satisfy_expected_checks.ts @@ -1,47 +1,33 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ import { CheckResult, CheckRunData, SubProjConfig } from "../types"; -/* eslint-enable @typescript-eslint/no-unused-vars */ -/** - * Checks if all the sub-project requirements are satisfied. - * - * @param subProjs The sub-projects a certain pull request - * matches. - * - * @param checksStatusLookup The checks that has already - * posted progresses. The key is the check ID and the value - * is the current check status. - * - * @returns The current result of checks fulfillment. - * * "all_passing" means all required checks post - * success conclusion. - * * "has_failure" means at least one of the required - * checks failed. - * * "pending" means there is no failure but some - * checks are pending or missing. - */ +export const getCheckResult = ( + checks: string[], + postedChecks: Record, +): CheckResult => { + let result: CheckResult = "all_passing"; + checks.forEach((check) => { + const relevant = check in postedChecks + if ( + relevant && + postedChecks[check].conclusion !== "success" && + postedChecks[check].conclusion !== null + ) { + // at least one check failed + return "has_failure"; + } + if (!relevant || postedChecks[check].conclusion === null) { + // some checks are pending or missing + result = "pending"; + } + }); + return result; +} + export const satisfyExpectedChecks = ( subProjs: SubProjConfig[], postedChecks: Record, ): CheckResult => { let result: CheckResult = "all_passing"; - subProjs.forEach((subProj) => { - subProj.checks.forEach((check) => { - if ( - check in postedChecks && - postedChecks[check].conclusion !== "success" && - postedChecks[check].conclusion !== null - ) { - result = "has_failure"; - } - if ( - (!(check in postedChecks) || - postedChecks[check].conclusion === null) && - result !== "has_failure" - ) { - result = "pending"; - } - }); - }); + subProjs.forEach((subProj) => result = getCheckResult(subProj.checks, postedChecks)); return result; }; From 6201d9599205c95f0eca1818fb1b8cdbbbb5e0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Tue, 22 Nov 2022 01:21:24 +0100 Subject: [PATCH 4/7] dist --- dist/check-group/core/generate_progress.js | 28 +++++----- .../core/satisfy_expected_checks.js | 54 +++++++------------ 2 files changed, 36 insertions(+), 46 deletions(-) diff --git a/dist/check-group/core/generate_progress.js b/dist/check-group/core/generate_progress.js index 0e23c16f..52dcc7f1 100644 --- a/dist/check-group/core/generate_progress.js +++ b/dist/check-group/core/generate_progress.js @@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.commentOnPr = exports.generateProgressDetailsMarkdown = exports.generateProgressDetailsCLI = void 0; +var satisfy_expected_checks_1 = require("./satisfy_expected_checks"); var statusToMark = function (check, postedChecks) { if (check in postedChecks) { if (postedChecks[check].conclusion === "success") { @@ -106,26 +107,29 @@ exports.generateProgressDetailsCLI = generateProgressDetailsCLI; var generateProgressDetailsMarkdown = function (subprojects, postedChecks) { var progress = "## Groups summary\n"; subprojects.forEach(function (subproject) { - // create a map of the relevant checks with their status - var subprojectCheckStatus = {}; - subproject.checks.forEach(function (check) { - var status = (check in postedChecks) ? postedChecks[check].conclusion : 'no_status'; - subprojectCheckStatus[check] = status; - }); // get the aggregated status of all statuses in the subproject - var subprojectEmoji = Object.values(subprojectCheckStatus).every(function (v) { return v === "success"; }) ? "🟢" : "🔴"; + var checkResult = (0, satisfy_expected_checks_1.getCheckResult)(subproject.checks, postedChecks); + var subprojectEmoji; + if (checkResult === "all_passing") { + subprojectEmoji = "🟢"; + } + else if (checkResult === "has_failure") { + subprojectEmoji = "🔴"; + } + else { + subprojectEmoji = "🟡"; + } // generate the markdown table progress += "
\n\n"; progress += "".concat(subprojectEmoji, " ").concat(subproject.id, "\n\n"); progress += "| Check ID | Status | |\n"; progress += "| -------- | ------ | --- |\n"; - for (var _i = 0, _a = Object.entries(subprojectCheckStatus); _i < _a.length; _i++) { - var _b = _a[_i], check = _b[0], status_2 = _b[1]; + subproject.checks.forEach(function (check) { var link = statusToLink(check, postedChecks); - var status_3 = parseStatus(check, postedChecks); + var status = parseStatus(check, postedChecks); var mark = statusToMark(check, postedChecks); - progress += "| ".concat(link, " | ").concat(status_3, " | ").concat(mark, " |\n"); - } + progress += "| ".concat(link, " | ").concat(status, " | ").concat(mark, " |\n"); + }); progress += "\n
\n\n"; }); return progress; diff --git a/dist/check-group/core/satisfy_expected_checks.js b/dist/check-group/core/satisfy_expected_checks.js index de93e2af..190e55c8 100644 --- a/dist/check-group/core/satisfy_expected_checks.js +++ b/dist/check-group/core/satisfy_expected_checks.js @@ -1,41 +1,27 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.satisfyExpectedChecks = void 0; -/* eslint-enable @typescript-eslint/no-unused-vars */ -/** - * Checks if all the sub-project requirements are satisfied. - * - * @param subProjs The sub-projects a certain pull request - * matches. - * - * @param checksStatusLookup The checks that has already - * posted progresses. The key is the check ID and the value - * is the current check status. - * - * @returns The current result of checks fulfillment. - * * "all_passing" means all required checks post - * success conclusion. - * * "has_failure" means at least one of the required - * checks failed. - * * "pending" means there is no failure but some - * checks are pending or missing. - */ -var satisfyExpectedChecks = function (subProjs, postedChecks) { +exports.satisfyExpectedChecks = exports.getCheckResult = void 0; +var getCheckResult = function (checks, postedChecks) { var result = "all_passing"; - subProjs.forEach(function (subProj) { - subProj.checks.forEach(function (check) { - if (check in postedChecks && - postedChecks[check].conclusion !== "success" && - postedChecks[check].conclusion !== null) { - result = "has_failure"; - } - if ((!(check in postedChecks) || - postedChecks[check].conclusion === null) && - result !== "has_failure") { - result = "pending"; - } - }); + checks.forEach(function (check) { + var relevant = check in postedChecks; + if (relevant && + postedChecks[check].conclusion !== "success" && + postedChecks[check].conclusion !== null) { + // at least one check failed + return "has_failure"; + } + if (!relevant || postedChecks[check].conclusion === null) { + // some checks are pending or missing + result = "pending"; + } }); return result; }; +exports.getCheckResult = getCheckResult; +var satisfyExpectedChecks = function (subProjs, postedChecks) { + var result = "all_passing"; + subProjs.forEach(function (subProj) { return result = (0, exports.getCheckResult)(subProj.checks, postedChecks); }); + return result; +}; exports.satisfyExpectedChecks = satisfyExpectedChecks; From 5acf4103760dbe5f5ccf91675b90fdee1a6f7b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Tue, 22 Nov 2022 01:46:20 +0100 Subject: [PATCH 5/7] Fixes --- dist/check-group/core/generate_progress.js | 7 ++--- dist/check-group/core/index.js | 2 +- .../core/satisfy_expected_checks.js | 29 +++++++++++++------ src/check-group/core/generate_progress.ts | 8 ++--- src/check-group/core/index.ts | 4 +-- .../core/satisfy_expected_checks.ts | 25 +++++++++++----- 6 files changed, 45 insertions(+), 30 deletions(-) diff --git a/dist/check-group/core/generate_progress.js b/dist/check-group/core/generate_progress.js index 52dcc7f1..b230da84 100644 --- a/dist/check-group/core/generate_progress.js +++ b/dist/check-group/core/generate_progress.js @@ -108,17 +108,14 @@ var generateProgressDetailsMarkdown = function (subprojects, postedChecks) { var progress = "## Groups summary\n"; subprojects.forEach(function (subproject) { // get the aggregated status of all statuses in the subproject - var checkResult = (0, satisfy_expected_checks_1.getCheckResult)(subproject.checks, postedChecks); - var subprojectEmoji; + var checkResult = (0, satisfy_expected_checks_1.getChecksResult)(subproject.checks, postedChecks); + var subprojectEmoji = "🟡"; if (checkResult === "all_passing") { subprojectEmoji = "🟢"; } else if (checkResult === "has_failure") { subprojectEmoji = "🔴"; } - else { - subprojectEmoji = "🟡"; - } // generate the markdown table progress += "
\n\n"; progress += "".concat(subprojectEmoji, " ").concat(subproject.id, "\n\n"); diff --git a/dist/check-group/core/index.js b/dist/check-group/core/index.js index b6341ca1..4520b316 100644 --- a/dist/check-group/core/index.js +++ b/dist/check-group/core/index.js @@ -136,7 +136,7 @@ var CheckGroup = /** @class */ (function () { case 1: postedChecks = _a.sent(); core.debug("postedChecks: ".concat(JSON.stringify(postedChecks))); - result = (0, satisfy_expected_checks_1.satisfyExpectedChecks)(subprojs, postedChecks); + result = (0, satisfy_expected_checks_1.getSubProjResult)(subprojs, postedChecks); this.notifyProgress(subprojs, postedChecks, result); core.endGroup(); if (result === "all_passing") { diff --git a/dist/check-group/core/satisfy_expected_checks.js b/dist/check-group/core/satisfy_expected_checks.js index 190e55c8..11010419 100644 --- a/dist/check-group/core/satisfy_expected_checks.js +++ b/dist/check-group/core/satisfy_expected_checks.js @@ -1,13 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.satisfyExpectedChecks = exports.getCheckResult = void 0; -var getCheckResult = function (checks, postedChecks) { +exports.getSubProjResult = exports.getChecksResult = void 0; +var getChecksResult = function (checks, postedChecks) { var result = "all_passing"; checks.forEach(function (check) { var relevant = check in postedChecks; - if (relevant && - postedChecks[check].conclusion !== "success" && - postedChecks[check].conclusion !== null) { + if (relevant && postedChecks[check].conclusion !== "success") { // at least one check failed return "has_failure"; } @@ -18,10 +16,23 @@ var getCheckResult = function (checks, postedChecks) { }); return result; }; -exports.getCheckResult = getCheckResult; -var satisfyExpectedChecks = function (subProjs, postedChecks) { +exports.getChecksResult = getChecksResult; +var getSubProjResult = function (subProjs, postedChecks) { var result = "all_passing"; - subProjs.forEach(function (subProj) { return result = (0, exports.getCheckResult)(subProj.checks, postedChecks); }); + subProjs.forEach(function (subProj) { + subProj.checks.forEach(function (check) { + var relevant = check in postedChecks; + if (relevant && postedChecks[check].conclusion !== "success") { + // at least one check failed + result = "has_failure"; + return; // continue + } + if (!relevant || postedChecks[check].conclusion === null) { + // some checks are pending or missing + result = "pending"; + } + }); + }); return result; }; -exports.satisfyExpectedChecks = satisfyExpectedChecks; +exports.getSubProjResult = getSubProjResult; diff --git a/src/check-group/core/generate_progress.ts b/src/check-group/core/generate_progress.ts index c27f1f7d..8a6598e3 100644 --- a/src/check-group/core/generate_progress.ts +++ b/src/check-group/core/generate_progress.ts @@ -1,6 +1,6 @@ import { CheckResult, CheckRunData, SubProjConfig } from "../types"; import { Context } from "probot"; -import { getCheckResult } from "./satisfy_expected_checks"; +import { getChecksResult } from "./satisfy_expected_checks"; const statusToMark = ( @@ -92,14 +92,12 @@ export const generateProgressDetailsMarkdown = ( let progress = "## Groups summary\n"; subprojects.forEach((subproject) => { // get the aggregated status of all statuses in the subproject - const checkResult = getCheckResult(subproject.checks, postedChecks) - let subprojectEmoji: string; + const checkResult = getChecksResult(subproject.checks, postedChecks) + let subprojectEmoji = "🟡"; if (checkResult === "all_passing") { subprojectEmoji = "🟢"; } else if (checkResult === "has_failure") { subprojectEmoji = "🔴"; - } else { - subprojectEmoji = "🟡"; } // generate the markdown table progress += "
\n\n" diff --git a/src/check-group/core/index.ts b/src/check-group/core/index.ts index c2ce89b7..785d7a44 100644 --- a/src/check-group/core/index.ts +++ b/src/check-group/core/index.ts @@ -8,7 +8,7 @@ } from "./generate_progress"; import { CheckRunData } from '../types'; import { matchFilenamesToSubprojects } from "./subproj_matching"; -import { satisfyExpectedChecks } from "./satisfy_expected_checks"; +import { getSubProjResult } from "./satisfy_expected_checks"; import { fetchConfig } from "./config_getter"; import type { CheckGroupConfig, CheckResult, SubProjConfig } from "../types"; import type { Context } from "probot"; @@ -84,7 +84,7 @@ export class CheckGroup { core.startGroup(`Check ${tries}`); const postedChecks = await getPostedChecks(this.context, this.sha); core.debug(`postedChecks: ${JSON.stringify(postedChecks)}`); - const result = satisfyExpectedChecks(subprojs, postedChecks); + const result = getSubProjResult(subprojs, postedChecks); this.notifyProgress(subprojs, postedChecks, result) core.endGroup(); diff --git a/src/check-group/core/satisfy_expected_checks.ts b/src/check-group/core/satisfy_expected_checks.ts index e461e322..481f334c 100644 --- a/src/check-group/core/satisfy_expected_checks.ts +++ b/src/check-group/core/satisfy_expected_checks.ts @@ -1,17 +1,13 @@ import { CheckResult, CheckRunData, SubProjConfig } from "../types"; -export const getCheckResult = ( +export const getChecksResult = ( checks: string[], postedChecks: Record, ): CheckResult => { let result: CheckResult = "all_passing"; checks.forEach((check) => { const relevant = check in postedChecks - if ( - relevant && - postedChecks[check].conclusion !== "success" && - postedChecks[check].conclusion !== null - ) { + if (relevant && postedChecks[check].conclusion !== "success") { // at least one check failed return "has_failure"; } @@ -23,11 +19,24 @@ export const getCheckResult = ( return result; } -export const satisfyExpectedChecks = ( +export const getSubProjResult = ( subProjs: SubProjConfig[], postedChecks: Record, ): CheckResult => { let result: CheckResult = "all_passing"; - subProjs.forEach((subProj) => result = getCheckResult(subProj.checks, postedChecks)); + subProjs.forEach((subProj) => { + subProj.checks.forEach((check) => { + const relevant = check in postedChecks + if (relevant && postedChecks[check].conclusion !== "success") { + // at least one check failed + result = "has_failure"; + return // continue + } + if (!relevant || postedChecks[check].conclusion === null) { + // some checks are pending or missing + result = "pending"; + } + }); + }); return result; }; From cf6fc273ad09fd7d11eff1dd6573c4480b4a551e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Tue, 22 Nov 2022 02:01:08 +0100 Subject: [PATCH 6/7] Use for-of --- .../core/satisfy_expected_checks.js | 21 ++++++++++++------- .../core/satisfy_expected_checks.ts | 15 +++++++------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/dist/check-group/core/satisfy_expected_checks.js b/dist/check-group/core/satisfy_expected_checks.js index 11010419..76538456 100644 --- a/dist/check-group/core/satisfy_expected_checks.js +++ b/dist/check-group/core/satisfy_expected_checks.js @@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.getSubProjResult = exports.getChecksResult = void 0; var getChecksResult = function (checks, postedChecks) { var result = "all_passing"; - checks.forEach(function (check) { + for (var _i = 0, checks_1 = checks; _i < checks_1.length; _i++) { + var check = checks_1[_i]; var relevant = check in postedChecks; if (relevant && postedChecks[check].conclusion !== "success") { // at least one check failed @@ -13,26 +14,30 @@ var getChecksResult = function (checks, postedChecks) { // some checks are pending or missing result = "pending"; } - }); + } + ; return result; }; exports.getChecksResult = getChecksResult; var getSubProjResult = function (subProjs, postedChecks) { var result = "all_passing"; - subProjs.forEach(function (subProj) { - subProj.checks.forEach(function (check) { + for (var _i = 0, subProjs_1 = subProjs; _i < subProjs_1.length; _i++) { + var subProj = subProjs_1[_i]; + for (var _a = 0, _b = subProj.checks; _a < _b.length; _a++) { + var check = _b[_a]; var relevant = check in postedChecks; if (relevant && postedChecks[check].conclusion !== "success") { // at least one check failed - result = "has_failure"; - return; // continue + return "has_failure"; } if (!relevant || postedChecks[check].conclusion === null) { // some checks are pending or missing result = "pending"; } - }); - }); + } + ; + } + ; return result; }; exports.getSubProjResult = getSubProjResult; diff --git a/src/check-group/core/satisfy_expected_checks.ts b/src/check-group/core/satisfy_expected_checks.ts index 481f334c..87e504ee 100644 --- a/src/check-group/core/satisfy_expected_checks.ts +++ b/src/check-group/core/satisfy_expected_checks.ts @@ -5,7 +5,7 @@ export const getChecksResult = ( postedChecks: Record, ): CheckResult => { let result: CheckResult = "all_passing"; - checks.forEach((check) => { + for (const check of checks) { const relevant = check in postedChecks if (relevant && postedChecks[check].conclusion !== "success") { // at least one check failed @@ -15,7 +15,7 @@ export const getChecksResult = ( // some checks are pending or missing result = "pending"; } - }); + }; return result; } @@ -24,19 +24,18 @@ export const getSubProjResult = ( postedChecks: Record, ): CheckResult => { let result: CheckResult = "all_passing"; - subProjs.forEach((subProj) => { - subProj.checks.forEach((check) => { + for (const subProj of subProjs) { + for (const check of subProj.checks) { const relevant = check in postedChecks if (relevant && postedChecks[check].conclusion !== "success") { // at least one check failed - result = "has_failure"; - return // continue + return "has_failure"; } if (!relevant || postedChecks[check].conclusion === null) { // some checks are pending or missing result = "pending"; } - }); - }); + }; + }; return result; }; From 0fe368ef276ced90eea2521c368a7f34740fe18d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Tue, 22 Nov 2022 02:11:32 +0100 Subject: [PATCH 7/7] I love nulls --- .../core/satisfy_expected_checks.js | 36 ++++++++++++------- .../core/satisfy_expected_checks.ts | 36 +++++++++++-------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/dist/check-group/core/satisfy_expected_checks.js b/dist/check-group/core/satisfy_expected_checks.js index 76538456..064e26cb 100644 --- a/dist/check-group/core/satisfy_expected_checks.js +++ b/dist/check-group/core/satisfy_expected_checks.js @@ -5,13 +5,19 @@ var getChecksResult = function (checks, postedChecks) { var result = "all_passing"; for (var _i = 0, checks_1 = checks; _i < checks_1.length; _i++) { var check = checks_1[_i]; - var relevant = check in postedChecks; - if (relevant && postedChecks[check].conclusion !== "success") { - // at least one check failed - return "has_failure"; + if (check in postedChecks) { + var conclusion = postedChecks[check].conclusion; + if (conclusion === null) { + // the check is in progress + result = "pending"; + } + else if (conclusion !== "success") { + // the check already failed + return "has_failure"; + } } - if (!relevant || postedChecks[check].conclusion === null) { - // some checks are pending or missing + else { + // the check is missing, hopefully queued result = "pending"; } } @@ -25,13 +31,19 @@ var getSubProjResult = function (subProjs, postedChecks) { var subProj = subProjs_1[_i]; for (var _a = 0, _b = subProj.checks; _a < _b.length; _a++) { var check = _b[_a]; - var relevant = check in postedChecks; - if (relevant && postedChecks[check].conclusion !== "success") { - // at least one check failed - return "has_failure"; + if (check in postedChecks) { + var conclusion = postedChecks[check].conclusion; + if (conclusion === null) { + // the check is in progress + result = "pending"; + } + else if (conclusion !== "success") { + // the check already failed + return "has_failure"; + } } - if (!relevant || postedChecks[check].conclusion === null) { - // some checks are pending or missing + else { + // the check is missing, hopefully queued result = "pending"; } } diff --git a/src/check-group/core/satisfy_expected_checks.ts b/src/check-group/core/satisfy_expected_checks.ts index 87e504ee..17a73c4c 100644 --- a/src/check-group/core/satisfy_expected_checks.ts +++ b/src/check-group/core/satisfy_expected_checks.ts @@ -6,13 +6,17 @@ export const getChecksResult = ( ): CheckResult => { let result: CheckResult = "all_passing"; for (const check of checks) { - const relevant = check in postedChecks - if (relevant && postedChecks[check].conclusion !== "success") { - // at least one check failed - return "has_failure"; - } - if (!relevant || postedChecks[check].conclusion === null) { - // some checks are pending or missing + if (check in postedChecks) { + const conclusion = postedChecks[check].conclusion; + if (conclusion === null) { + // the check is in progress + result = "pending"; + } else if (conclusion !== "success") { + // the check already failed + return "has_failure"; + } + } else { + // the check is missing, hopefully queued result = "pending"; } }; @@ -26,13 +30,17 @@ export const getSubProjResult = ( let result: CheckResult = "all_passing"; for (const subProj of subProjs) { for (const check of subProj.checks) { - const relevant = check in postedChecks - if (relevant && postedChecks[check].conclusion !== "success") { - // at least one check failed - return "has_failure"; - } - if (!relevant || postedChecks[check].conclusion === null) { - // some checks are pending or missing + if (check in postedChecks) { + const conclusion = postedChecks[check].conclusion; + if (conclusion === null) { + // the check is in progress + result = "pending"; + } else if (conclusion !== "success") { + // the check already failed + return "has_failure"; + } + } else { + // the check is missing, hopefully queued result = "pending"; } };