diff --git a/dist/check-group/core/generate_progress.js b/dist/check-group/core/generate_progress.js
index 0e23c16f..b230da84 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,26 @@ 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.getChecksResult)(subproject.checks, postedChecks);
+ var subprojectEmoji = "🟡";
+ if (checkResult === "all_passing") {
+ subprojectEmoji = "🟢";
+ }
+ else if (checkResult === "has_failure") {
+ 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/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 de93e2af..064e26cb 100644
--- a/dist/check-group/core/satisfy_expected_checks.js
+++ b/dist/check-group/core/satisfy_expected_checks.js
@@ -1,41 +1,55 @@
"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.getSubProjResult = exports.getChecksResult = void 0;
+var getChecksResult = 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";
+ for (var _i = 0, checks_1 = checks; _i < checks_1.length; _i++) {
+ var check = checks_1[_i];
+ 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";
+ }
+ }
+ else {
+ // the check is missing, hopefully queued
+ result = "pending";
+ }
+ }
+ ;
+ return result;
+};
+exports.getChecksResult = getChecksResult;
+var getSubProjResult = function (subProjs, postedChecks) {
+ var result = "all_passing";
+ 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];
+ 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 ((!(check in postedChecks) ||
- postedChecks[check].conclusion === null) &&
- result !== "has_failure") {
+ else {
+ // the check is missing, hopefully queued
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 b2e12a39..8a6598e3 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 { getChecksResult } from "./satisfy_expected_checks";
const statusToMark = (
@@ -90,25 +91,25 @@ 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
- const subprojectEmoji: string = Object.values(subprojectCheckStatus).every(v => v === "success") ? "🟢" : "🔴"
+ const checkResult = getChecksResult(subproject.checks, postedChecks)
+ let subprojectEmoji = "🟡";
+ if (checkResult === "all_passing") {
+ subprojectEmoji = "🟢";
+ } else if (checkResult === "has_failure") {
+ 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/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 3a661eec..17a73c4c 100644
--- a/src/check-group/core/satisfy_expected_checks.ts
+++ b/src/check-group/core/satisfy_expected_checks.ts
@@ -1,47 +1,49 @@
-/* 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 satisfyExpectedChecks = (
- subProjs: SubProjConfig[],
+export const getChecksResult = (
+ checks: string[],
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";
+ for (const check of checks) {
+ 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";
}
- if (
- (!(check in postedChecks) ||
- postedChecks[check].conclusion === null) &&
- result !== "has_failure"
- ) {
+ } else {
+ // the check is missing, hopefully queued
+ result = "pending";
+ }
+ };
+ return result;
+}
+
+export const getSubProjResult = (
+ subProjs: SubProjConfig[],
+ postedChecks: Record,
+): CheckResult => {
+ let result: CheckResult = "all_passing";
+ for (const subProj of subProjs) {
+ for (const check of subProj.checks) {
+ 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";
}
- });
- });
+ };
+ };
return result;
};